Place parentheses around a cross-reference
Try using \eqref{fig:label}
from the amsmath
package.
(Taken from here: https://groups.google.com/forum/#!topic/latexusersgroup/e1CHoBfj8pQ)
You could renew the reference command, perhaps something like:
\let\oldref\ref
\renewcommand{\ref}[1]{(\oldref{#1})}
Here's a complete MWE to play with:
% arara: pdflatex
% arara: pdflatex
\documentclass{article}
\let\oldref\ref
\renewcommand{\ref}[1]{(\oldref{#1})}
\begin{document}
\section{Section heading}\label{sec:testlabel}
Reference: \ref{sec:testlabel}
\end{document}
Note: as mentioned by @Mico, this solution isn't compatible with hyperref
package.
I prefer the autoref
function provided in the hyperref package.
Taking examples for tables and figures:
The Table reference is \autoref{tab:VHTRC}.
The equation reference is \autoref{eq:3}.
Next, new reference styles should be renewed at the preamble. Usually I define them just after including the hyperref package.
\usepackage{hyperref}
\def\equationautorefname~#1\null{Equation (#1)\null}
The \def
define the auto-reference variable #1
in the style Equation (#1)
, which is enclosed in ()
.
Then you will get the result like this:
If you want to use curly braces {}
, they should be escaped with the \
.
\usepackage{hyperref}
\def\equationautorefname~#1\null{Equation \{#1\}\null}