Tourmaline is not a single mineral. It is the name of a large family of minerals all of which are borosilicates (aluminium silicates which contain boron) and have the same basic structure. However tourmaline is not particularly fussy about the elements it can incorporate into its growth. It will accept a fairly wide range of different cations into several lattice sites. This leads to a truly diverse range of colours and coloration effects.
Tourmaline is formed by the transport of hot boron rich fluids. It can be found in igneous and metamorphic rocks.