# What is the actual function of "&" in math environment?

First of all, I must and want to say that I really like the idea of this website. It's pretty awesome to have a place like this where you can ask all your questions regarding LaTeX/TeX. :D

My question might be rather trivial. In fact, I have not really figured out the actual function of the & sign in mathematical environments. I know that one can use it in order to add explanations of variables next to mathematical formulas. If I add e.g. the expression && i &= \text{interest} under a formula that contains the variable i, I can define that as the interest rate in the specific formula and in the final document it will appear next to the formula.

But what does the & exactly do? Why do I have to add two of it in order to have a correct typesetting. As you might have already noticed, I haven't understood the syntax of it yet. :D

It would be so nice if somebody could help me with this one.

Thank you very, very much in advance.

Best regards,

Marcel

OK, so I want to provide the code I promised yesterday.

The original code I referred to yesterday is this one:

\documentclass[a4paper,10pt]{scrartcl}

\usepackage[utf8]{inputenc}
\usepackage[ngerman]{babel}
\usepackage[T1]{fontenc}
\usepackage{amsmath}

\begin{document}

\begin{align*}
G(x) &= 0 & G &= \text{Gewinn} \\
&& x &= \text{Menge} \\
\Leftrightarrow E - K = 0 \\
&& E &= \text{Erlös} \\
&& K &= \text{Kosten} \\
\Leftrightarrow E = K \\
\Leftrightarrow p \cdot x = K_{f} + k_{v} \cdot x \\
&& p &= \text{Preis} \\
&& K_{f} &= \text{Fixkosten} \\
&& k_{v} &= \text{variable Kosten}\\
\Rightarrow x = \frac{K_{f}}{p - k_{v}}\\
\end{align*}

\end{document}


I simply copy-pasted the structure from another forum and used it to express my own formulas, but did not really understand what it does - until yesterday. :) With the explanations of & as an alignment marker I got yesterday, I managed to align the formulas at the arrow signs:

[\documentclass[a4paper,10pt]{scrartcl}

\usepackage[utf8]{inputenc}
\usepackage[ngerman]{babel}
\usepackage[T1]{fontenc}
\usepackage{amsmath}

\begin{document}

\begin{align*}
G(x) &= 0 & G &= \text{Gewinn} \\
&& x &= \text{Menge} \\
&\Leftrightarrow E - K = 0 \\
&& E &= \text{Erlös} \\
&& K &= \text{Kosten} \\
&\Leftrightarrow E = K \\
&\Leftrightarrow p \cdot x = K_{f} + k_{v} \cdot x \\
&& p &= \text{Preis} \\
&& K_{f} &= \text{Fixkosten} \\
&& k_{v} &= \text{variable Kosten}\\
&\Rightarrow x = \frac{K_{f}}{p - k_{v}}\\
&bzw.\ \boxed{p = \frac{K_{f}}{x} + k_{v}}
\end{align*}

\end{document}]


That looks much tidier. So I think that I understood the basic functionality of &. But what I'm still uncertain about is the meaning of &&. I also experimented a bit with that and it appears to me that this is just meant to create space. Similar to using the tab button in programs like Word. Did I get that right?

Thanks again. :D

• Welcome to TeX.SX! the & is used as an alignment marker among groups of equations or other math notation (e.g. matrix columns) treated together within a single environment. since the rules are somewhat different for different packages and environments, it's best to consult the package documentation for specifics. Mar 22, 2015 at 19:54
• As an example if you load amsmath package and type \begin{align}123456789 &= x\\y = 123456789\end{align} then they will be aligned at the = sign instead of just centered. But every package uses it for different alignment purpose. If you include your own code then more suitable answer can be given. Mar 22, 2015 at 19:58
• Hi! @barbara explained it well. For align, we surely have a nicely written answer explaining the behaviour, for instance this one: tex.stackexchange.com/questions/200813/…
– yo'
Mar 22, 2015 at 20:29

In TeX & is used for alignment. That is, aligning parts of equations on different lines. My favourite example is the cases environment and, as egreg says in the comments, other common examples include matrices, via array, tables, via tabular ,and the many amsmath alignment environments like align, split ...

If you want an ampersand in mathematics use \&:

\documentclass{article}
\usepackage{amsmath}
\begin{document}

$|x| = \begin{cases} x, &\text{if }x\ge0,\\ -x, &\text{if }x<0. \end{cases}$

For an ampersand in math-mode type $\&$.

\end{document}


• Other examples include matrices and the align environment. Mar 22, 2015 at 20:33
• back to the documentation -- gather is not an aligned environment. an unwary & in that environment will not do anything useful, and may even result in an error message for a misplaced &. Mar 23, 2015 at 4:03