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
  • 2
    Would you be able to provide an example of the equations causing these problems? You usage of \label could be incorrect.
    – Werner
    Commented Jan 13, 2012 at 20:09
  • Lockstep provided me a solution, thanks anyway.
    – Nadori
    Commented Jan 13, 2012 at 20:34

2 Answers 2

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'

You must log in to answer this question.

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