61

In the following piece of code

\begin{align*}
[x \mapsto s]x &= s \\
[x \mapsto s]y &= y \qquad \text{als } y\neq x \\
[x \mapsto s](\la{y}t_1) &= \la{y}[x \mapsto s]t_1 \qquad \text{als } y \neq x \text{ en   } y \not \in FV(s) \\
[x \mapsto s](t_1 \; t_2)&= ([x \mapsto s]t_1)\;([x \mapsto s]t_2)
\end{align*}

I am currently only aligning on the = sign. Is it however also possible to align on more than one place in the environment? I would also like the \text to be aligned, as wel as the begining of each new line.

67

Multiple alignment points with no gap between expressions is obtained using the alignat environment from amsmath. The following MWE illustrates that:

enter image description here

\documentclass{article}

\usepackage{amsmath}

\begin{document}

\begin{alignat*}{3}
  &[x \mapsto s]x &&= s && \\
  &[x \mapsto s]y &&= y \qquad &&\text{als } y\neq x \\
  &[x \mapsto s](\lambda(y)t_1) &&= \lambda(y)[x \mapsto s]t_1 \qquad &&\text{als } y \neq x \text{ en   } y \not \in FV(s) \\
  &[x \mapsto s](t_1 \; t_2)&&= ([x \mapsto s]t_1)\;([x \mapsto s]t_2) &&
\end{alignat*}

\end{document}

I've taken the liberty to convert the unknown \la{<arg>} macro to \lambda(<arg>).

Consider reading Herbert's mathmode document. It illustrates the various "alignment environments" of amsmath clearly. Specifically, see section 25 align environments, p 43 onward.

  • great! will give it a read, also my apologies for the unknown macro, you converted it correctly, – codd May 20 '12 at 14:35
  • 1
    One doesn't even need alignat: the simple align can do the same, but it adds spacing as it thinks correct, which might not be what the user wants. – egreg May 20 '12 at 14:37
  • egreg: could you elaborate? Because spacing would be nice, I currently forced it using \qquad... – codd May 20 '12 at 14:38
  • 1
    @codd: See @_barbarabeeton's answer. – Werner May 20 '12 at 17:31
  • The link to Herbert's mathmode document is dead. A more recent version can be found here, with section 25 on the align environments from p 46 onward. – Inactive - avoiding CoC Oct 13 '16 at 9:51
30

using just align would be done like this:

\documentclass{article}
\usepackage{amsmath}% http://ctan.org/pkg/amsmath
\begin{document}
\begin{align*}
  [x \mapsto s]x &= s \\
  [x \mapsto s]y &= y &&\text{als } y\neq x \\
  [x \mapsto s](\lambda(y)t_1) &= \lambda(y)[x \mapsto s]t_1 &&\text{als } y \neq x \text{ en   } y \not \in FV(s) \\
  [x \mapsto s](t_1 \; t_2) &= (x \mapsto s]t_1)\;([x \mapsto s]t_2)
\end{align*}
\end{document}

this gives the following result:

display with multiple alignment points

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.