# Custom cross-reference formats (e.g. “Equation 1” instead of just “1”) [duplicate]

I have an equation system set up as below. When I reference it however, ie. with \ref{eqn:surfacetension}, it only prints the number '1', and not 'Equation 1'. How can I modify the code to do that? I apologise if I left out any key bits of code, I only put in the bits that I think are relevant

\documentclass[a4paper,12pt]{scrartcl}

\usepackage{amsmath}

\makeatletter
\let\mytagform@=\tagform@
\def\tagform@#1{\maketag@@@{\bfseries(\ignorespaces#1\unskip\@@italiccorr)}\hspace{3mm}}
\renewcommand{\eqref}[1]{\textup{\mytagform@{\ref{#1}}}}
\makeatother

\begin{document}

$$\Delta P = \frac{2\gamma}{r} \label{eqn:surfacetension}$$

\end{document}


## marked as duplicate by jubobs, Andrew Swann, mafp, barbara beeton, QrrbrbirlbelMay 2 '13 at 13:52

• You can use the prettyref package to customize the format of your cross-references. Add \usepackage{prettyref} \newrefformat{eqn}{Equation~\ref{#1}} to your preamble and then use \prettyref{eqn:surfacetension} instead of \ref{eqn:surfacetension}. – jubobs May 2 '13 at 11:53
• There are several packages that allow for "advanced" cross-referencing, see tex.stackexchange.com/questions/36295/… for an overview. – Torbjørn T. May 2 '13 at 12:18

You could use the command \autoref (provided by the hyperref package) or the command \cref (provided by the cleveref package) to achieve your objective of having LaTeX provide both the "name" and the "number" of the item being cross-referenced.

The scope of these commands isn't limited to cross-referencing equations; the commands \autoref and \cref can be applied to many other items as well. Do peruse the user guides of these packages to learn how to customize, if necessary, the appearance of the cross-references generated by these packages.

\documentclass[a4paper,12pt]{scrartcl}
\setlength{\textwidth}{4in} % just for this MWE
$$\Delta P = \frac{2\gamma}{r} \label{eqn:surfacetension}$$

At How do I configure a \ref of a \label to print more than just the number?, I provide a package called eqcite. It sounds similar to what Jubobs mentions above in his comment, except that it allows for the different cases when you want to say "equation 1" (\eqcite{eq:ref}) vs. "Equation 1" (\Eqcite{eq:ref}) vs. "equations 1 and 2" (\eqcites{eq:ref1} and \andeqcite{eq:ref2}). Maybe prettyref does that too. I'm not familiar with it.