[Tex/LaTex] Adding parentheses to figure references

cross-referencingpunctuation

Using pretty much no packages, when using the \ref{label of figure} i get just the number of the figure.
Is there an easy way to set it to make parentheses around that number?
At the moment I have to do it manually, but would be nicer if it could be done automatically

Best Answer

You can use the \p@figure macro that's used in building the current label.

\documentclass{article}
\makeatletter
\renewcommand\p@figure{\expandafter\counter@parenthesize}
\newcommand\counter@parenthesize[1]{(#1)}
\makeatother

\begin{document}

\begin{figure}
\caption{X}\label{X}
\end{figure}

See Figure~\ref{X}.

\end{document}

enter image description here

You can do similarly for the other counters you need to be treated in a similar way.

Related Question