4

I use autonum package to number the equations only when they are referenced. However, sometimes I want to refer to a range of equations. For example, I have 4 equations and I type \eqref{eq1}-\eqref{eq4}. But, the 2 equations in between will not be numbered, since they are not referenced. Is there some way to manually number these equations as well?

Here is a minimal example

\documentclass{article}
\usepackage{autonum}
\begin{document}
\begin{equation}
equation 1  \label{e1}
\end{equation}
\begin{equation}
equation 2
\end{equation}
\begin{equation}
equation 3
\end{equation}
\begin{equation}
equation 4  \label{e4}
\end{equation}

I want to refer to \eqref{e1}-\eqref{e4}, but the middle two will not be numbered with autonum.
\end{document}
1
  • Welcome to TeX.SX! Please help us help you and post a MWE.
    – TeXnician
    Commented Mar 19, 2017 at 16:16

3 Answers 3

2

The following example provides \retainlabel{<label>} which acts like \label{<label>} but also immediately sets a \ref{<label>} inside a box. The \ref is never set, but called and therefore not removed by autonum:

enter image description here

\documentclass{article}

\usepackage{amsmath,autonum}

\newcommand{\retainlabel}[1]{\label{#1}\sbox0{\ref{#1}}}

\begin{document}

\begin{equation}
  f_1(x) = ax^2 + bx + c \label{eqn:one}
\end{equation}
\begin{equation}
  f_2(x) = ax^2 + bx + c \retainlabel{eqn:two}
\end{equation}
\begin{equation}
  f_3(x) = ax^2 + bx + c \retainlabel{eqn:three}
\end{equation}
\begin{equation}
  f_4(x) = ax^2 + bx + c \label{eqn:four}
\end{equation}

See \eqref{eqn:one}--\eqref{eqn:four}.

\end{document}
2

autonum offers "+" variants of math environments, including equation+ which get numbered regardless of being referenced or not:

\documentclass{article}
\usepackage{autonum}
\begin{document}
\begin{equation}
equation 1  \label{e1}
\end{equation}
\begin{equation+}
equation 2
\end{equation+}
\begin{equation+}
equation 3
\end{equation+}
\begin{equation}
equation 4  \label{e4}
\end{equation}
I want to refer to \eqref{e1}--\eqref{e4}, and now the middle two will also be
numbered with autonum.
\end{document}

enter image description here

1
\documentclass{article}



\usepackage{hyperref}
\usepackage{cleveref}
\usepackage{autonum}



\begin{document}

\begin{equation}
a\label{a}
\end{equation}
\begin{equation}
b\label{b}
\end{equation}
\begin{equation}
c\label{c}
\end{equation}

Consider \cref{a,b,c}.
\end{document}

I've included hypertext because the ordering of packages is important when you use autonum. Cleveref is one of my favorite packages.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .