4

I hope there is a solution for this. When I refer to some equation I always get something like 37, but I would like to have (37). I could make a new command but the problem is I use many kind of environments in my text: equation (needs \eqref), multline (needs \ref), theorems (need \ref). I don't want parantheses when referring to theorem numbers. Any advice is appreciated.

  • 2
    Would you be able to provide an example of the equations causing these problems? You usage of \label could be incorrect. – Werner Jan 13 '12 at 20:09
  • Lockstep provided me a solution, thanks anyway. – Nadori Jan 13 '12 at 20:34
3

One could use the "extension of counter referencing" described in section 53.2 of source2e and then redefine \p@equation.

\documentclass{article}

\makeatletter
\renewcommand*\refstepcounter[1]{%
  \stepcounter{#1}%
  \protected@edef\@currentlabel
  {\csname p@#1\expandafter\endcsname\csname the#1\endcsname}%
}
\renewcommand{\p@equation}[1]{(#1)}
\makeatother

\begin{document}

\section{foo}\label{foo}

\begin{equation}\label{test}
a^2 + b^2 = c^2
\end{equation}

See equation~\ref{test} in section~\ref{foo}.

\end{document}

enter image description here

3

if you're using amsmath, just use \eqref{ <label> } which includes the parentheses and keeps the whole thing upright even in an italic (e.g. theorem) environment. it really doesn't matter what you're using it for; it should work with any label.

reading the question more carefully, you say you don't want parentheses when referring to thworems. then just use \ref -- but if you'd like them upright like \eqref, then use \textup{\ref{...}} when not in a "guaranteed" upright environment'

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.