3

How can I reference a range of equations in the form I want? For example, I want to reference a range of equations starting with Eq. (A.3) and ending with Eq. (A.7), what is a simple way to get the reference to display as Eq. (A.3-7)? I know how to get (A.3-A.7) but I don't love the way it looks.

ETA working example:

\begin{align}
a &= b  \label{eq:beg} \\
b &= c  \\
c &= d  \\
d &= e  \\
e &= f  \label{eq:end}
\end{align}

You can see from Eq.~(\ref{eq:beg}-(\ref{eq:end}) that $a = f$

This displays

You can see from Eq. (A.3-A.7) that a=f

but I want it to display

You can see from Eq. (A.3-7) that a=f
Well...
  • 133
  • Welcome to TeX.SX! Please help us help you and add a minimal working example (MWE) that illustrates your problem. Reproducing the problem and finding out what the issue is will be much easier when we see compilable code, starting with \documentclass{...} and ending with \end{document}. – DG' Oct 07 '20 at 09:54
  • Are you willing and able to use the cleveref package to create cross-referencing call-outs? – Mico Oct 07 '20 at 10:00
  • @Mico Sure, I made a quick attempt at cleveref but found that it was formatting (A.3) to (A.7), which isn't the output I want. How can I do what I want using cleveref? – Well... Oct 07 '20 at 10:02
  • 1
    You need to check out p. 20 of the package's user guide. Anyway, I'm about to post an answer that makes use of cleveref's machinery. – Mico Oct 07 '20 at 10:11

1 Answers1

4

Your formatting objective may be achieved in a straightforward manner by employing some of the machinery of the cleveref package.

enter image description here

\documentclass{article}
\usepackage[noabbrev]{cleveref}
\crefrangelabelformat{equation}% see p. 20 of package's user guide
    {(#3#1#4--#5\crefstripprefix{#1}{#2}#6)}

\begin{document} \noindent \crefrange{eq:c}{eq:g}, \labelcref{eq:c,eq:g,eq:e,eq:d,eq:f} % input arguments needn't be sorted

\appendix \counterwithin{equation}{section} \section{Supplemental material} \begin{equation} a \label{eq:a} \end{equation} \begin{equation} b \label{eq:b} \end{equation} \begin{equation} c \label{eq:c} \end{equation} \begin{equation} d \label{eq:d} \end{equation} \begin{equation} e \label{eq:e} \end{equation} \begin{equation} f \label{eq:f} \end{equation} \begin{equation} g \label{eq:g} \end{equation} \end{document}

Mico
  • 506,678