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.

Take a look at the following minimal working example:

\documentclass[a4paper, 11pt, leqno]{article}
\usepackage{amsmath, enumitem}
\title{}
\author{Who knows?}
\date{}
\begin{document}
    \maketitle
    Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam felis nisi, hendrerit vitae accumsan et, gravida nec felis. Maecenas turpis urna, ultrices non volutpat ac, eleifend sit amet dui.

    \begin{enumerate}[label=(YZW\alph*), leftmargin=*, align=left, widest=4]
        \item Nullam enim turpis, condimentum non pretium ut, pharetra at justo. Donec eu nibh nec augue rhoncus pharetra vel hendrerit mi:
            \begin{equation}
                E \neq mc^{\sqrt{2}}.
            \end{equation}
        \item Sed aliquet enim magna. Phasellus ligula quam, pharetra id bibendum sed, mollis quis nibh. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. 
    \end{enumerate}
    Nulla molestie ultrices lectus, vel facilisis arcu laoreet ac. Nullam pulvinar, ligula in commodo auctor, augue nibh tincidunt nulla:
    \begin{equation}
        E = mc^{(-\sqrt{2})^2}.
    \end{equation}
    Here endeth the lesson.
\end{document}

Of the two equation numbers, the first appears indented within the enumerated list. I would like to align all equation numbers as they normally should be---at the extreme left of the margin. Any ideas how to do this?

share|improve this question
2  
there seems to be disagreement on how equation numbers should appear within indented lists. the ams document classes, by themselves, do not indent, but put the equation numbers at the left margin. there have been quite a few requests to indent them to the level of the list indentation. (you can't please everyone.) perhaps this should be a settable option. –  barbara beeton Apr 19 '13 at 15:18
    
So should we add the amsmath tag to the question? –  jjdb Apr 19 '13 at 15:21
    
@jjdb: added the tag amsmath –  dnemoc Apr 19 '13 at 15:25
    
I agree that there's a disagreement on how equation numbers should appear within indented lists, and I certainly don't want to ruffle any feathers here. If this option is settable, would anyone please point out the appropriate place? –  dnemoc Apr 19 '13 at 15:26
    
Did you have a look at the amsmath documentation? –  jjdb Apr 19 '13 at 15:29

3 Answers 3

This seems to work, but I don't know if it will in all cases. However, if you plan to have numbered equations in enumerated lists, it's surely better to put numbers on the right, where they won't clash with the list items.

\documentclass[a4paper, 11pt, leqno]{article}
\usepackage{enumitem}
\usepackage{amsmath}

\makeatletter
\everydisplay=\expandafter{\the\everydisplay
  \ifdim\@totalleftmargin>\z@
    \displayindent=\dimexpr-\@totalleftmargin+\leftmargin\relax
    \displaywidth=\columnwidth
  \fi
}
\makeatother

\begin{document}

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam felis nisi, hendrerit vitae accumsan et, gravida nec
felis. Maecenas turpis urna, ultrices non volutpat ac, eleifend sit amet dui.
\begin{enumerate}[label=(YZW\alph*), leftmargin=*, align=left, widest=4]
\item Nullam enim turpis, condimentum non pretium ut, pharetra at justo. Donec eu nibh nec augue rhoncus pharetra vel
hendrerit mi:
\begin{equation}
E \neq mc^{\sqrt{2}}.
\end{equation}
\item Sed aliquet enim magna. Phasellus ligula quam, pharetra id bibendum sed, mollis quis nibh. Class aptent taciti
sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos.
\end{enumerate}
Nulla molestie ultrices lectus, vel facilisis arcu laoreet ac. Nullam pulvinar, ligula in commodo auctor, augue nibh
tincidunt nulla:
\begin{equation}
E = mc^{(-\sqrt{2})^2}.
\end{equation}
Here endeth the lesson.
\end{document}

enter image description here


When TeX starts to typeset a math display it executes the tokens contained in the token parameter \everydisplay. So I tell LaTeX to override the computed value of \displaywidth and of \displayindent when \@totalleftmargin is positive (which it is in lists). So we want that the indent is the negative of \@totalleftmargin minus the \leftmargin (the computation depends on how LaTeX sets lists), and the \displaywidth is the normal column width.

Anybody can change those parameters (provided they know what they are doing); TeX will use the values current at the end of the math material for typesetting the display.

share|improve this answer
    
could you explain you're solution more in detail? I would love to understand how your magic spells work ;) –  jjdb Apr 19 '13 at 17:42
    
@egreg: Thank you so much for this lovely bit of code. –  dnemoc Apr 20 '13 at 4:47

You could end the enumerate environment before the equation environment, and start an new one afterward, yielding the following result (removing the leqno option):

enter image description here

\documentclass[a4paper, 11pt]{article}
\usepackage{ enumitem}
\title{}
\author{Who knows?}
\date{}
\begin{document}
\maketitle
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam felis nisi, hendrerit vitae accumsan et, gravida nec felis. Maecenas turpis urna, ultrices non volutpat ac, eleifend sit amet dui.

\begin{enumerate}[label=(YZW\alph*), leftmargin=*, align=left, widest=4, nolistsep]
    \item Nullam enim turpis, condimentum non pretium ut, pharetra at justo. Donec eu nibh nec augue rhoncus pharetra vel hendrerit mi:
\end{enumerate}
\begin{equation}
   E \neq mc^{\sqrt{2}}.
\end{equation}
\begin{enumerate}[label=(YZW\alph*), leftmargin=*, align=left, widest=4, nolistsep, resume]
    \item Sed aliquet enim magna. Phasellus ligula quam, pharetra id bibendum sed, mollis quis nibh. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos.
\end{enumerate}
Nulla molestie ultrices lectus, vel facilisis arcu laoreet ac. Nullam pulvinar, ligula in commodo auctor, augue nibh tincidunt nulla:
\begin{equation}
    E = mc^{(-\sqrt{2})^2}.
\end{equation}
Here endeth the lesson.
\end{document}

Without the options the spacing after between the enumerate and the equation environments might not be correct. But as Gonzalo pointed out in his comment, choosing the right options fixes that pretty much.

share|improve this answer
    
Nice, but then that is liable to mess up with various spacings, especially if one employs a non-standard \parskip :( –  dnemoc Apr 19 '13 at 15:23
    
In that case I would really tweak that manually. Or are there multiple occurences of this construction? –  jjdb Apr 19 '13 at 15:27
    
There are multiple occurrences of this construction, for sure. I've tried a few hacks, but none is quite good. –  dnemoc Apr 19 '13 at 15:31
1  
Since dnemoc is loading enumitem, you can say \begin{enumerate}[nolistsep] for the first list, and \begin{enumerate}[nolistsep,resume], for the second one. This improves the spacing and also keeps the numbering sequence. –  Gonzalo Medina Apr 19 '13 at 15:42
    
@Gonzalo yap, that works. Hope you don't mind if I incorporate it above in the answer? –  jjdb Apr 19 '13 at 15:47

i haven't tried it, but it seems to me that simply removing the [leqno] option should get rid of the positioning problem. if the equation numbers aren't on the left, then the indentation of the enumerate doesn't even enter the picture.

of course, if your document also has theorems and proofs, you want a "tombstone" at the ends of proofs, and any of your proofs end with numbered displays, then there's a built-in conflict, and it's not a good option.

share|improve this answer
    
Oh, I should have specified a priori: I do want the leqno option. This problem with equation number alignment doesn't arise in amsmath; have to look at that documentation. –  dnemoc Apr 20 '13 at 4:44

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.