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.

Here is yet another attempt at this question. I've narrowed down a MWE:

\documentclass{article}
\usepackage{amsmath}
\usepackage[amsmath,standard,thmmarks]{ntheorem}

\begin{document}
Integer suscipit massa et nulla accumsan sed lacinia lacus tincidunt. Aenean nisi lacus, iaculis eu consequat in, fermentum eget urna. Proin augue lacus, euismod eu tempor vel, mollis eget quam. Donec vitae consequat nulla. In cursus sagittis diam, at tristique sem interdum pharetra.
\begin{theorem}
  Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec risus mi, pharetra eget sodales volutpat, aliquam eu metus. Aenean ultricies iaculis sapien, pretium lobortis ligula ultrices a.
  \begin{proof}
    Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec risus mi, pharetra eget sodales volutpat, aliquam eu metus. Aenean ultricies iaculis sapien, pretium lobortis ligula ultrices a.
    \begin{equation*}
      A = \{x_{i,j}: i = 1, \ldots, n; j = 1, \ldots, m\}
    \end{equation*}
    Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec risus mi, pharetra eget sodales volutpat, aliquam eu metus. Aenean ultricies iaculis sapien, pretium lobortis ligula ultrices a.
  \end{proof}
\end{theorem}
Morbi gravida dapibus dapibus. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Mauris mauris diam, faucibus vitae pretium vitae, volutpat eget velit. Aenean quis vestibulum ante. Duis enim tortor, accumsan eget hendrerit non, pellentesque vel magna. Duis eros turpis, auctor vel aliquam vitae, congue ut dolor.
\begin{equation*}
  A = \{x_{i,j}: i = 1, \ldots, n; j = 1, \ldots, m\}
\end{equation*}
Sed a libero mi. Donec cursus dignissim quam tincidunt fermentum. Curabitur ac libero leo, non sagittis nisi. Proin sodales tincidunt ante, in aliquam justo cursus in. Nunc tempus feugiat volutpat. Phasellus porttitor dolor elementum quam suscipit tempus. Donec posuere consectetur turpis sed congue. Sed et nunc dui, sit amet viverra erat. Ut malesuada molestie quam, porta fringilla libero consequat quis.
\begin{theorem}
  Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec risus mi, pharetra eget sodales volutpat, aliquam eu metus. Aenean ultricies iaculis sapien, pretium lobortis ligula ultrices a.
  \begin{proof}
    Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec risus mi, pharetra eget sodales volutpat, aliquam eu metus. Aenean ultricies iaculis sapien, pretium lobortis ligula ultrices a.
    \begin{equation*}
      A = \{x_{i,j}: i = 1, \ldots, n; j = 1, \ldots, m\}
    \end{equation*}
    Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec risus mi, pharetra eget sodales volutpat, aliquam eu metus. Aenean ultricies iaculis sapien, pretium lobortis ligula ultrices a.
  \end{proof}
\end{theorem}
Nullam elementum libero ut erat suscipit cursus non eget nibh. In accumsan rhoncus scelerisque. Sed vel eros et lacus tincidunt laoreet. Etiam molestie metus id tortor euismod vitae bibendum nisi rhoncus.

Pellentesque nec gravida ligula. Curabitur nibh sem, porta in suscipit non, porttitor lobortis arcu. Sed imperdiet, nisi sit amet vehicula lobortis, eros urna aliquam magna, sed auctor sem dui nec turpis. Nulla facilisi. Nam a elit lacus. Etiam vel leo ligula. Donec lectus mi, tristique at lobortis id, viverra nec felis.
\begin{equation*}
  Ax = b \quad\mbox{Uneven skips with equation* and thmmarks?}
\end{equation*}
Etiam vel felis at enim pulvinar lacinia lacinia quis ipsum. Etiam ac elementum tellus. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Pellentesque sit amet rhoncus tortor.
\begin{theorem}
  Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec risus mi, pharetra eget sodales volutpat, aliquam eu metus. Aenean ultricies iaculis sapien, pretium lobortis ligula ultrices a.
  \begin{proof}
    Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec risus mi, pharetra eget sodales volutpat, aliquam eu metus. Aenean ultricies iaculis sapien, pretium lobortis ligula ultrices a.
    \begin{equation*}
      Ax = b \quad\mbox{Uneven skips with equation* and thmmarks?}
    \end{equation*}
    Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec risus mi, pharetra eget sodales volutpat, aliquam eu metus. Aenean ultricies iaculis sapien, pretium lobortis ligula ultrices a.
  \end{proof}
