8

Is there a way to automatically refer to a set of equations in an align environment?

E.G. I would like this to read "From Eqs.(1-3), we can clearly see..."

\documentclass{article}
\usepackage{amsmath}
\begin{document}\thispagestyle{empty}
  \begin{align}\label{eqn:myeqs}
    x =& y\\
    y = \sqrt{x-q}\\
    z =& y-20l
  \end{align}

  \begin{equation}\label{eqn:somethingelse}
    E = \hbar \omega
  \end{equation}

  From Eqs. \ref{eqn:myeqs}, we can clearly see...
\end{document}

I've seen a way to do this manually, but I'm curious to see if there's a simple, automated way to handle this.

2
  • 2
    You could add a label to both the first and the last line in the align and use cleverefs \crefrange as in tex.stackexchange.com/questions/18986/… Edit: Sorry, the formatting is a little different. Feb 10, 2014 at 20:51
  • This plus a quick \crefname{equation}{Eq.}{Eqs.} got me exactly to what I need! Would you be able to submit this as answer so I can give you credit? I realize its similar to the previous one, but I tried numerous search terms and couldn't arrive at it so it may be helpful to others to have this example.
    – zje
    Feb 10, 2014 at 21:05

1 Answer 1

8

You can add a label to both the first and last equation in an align, and use cleverefs \crefrange{first label}{second label} to create the reference. The format of the references printed by cleveref can be modified as described in chapter 8 of the manual.

Some additional points:

  • In an align the & should be placed before the =, not after, as you had in your code. Having it after leads to wrong spacing.

  • If you use hyperref, cleveref should be loaded after hyperref.

enter image description here

\documentclass{article}
\usepackage{amsmath}
\usepackage{cleveref}
\crefrangelabelformat{equation}{(#3#1#4--#5#2#6)}
\crefname{equation}{Eq.}{Eqs.}
\Crefname{equation}{Equation}{Equations}
\begin{document}
\begin{align}
    x &= y    \label{eq:a}\\
    y &= \sqrt{x-q}\\
    z &= y-20l  \label{eq:b}
\end{align}
From \crefrange{eq:a}{eq:b}, we can clearly see\ldots

\Crefrange{eq:a}{eq:b} shows \ldots
\end{document}
1
  • @orbjørn-t This worked for me. Thanks.
    – PoreyS
    Feb 3, 2022 at 14:46

You must log in to answer this question.

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