7

I am writing my thesis. Therefore, I need to use \ref{}. Sometimes I would like to use ( ) such that:

(\ref{}). As you know, for citation, we can use \citep to get this (authour 1980). I would like to know if there is a shortcut for \ref as well. That is, is there a convenient way to get (\ref{}) automatically.

  • 2
    \eqref from amsmath? – David Carlisle Mar 24 '18 at 8:16
  • @DavidCarlisle thank you a lot. Could you please pass it as an answer? – Alice Mar 24 '18 at 8:19
  • You could make your own?\def\refp#1{\ref{#1}} – Andreas Storvik Strauman Mar 24 '18 at 8:19
  • @AndreasStorvikStrauman what does #1 mean? – Alice Mar 24 '18 at 8:20
  • 1
    I forgot you're parentheses, so \def\refp#1{(\ref{#1})} is what you're looking for, then you can do \refp{ref:somewhere} – Andreas Storvik Strauman Mar 24 '18 at 8:27
9

This form with ( ) is usually used for equation numbers and amsmath provides \eqref which does exactly what you ask. Or more exactly it uses the same format as the package uses for equation numbers, so ( ) by default but if you change that then both the equation and the reference will use the same formatting.

4

As the accepted answer by @DavidCarlisle says, \eqref from amsmath is the way to go, since it takes care of the format such that it matches amsmaths equation numbering. However, you could make your own:

% Make a new command that makes your \refp
\newcommand{\refp}[1]{(\ref{#1})}

The square brackets [1] is how many arguments the command takes, and the #1 is the argument itself. So now when you do \refp{some:ref} it replaces it with (\ref{some:ref}) All you have to do to use it is then

\refp{some:ref}

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.