\end{theorem}

Nullam sollicitudin nisl ac metus malesuada fermentum. Mauris tellus arcu, porttitor et condimentum ut, commodo pellentesque justo. Nam rutrum, nunc non dictum placerat, dolor metus interdum dui, eu tincidunt libero mauris vel ante.
\begin{equation*}
  A = \{x_{i,j}: i = 1, \ldots, n; j = 1, \ldots, m\}
\end{equation*}
Nunc placerat auctor odio, vel ullamcorper massa dapibus eu. Suspendisse luctus, erat at semper pulvinar, velit diam convallis metus, vitae aliquam nibh tortor vitae neque. Morbi venenatis eleifend sapien at pulvinar. Quisque urna leo, molestie ut consequat id, porta vitae neque. Praesent varius convallis justo id tincidunt. Duis nulla elit, euismod sit amet tincidunt ut, sodales eu felis. Phasellus rutrum bibendum urna sit amet iaculis.
\begin{equation*}
  Ax = b \quad\mbox{Uneven skips with equation* and thmmarks?}
\end{equation*}
Nullam vel velit quis nibh volutpat ullamcorper. Pellentesque tempor turpis quis massa tincidunt imperdiet. Nam lobortis, justo quis mollis faucibus, erat enim lobortis massa, sagittis egestas lacus odio sed enim. Morbi pulvinar placerat sem, eget pulvinar risus hendrerit sit amet. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Sed elementum faucibus mi, eget euismod magna convallis vel. Fusce egestas posuere dignissim.
\end{document}

The uneven display skips arise with ntheorem's automatic end mark placement, enabled using the thmmarks option.

Three of the last four equations appear to be unevenly spaced in the resulting document. Here is an excerpt with the thmmarks option:

enter image description here

And without the thmmarks option:

enter image description here

share|improve this question
2  
The undesired effect in your example code disappears once I use "real" text instead of the filler text given by the lipsum package. I was trying to produce a minimal example with "real" text, but failed. Can you please post a minimal example showing the undesired effect, but using real text? –  Gonzalo Medina May 13 '11 at 20:48
3  
Recent versions of lipsum provide the \lipsum* command that doesn't add \par at the end of the dummy text. –  egreg May 13 '11 at 22:43
    
@Gonzalo, @egreg: Thanks for pointing this out. @Gonzalo: I can't replicate the problem in a minimal example, either. I've tried stripping down the actual document I'm working with, but the problem disappears. I'll edit my question to help with some troubleshooting. –  Audrey May 14 '11 at 2:55

4 Answers 4

up vote 3 down vote accepted
+100

It seems to work properly if you replace the equation environment with amsmath gather (this is a good idea in general, anyway), because the amsmath version of the equation environment doesn't really work as well as the other amsmath environments, and it can have similar uneven spacing in other circumstances (such as with hyperref loaded). You can do this by adding to your preamble (after loading amsmath and ntheorem):

\let\equation\gather
\let\endequation\endgather
\expandafter\let\csname equation*\expandafter\endcsname\csname gather*\endcsname
\expandafter\let\csname endequation*\expandafter\endcsname\csname endgather*\endcsname

EDIT 1: This is a good workaround with the amsmath option fleqn. Unequal skips tend to occur when ntheorem doesn't set a tag/endmark (see ntheorem documentation on \SetEndMark). So an alternative to redefining equation is to make \SetEndMark generate some whitespace instead:

