Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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.

share|improve this question

2 Answers 2

up vote 14 down vote accepted

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}% http://ctan.org/pkg/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.

share|improve this answer
    
great! will give it a read, also my apologies for the unknown macro, you converted it correctly, –  codd May 20 '12 at 14:35
    
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
    
@codd: See @_barbarabeeton's answer. –  Werner May 20 '12 at 17:31

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

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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