# Multiple items/equations in single eqref call

How can I reference multiple items/equations in a single \eqref call? I want, e.g., "In (1,2)..." instead of "In (1) and (2)...". I'd think I could do something like

\begin{enumerate}
\item blah \label{it:1}
\item blah \label{it:2}
\end{enumerate}

In \eqref{it:1, it:2}...

but that doesn't work.

• In (\ref{it:1}, \ref{it:2}) blah; don't overuse \eqref. Apr 8, 2012 at 17:50
• @egreg Good idea. Thanks. Why do you say "overuse"? Apr 8, 2012 at 18:19
• \eqref is not a general substitute for \ref. Apr 8, 2012 at 19:09
• @egreg What, exactly, do you mean? Feel free to provide a reference to something I can read that explains what you mean. Apr 8, 2012 at 20:11
• The purpose of \eqref is to print a reference to an equation, with the same format as the equation numbers (and always upright). This format is not, in general, the one to use for other cross references. Apr 8, 2012 at 20:17

The command \eqref is meant for printing references to equations in the same format as used for numbering the equations (and always in upright type).

This is not always appropriate for other cross references. For example, items are usually numbered without parentheses and it could be difficult for the reader to interpret the cross reference "In (1, 2)". But this is a matter of opinion and yours is as good as mine.

So (\ref{it:1},~\ref{it:2}) can be the solution when only a few of these cross references are used in the document. If you need them more than a few times, then probably a macro can be useful.

The easiest way is to use LaTeX3 facilities; the macro can be tailored to other formats, if need arises.

\usepackage{xparse}
\ExplSyntaxOn
\NewDocumentCommand{\mref}{m}{\quinn_mref:n {#1}}
\seq_new:N \l_quinn_mref_seq
\cs_new:Npn \quinn_mref:n #1
{
\seq_set_split:Nnn \l_quinn_mref_seq { , } { #1 }
\seq_pop_right:NN \l_quinn_mref_seq \l_tmpa_tl
( % print the left parenthesis
\seq_map_inline:Nn \l_quinn_mref_seq
{ \ref{##1},\nobreakspace } % print the first references
\exp_args:NV \ref \l_tmpa_tl % print the last or only one
) % print the right parenthesis
}
\ExplSyntaxOff

If you want to ensure that the references are always printed in upright shape, then you can change the first definition into

\NewDocumentCommand{\mref}{m}{\textup{\quinn_mref:n {#1}}}

## Complete example

\documentclass{article}
\usepackage{xparse}
\ExplSyntaxOn
\NewDocumentCommand{\mref}{m}{\quinn_mref:n {#1}}
\seq_new:N \l_quinn_mref_seq
\cs_new:Npn \quinn_mref:n #1
{
\seq_set_split:Nnn \l_quinn_mref_seq { , } { #1 }
\seq_pop_right:NN \l_quinn_mref_seq \l_tmpa_tl
( % print the left parenthesis
\seq_map_inline:Nn \l_quinn_mref_seq
{ \ref{##1},\nobreakspace } % print the first references
\exp_args:NV \ref \l_tmpa_tl % print the last or only one
) % print the right parenthesis
}
\ExplSyntaxOff

\begin{document}
\begin{enumerate}
\item\label{it:1}  blah
\item\label{it:2}  blah
\end{enumerate}

In \mref{it:1,it:2} and this \emph{does} work!

In \mref{it:1} there's only one!
\end{document}

• I know this is an old post, but can I ask, is there a way of doing this so that my LaTeX editor (TeXstudio) recognises this command, and gives me the auto-fill options when I start typing the reference? At the moment, it gives me an unrecognized command warning (but still compiles), and no autofill, and the references don't turn green, as they do with \eqref{equation} for example. (This may not be possible, of course) Aug 23, 2018 at 17:09

For referencing multiple equations (not items, though), consider the suggestions at https://stackoverflow.com/q/3328806 where you can, for example, group multiple (related) equations using subequations and align and then reference either the group of equations or the individual ones.