\makeatletter
\gdef\SetEndMark#1#2{%
   \stepcounter{end#1ctr}%
   \@ifundefined{mark\thm@romannum{curr#1ctr}#1\thm@romannum{end#1ctr}}%
   {\,\relax}% EDIT: Set a thin space instead of nothing
   {#2{\csname mark\thm@romannum{curr#1ctr}#1\thm@romannum{end#1ctr}\endcsname
       \ifdim\rightmargin>\z@\hskip-\rightmargin\fi
       \hbox to 0cm{}}}}
\makeatother

EDIT 2: The uneven skips can be produced with version 1.31 of ntheorem available from CTAN. Version 1.32 available directly from the authors includes some changes to the handling of skips that appear to mitigate (and possibly resolve) the problem. Version 1.33 (not yet released) should contain a direct fix.

share|improve this answer
    
Thanks. I quickly tested this on my actual document and it appears to fix the problem. I'll do a more thorough check in the next day or so. In the meantime, if there is any further advice you could provide re: math environments, that would be great. In addition to equation, I also use align and multline heavily. –  Audrey Aug 11 '11 at 14:01
1  
@Audrey: Unequal spacing of amsmath&hyperref equation see here (but also here, which explains a reason to stick with equation anyway. Personally I prefer fleqn, so the shortskips are not relevant to me). eqnarray is bad: to quote ShreevatsaR Avoid eqnarray! Avoid eqnarray! Avoid eqnarray!. Other amsmath envs (align et al) are ok. –  Lev Bishop Aug 11 '11 at 16:10
    
Very helpful. I use hyperref as well. My only hesitation in accepting your answer is that in replacing equation with gather, I lose shortskips. Use of fleqn is a little too unconventional and my eye is really missing all those places where \abovedisplayshortskip used to kick in. Any ideas? –  Audrey Aug 11 '11 at 16:38
1  
@Audrey: Some ideas, in order of increasing difficulty: 0) drop the [thmmarks] option; 1) set \parfillskip short, to never allow a short line preceding a display; 2) save the definitions of the equation envs before you load ntheorem and restore them afterwards (this will break the automatic mark in the case that an equation env terminates the proof) ; 3) Fix the bug in ntheorem; 4) fix amsmath to use short skips with gather et al. Of these, only (1) and (4) will also solve the problem with hyperref. –  Lev Bishop Aug 11 '11 at 18:45
    
Sounds good. I tend to avoid proofs ending with displays, so it looks like I can make a compromise with use of thmmarks. I will investigate further. Unless someone else comes along with a full solution, I'll accept your answer since you've pointed me in the right direction. –  Audrey Aug 11 '11 at 18:55

\lipsum produces a paragraph of text. If you compile \lipsum[1]a, you will see that the “a” is in a new paragraph. Thus you also get a \parskip of vertical space before the equation.

Typically you do not want to have paragraphs before equations. So you should also not have a blank line before an equation. The question How can I get rid of indentation after an equation? has some more information.

share|improve this answer
    
Yeah, sorry about that. I didn't look at the documentation closely enough in preparing the MWE. My problem arises when the display is surrounded by text, no \parskips before or after. –  Audrey May 14 '11 at 2:47
    
@Audrey: Could you please add a concrete example to the question. –  Caramdir May 14 '11 at 2:56
    
I've tried, but the only example I can come with up isn't minimal. I've edited my question to reflect that. –  Audrey May 14 '11 at 3:19
2  
Just for clarification: This answer was helpful in pointing out that my first MWE was bad. It no longer applies to this new MWE. –  Audrey Aug 11 '11 at 14:49

The skip below and above of the equation depends on four predefined lengths:

\abovedisplayskip
\abovedisplayshortskip
\belowdisplayskip
\belowdisplayshortskip

The lengths are describe in mathmode by Herbert Voß (p. 31 section 11.5.1).

Important: amsmath isn't able to use this length. amsmath always uses \belowdisplayskip and \abovedisplayskip

share|improve this answer
    
Thanks. I'm aware of that... The above and below skip lengths are equal by default. I assume that the problem is that, being rubber lengths, they don't stretch equally. I'm wondering if there is a solution that won't require me to change the skip lengths for every unevenly spaced equation manually. –  Audrey May 13 '11 at 20:13
    
@Audrey: Nope, rubber lengths should always stretch equally. –  Hendrik Vogt Jun 13 '12 at 13:56
    
@HendrikVogt Around a vanilla equation, of course. ntheorem's automatic endmark placement checks were making rubber skip lengths unequal. –  Audrey Jun 13 '12 at 15:50
    
I'm pretty sure that the current amsmath puts \abovedisplayshortskip and \belowdisplayshortskip above and below equation and equation* (and equation*'s synonyms) when needed. amsmath does always use \abovedisplayskip and \belowdisplayskip with its other equation environments (align, gather, split, etc.). –  MSC Apr 18 '13 at 19:10
    
@MSC: Only the environment equation can handle \abovedisplayshortskip. The new version of amsmath doesn't fix it. –  Marco Daniel Apr 18 '13 at 19:21

