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'd like to have something like the following:

\begin{enumerate}
\item $1 + 1 = 2$ 
\item $1 = 2 - 1$
\end{enumerate}

The thing is, I'd also like the equals signs to be aligned. But I'd like the equation with the widest left side to start out right after the item number, as if that line were text.

[Note: What I'm trying to do is state a theorem with several parts, each of which is most easily stated as an equation. Obviously, if I only cared about the "minimal working example" above, I would be better off using an align environment and equation numbers.]

Is there a reasonable way to do this?

share|improve this question
add comment

6 Answers

up vote 3 down vote accepted
\usepackage{array}

\newenvironment{enumalign}
  {\par\addvspace{\topsep}\setcounter{enumi}{0}
   \noindent$\begin{array}{@{}r@{\hspace{\labelsep}}r@{}>{{}}l@{}}}
  {\end{array}$\par\addvspace{\topsep}}
\newcommand{\eitem}{\stepcounter{enumi}\makebox[\labelwidth][r]{\theenumi.}&}

\begin{document}
\begin{enumalign}
\eitem 1+1&=2\\
\eitem 1&=2-1
\end{enumalign}

Remember to end the rows with \\

share|improve this answer
    
This is really great. The only issue I see is that there is not enough space between lines. (In a more complicated example, I had square brackets in the same horizontal position on neighboring lines, and they were almost touching.) –  Charles Staats Oct 10 '11 at 23:21
    
You can add \renewcommand{\arraystretch}{1.5} or so before the \noindent and you have always available the optional argument to \\: \\[2ex], for instance. –  egreg Oct 10 '11 at 23:24
    
I'm accepting this answer because it is as much as I might have hoped for. I found that 2.5 seemed to work best for the particular example I cared about. But I will say that this enumalign environment does not seem to do as good a job of automatically adjusting the vertical spacing as either the enumeration or the align environment. (The example I have in mind does not fit in this comment.) –  Charles Staats Oct 11 '11 at 1:39
add comment
\documentclass[leqno]{report}
\usepackage{amsmath}

\begin{document}

\begin{flalign}
1 + 1 &= 2     &\\
    1 &= 2 - 1 
\end{flalign}

\end{document}

enter image description here

share|improve this answer
1  
Is there a way to use this without putting any other equation numbers on the left? –  Charles Staats Oct 9 '11 at 21:04
    
Charles: Yes there is. I have provided a way of doing this. Let me know if it was what you were looking to do and if not I can adjust the answer accordingly. –  night owl Oct 9 '11 at 23:01
add comment

You could use \hphantom for taking the required space for alignment:

\documentclass{article}
\usepackage{mathtools}
\begin{document}
\begin{enumerate}
\item $1 + 1 = 2$ 
\item $\hphantom{1+1}\mathllap{1} = 2 - 1$
\end{enumerate}
\end{document}
share|improve this answer
1  
Without mathtools and only \llap should do the same –  Herbert Oct 9 '11 at 18:09
    
@Herbert: with just \llap you would get a text font 1, not a math font 1. If \llap is used, one should switch into math mode within the argument, such as \llap{$1$} instead of \llap{1}. Even if math digits are similar to text digits - in other cases it could be variables or symbols. And I guess knowing about mathtools is beneficial, so I mentioned that. –  Stefan Kottwitz Oct 9 '11 at 18:31
    
Thanks! I had never heard of either the \llap or the \mathllap command, which is probably why I was having so much trouble. –  Charles Staats Oct 9 '11 at 18:37
    
@Stefan: I know that it only works for digits. But in this case, you do not need \llap{$1$}, the 1 is taken from the text font, so $$ is superflous –  Herbert Oct 9 '11 at 18:39
    
@Herbert: The example in question is a "minimal working example." The version using just \llap would not generalize to the example I actually care about. –  Charles Staats Oct 9 '11 at 18:52
add comment

Note: This is based very heavily on Stefan Kottwitz's answer; I've just used some macros to make it a little bit more flexible.

\documentclass{article}
\usepackage{mathtools}

\newcommand{\leftsidelength}{}
\newcommand{\leftside}[1]{\hphantom{\leftsidelength}\mathllap{#1}}

\begin{document}

\begin{enumerate}
\renewcommand{\leftsidelength}{1+1}
\item $\leftside{\leftsidelength} = 2$ 
\item $\leftside{1} = 2 - 1$
\end{enumerate}

\end{document}

Someone who knows what they're talking about may tell me that there's a much better way to do this, but it seems to work. More importantly, if there is more than one line, it eliminates typing redundancy for the "phantomized" longest line, which makes for a more robust setup.

The only missing component would be an automatic way to determine which left side is longest.

share|improve this answer
    
Incidentally, I'm aware that the \leftside{} command in the first item is unnecessary. I included it for uniformity. –  Charles Staats Oct 9 '11 at 18:53
add comment

I tried once (and was surprised that it actually work) to use \item inside \intertext of the nested align environment:

\begin{enumerate}
     \item First point, blah
     \begin{align}
          a &= b+2  \\ %% not sure about whether those \\ are needed or not
      \intertext{\item Second point, blah}
          b &= c+3
     \end{align}
\end{enumerate}
share|improve this answer
1  
I was going to point to my answer at tex.stackexchange.com/questions/29119/…, where I say just this, except that it seems the OP wants his equations on the same line as the enumeration numbers, and this can't accomplish that (you have to write "First point, blah" to fill up that line and put the equation below it). –  Ryan Reich Oct 9 '11 at 21:46
add comment
\documentclass{article}
\usepackage[fleqn]{amsmath}

\begin{document}
\begin{flalign} % Displays all equation #'s in environment.
1 + 1 &= 2 \\
1 &= 2 - 1 &
\end{flalign}
------------------------------
\begin{flalign*}% Add the * if you want no equation #'s displayed.
1 + 1 &= 2 \\
1 &= 2 - 1 &
\end{flalign*}
------------------------------
\begin{flalign}
1 + 1 &= 2 \notag \\% \notag used if you want to specify equation #'s
                    % only for certain equations. 
1 &= 2 - 1 \\
3 + 4 &= 7 \notag \\
4 &= 7 - 3 &
\end{flalign}

\end{document}

Results below:

Align

share|improve this answer
    
The point here was that, if I were going to use Herbert's solution, I would want a way of putting some equation numbers on the left and others on the right. I'm already familiar with ways to omit certain equation numbers. –  Charles Staats Oct 10 '11 at 23:10
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.