3

I am writing a document with equations and I am used to refer to equations with \eqref{label}.

However if I want to refer to it in a commentary with parenthesis (see Eq. \eqref{label}), it will make double parenthesis, which is not nice I guess.

I was expecting something like the \cite command which allows for including extra words in it with \citep[something before][something after]{label} but it does not work.

Should I use (see Eq. \ref{label})or is this just sort of a hack and impropoer Latex typo ?

1

Although I don't think this is the ideal solution, you can redefine the command \eqref, because this means that it will change it for the whole document. If you don't want this, just define a different command.

If you want to define a new command, just write:

\newcommand\myeqref[1]{
    (see Eq. \textup{\ref{#1}})
}

Output

enter image description here

Code

\documentclass{article}
\usepackage{amsmath}

\renewcommand{\eqref}[1]{(see Eq. \textup{\ref{#1}})}

\begin{document}
\begin{equation}
 a^2+b^2=c^2\label{eq:1}
\end{equation}

If I refer to the equation, it does it all by itself, here: \eqref{eq:1}
\end{document}
  • what does \textup do ? About redefining \eqref it is not an issue with \NewDocumentCommand as it is possible to modify only the behaviour if optional argument is provided – ClementWalter Apr 26 '16 at 10:52
  • 1
    @clemlaflemme The original command \eqref is enclosed in \textup, which basically disallows the reference to not be "italic". Try writing \textit{\eqref{eq:1}}, the 1 will stay regular. Maybe you can enclose the whole reference in it, so if you have italic text, the reference will stay up. – Alenanno Apr 26 '16 at 10:54
  • 1
    @Alenanno No love for a non-breaking space after Eq.? ;) – Jon Apr 26 '16 at 12:16
  • @Jon you mean with ~? Sure, I'll fix it when I get back to my computer :P – Alenanno Apr 26 '16 at 12:31
1

I just use \ref{eq_my_equation} in all cases, as the parentheses around equation numbers aren't necessary in what I write. You could do the same, or just use \ref when required.

Note that (from an answer to this related question) amsmath's \eqref also sets the equation number in the relevant upright font. We could get into a discussion about whether or not that's the right thing to do, but for the purposes of this answer: I've never had to deal with this problem, having never had to refer to an equation from within italics.

0

Based upon @Alenanno and also including optional arguments for @Steven commands an answer with the more advanced \NewDocumentCommand from package xparse:

\LetLtxMacro{\oldeqref}{\eqref}
\RenewDocumentCommand\eqref{D<>{Eq.}om}{%
\IfNoValueTF{#2}
{#1~\oldeqref{#3}}
{(#2 #1~\textup{\ref{#3}})}%
}

will do the job, that is:\eqref is unchanged but \eqref[something]{label} returns (Something n) and it is also possible to change the base word Eq. (in my example) with \eqref<eqn>{label} and \eqref<eqn>[Something]{label}:

Example

\eqref{eq:label}; \eqref[Before]{eq:label}; \eqref<eqn>{eq:label}; \eqref<eqn>[Before]{eq:label}

Output

output new eqref

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.