Thus far there has been no complete answer. And rather than comment on other answers, I thought a discussion in "answer" form would be appropriate.


I think the fundamental problem here starts with the ntheorem package choice thmmarks, as suggested by @Audrey's MWE:

The uneven display skips arise with memoir and ntheorem with automatic end mark placement enabled.

By removing this option, the above/below skips of the equation* environment is reasonable - I'm not taking out my ruler just yet. My motivation stems from the fact that ntheorem with thmmarks allows the user to forget about how the placement of a theorem mark will work when ending the environment with an equation. As such, when the package option thmmarks is given, ntheorem redefines the way \[ and \] operates. Here's an extract of the ntheorem redefinition from ntheorem.sty (lines 83-116, v1.31, 2011/02/16, TeX Live 2011):

 83: \gdef\[{%
 84:   \relax\ifmmode
 85:     \@badmath
 86:   \else
 87:     \ifvmode
 88:       \nointerlineskip
 89:       \makebox[.6\linewidth]%
 90:     \fi
 91:     $$\stepcounter{end\InTheoType ctr}%
 92:       \@ifundefined{mark\thm@romannum{curr\InTheoType ctr}%
 93:         \InTheoType\thm@romannum{end\InTheoType ctr}}{\relax}%
 94:       {\ifx\csname\InTheoType Symbol\endcsname\@empty\else
 95:         \boxmaxdepth=.5ex\begin{array}[b]{@{}l}%
 96:         \boxmaxdepth=\maxdimen\displaystyle\fi}%
 97:       \addtocounter{end\InTheoType ctr}{-1}%
 98:     %%$$ BRACE MATCH HACK
 99:   \fi}
100: \gdef\]{%
101:   \stepcounter{end\InTheoType ctr}%
102:   \@ifundefined{mark\thm@romannum{curr\InTheoType ctr}%
103:     \InTheoType\thm@romannum{end\InTheoType ctr}}{\relax}%
104:     {\ifx\csname\InTheoType Symbol\endcsname\@empty\else
105:       \end{array}\fi}%
106:     \addtocounter{end\InTheoType ctr}{-1}%
107:     \relax\ifmmode
108:       \ifinner
109:         \@badmath
110:       \else
111:         \PotEndMark{\eqno}\global\@ignoretrue$$%%$$ BRACE MATCH HACK
112:       \fi
113:   \else
114:     \@badmath
115:   \fi
116:   \ignorespaces}

Equivalently, I presume, this also affects the way the equation* environment works. However, the unstarred version of equation is left untouched, for obvious reasons: You won't place a theorem mark on the right side of a numbered equation. To see this, replace equation* with equation and the spacing seems fine.

This provides another motivation for the success when using @Lev's answer - by using something other than equation*; a redefinition of equation* as gather*. As far as I can tell, gather (and gather*) is void of using \[ and \], but rather uses $\displaystyle ...$ for typesetting, thereby side-stepping ntheorem's redefinition.

I'm not a LaTeX programmer (yet!), so trying to figure out how to change/modify the code to make it work is daunting to say the least. Moreover, the redefinition of \[ and \] contain some things that I can't explain. For example, the use of \makebox[.6\linewidth] (line 89) seems arbitrary. And then I thought the use of $$ for displaymath in LaTeX was a big no-no, but it clearly forms part of this redefinition (lines 91+111).

share|improve this answer
    
Thanks - I'd be willing to accept a discussion that leads me to a solution. I need to do some more testing, but I think Lev has caught the problem. At the end of section 5.2 of the ntheorem manual, the authors state that the endmark placement algorithm has not been thoroughly tested with amsmath environments, so they could be a source of bugs. Section 7 gives some code documentation. Not sure if that would help in interpreting the code above. In any case, it's over my head. –  Audrey Aug 11 '11 at 14:11
1  
Just an add-on: In my document, the uneven spacing only occurs with equation*. So your interpretation of the code is correct. Using an alternative to equation* means parting with shortskips. I'd prefer to avoid this. –  Audrey Aug 11 '11 at 17:15
    
I managed to find the bug by tracing backwards through the code handling the options thmmarks and amsmath. It appears a little later than the code above. Your post still helped, though. It's too bad I can only award one user the bounty. Thanks again. –  Audrey Aug 12 '11 at 19:30

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.