Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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.

share|improve this question
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

2 Answers 2

up vote 3 down vote accepted

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

share|improve this answer

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'

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.