10

I searched the tex.stackexchange archives for an answer to this question but couldn't find one. I assume it's a common question, however.

I often want to align text similar to the poly environment in lhs2TeX. For instance:

e(x)      = x
e(M N)    = e(M) e(N)
e(λx:τ.M) = λx:τ.e(M)
e(λ_:τ.M) = λx:τ.e(M)  (x ∉ FV(M))

The solutions I see are to use a tabular environment, an eqnarray, or an align. However, align and eqnarray create columns that are too far apart, and tabular has similar, but less significant spacing problems.

Is there a simple solution to this problem? The layout is common, so I assume there is.

3 Answers 3

14

The alignat environment from amsmath can manage that.

\documentclass{article}
\usepackage{amsmath}

\begin{document}
  \begin{alignat}{2}
    & e(x)                &&= x\\
    & e(M N)              &&= e(M) e(N)\\
    & e(\lambda x:\tau.M) &&= \lambda x:\tau.e(M)\\
    & e(\lambda\_:\tau.M) &&= \lambda x:\tau .e(M)  (x \notin FV(M))
  \end{alignat}
\end{document}
0
2

According to the manual, the lhsTeX poly environment uses the polytable package internally. So I maybe that package provides the table format you are looking for.

2

You could use an array:

\documentclass{article}
\begin{document}
\[\begin{array}{ll}
e(x)      &= x\\
e(M N)    &= e(M) e(N)\\
e(\lambda x:\tau.M) &= \lambda x:\tau.e(M)\\
e(\lambda\_:\tau.M) &= \lambda x:\tau .e(M)  (x \notin FV(M))\\
\end{array}\]
\end{document}

If the spacing is too far apart, use @ separators for the column specifications, e.g., \begin{array}{l@{\,}l}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .