0

In the following code

\documentclass{article}
\usepackage{amsthm}
\newcounter{number}
\begin{document}
\begin{proof}ccc\[aaa\]\end{proof}
\label{\thenumber}
\begin{proof}ee\end{proof}
\end{document}

the \label command produces additional vertical space, which is not there, if I omit this command. How can I avoid this space? This is maybe related to Additional space by \refstepcounter, but here the 'hyperref' package is not involved.

  • 1
    What is \label{\thenumber} supposed to do in your code? – leandriis 2 days ago
  • It writes the current value of the counter 'number' to the aux-file. – Gerhard 2 days ago
  • 1
    you could write the number directly to the aux file if that is needed, (\immediate\write never affects spacing) but using \label with a generated number is very weird. – David Carlisle 2 days ago
  • Are you sure the extra space isn't related to the fact that the tombstone for the proof is moved down because the proof ends with a display? (I don't have a tex system available to try this out to see the result. A visual of the output would have helped.) – barbara beeton 2 days ago
1

Normally if one display environment (or section heading,etc) follows another, any vertical spacing specified by the end of one and the start of the next is merged, so you only get the maximum of the two lengths,not the sum.

However the \write node produced by \label (which is needed to delay the writing to the aux file, so \pageref works) means that here the second proof environment can not "see" the vertical space that has been added by the first proof, so you get

end proof space, write node, begin proof space

instead of

max(end proof space, begin proof space)

The solution is to put the \label somewhere safer (almost always better not to do it in vmode if it can be avoided), so for example this works

\documentclass{article}
\usepackage{amsthm}
\newcounter{number}
\begin{document}
\begin{proof}ccc\[aaa\label{\thenumber}\]\end{proof}
\begin{proof}ee\end{proof}
\end{document}

Unrelated to the space issue (as that would be the same with \label{zzz}) but using \label with a counter generated label key is a rather strange construct.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.