Some crystals, like quartz and diamonds, form in a variety of different colors. For example, quartz can be clear, 'foggy', pink, yellow, and even blue.
- What happens during the crystal's formation to make it one color or another?
Some crystals, like quartz and diamonds, form in a variety of different colors. For example, quartz can be clear, 'foggy', pink, yellow, and even blue.
The reason minerals like quarts and diamonds vary in color is generally caused by the chemical elements involved while the crystal is being formed.
Chemicals
Different colors can be created by different chemicals. Amethyst for example has traces of iron built into its crystalline structure giving it a purple hue. Iron can also give crystals a yellow hue.
[edit: See Gimelist's answer for a much more detailed and colorful explanation]
Growth Imperfections
Some colors, like in smoky quartz, are from growth imperfections. These imperfections change the way the crystal reflects light, which changes the appearance of coloration.
Light
Part of the color seen when looking at a crystal is light. When light enters a crystal its spectrum is broken apart, and part of it is absorbed while other parts are reflected. This changes the apparent color of the crystal.
I'd like to elaborate of the Chemicals issue of Azzie Rogers' answer.
You can divide the chemical coloring into three main parts (there may be more, but these are the important ones):
Inclusions
A large, solid crystal can have tiny inclusions of other solid minerals. Commonly these inclusions are too small to individually observe by the naked eye. Microscopic methods, either optic or electronic, are usually required to properly identify the inclusions. Nonetheless, when a crystal is viewed on a macroscopic scale, the inclusions give their characteristic color to the mineral.
Here is one great example:
(Fig. 4 of Anenburg et al. 2014)
You can see the blue celestine (strontium sulfate) in the bottom, and the white calcite (calcium carbonate) on top. Their interface is colored red and salmon pink. The reason is the existence of tiny micrometer sized inclusions of iron oxides (i.e. rust). Note that the iron oxides are different minerals, e.g. hematite, goethite, etc.
Mineral inclusions can sometimes cause even more spectacular effects, such as asterism: (source: Charles Tilford)
In this case, the cause are tiny inclusions of rutile (titanium oxide).
Crystal field theory (allochromatism)
The crystal field theory explains, among other things, what happens to light as it encounters metals in different structural configurations inside a crystal. Keeping the complicated terminology at minimum (energy level splitting yay!), what basically happens is that different metal cations (positively charged atoms) in a crystalline structure absorb different wavelengths of light. The identity of the metal is not the only important thing: a paramount factor is the number of oxygen atoms that surround the metal atoms and their shape (be it a tetrahedron, octahedron, etc.) These metals are not part of of the formal chemical composition of the mineral. Instead, they replace other atoms in the mineral by very little amounts. For example, ruby is a mineral composed of aluminum oxide. If you take just a bit of this aluminum and replace it with chromium (less than 1% is enough), it becomes vivid red. Note that in contrast to inclusions, we are talking about different metals in the same mineral, and not inclusions of different minerals.
A digestible explanation with some nice photographs and applets can be found here: http://www.chm.davidson.edu/vce/coordchem/cft.html
Idiochromatism
This is the case where the color of the mineral is not dictated by trace amounts of metals in an otherwise colorless mineral (see the ruby example above), but rather by the major chemical constituents of the mineral. A great example is copper, which gives strong green colors to some minerals that contain it (e.g. malachite):
Or the red color of cinnabar, given by mercury: