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.

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.

share|improve this question
add comment

3 Answers

up vote 15 down vote accepted

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}
share|improve this answer
    
This works great; thanks for the response. –  danportin Feb 7 '11 at 2:56
add comment

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}

share|improve this answer
add comment

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.

share|improve this answer
add comment

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.