7

When using mathtools with the option showonlyrefs I find a spurious vertical spacing. I have found a similar question but the issue there was a long equation, which is not my case. Consider the MWE

\documentclass{minimal}
\usepackage{mathtools}
\mathtoolsset{showonlyrefs}
\begin{document}
\begin{equation}
\label{eq}
a=b
\end{equation}
This is an equation %\refeq{eq}
\end{document}

If one uncomments \refeq, the vertical space after the equation is reduced. Any ideas?

2

This is probably a `feature' of the problematic equation environment (see various posts on this site). It disappears in the following example.

\documentclass{minimal}
\usepackage{mathtools}
\mathtoolsset{showonlyrefs}
\begin{document}
\begin{gather}
\label{eq}
a=b
\end{gather}
This is an equation %\refeq{eq}
\end{document}
  • 1
    good point! That is reason, why in my document I usually use gather instead equation. – Zarko Jul 30 '15 at 19:40
2

The autonum package seems to be better at it:

\documentclass{article}
\usepackage{amsmath}
\usepackage{autonum}

\usepackage{lipsum} % for mock text

\begin{document}

\lipsum*[2]
\begin{equation}
\label{eq1}
a=b
\end{equation}
This is an equation \eqref{eq1}.
\lipsum*[2]
\begin{equation}
\label{eq2}
a=b
\end{equation}
\lipsum[2]

\end{document}

enter image description here

1

use align instead of equation

\begin{align}\label{eq}
    a &= b
\end{align}
This is an equation \refeq{eq}

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.