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.

This question already has an answer here:

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}

\begin{equation}
\Delta P = \frac{2\gamma}{r} 
\label{eqn:surfacetension}
\end{equation}

\end{document}
share|improve this question

marked as duplicate by Jubobs, Andrew Swann, mafp, barbara beeton, Qrrbrbirlbel May 2 '13 at 13:52

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

    
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
3  
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

2 Answers 2

up vote 3 down vote accepted

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.

enter image description here

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
\usepackage[colorlinks=true]{hyperref}
\usepackage[nameinlink,noabbrev]{cleveref}
\begin{document}
\begin{equation}
\Delta P = \frac{2\gamma}{r} 
\label{eqn:surfacetension}
\end{equation}

Here's a cross-reference using \verb+\autoref+: \autoref{eqn:surfacetension}.

And here's a cross-reference using \verb+\cref+: \cref{eqn:surfacetension}.
\end{document}

For a more in-depth discussion of the capabilities of various LaTeX cross-referencing methods and packages, I'd suggest you check out this answer. Shameless self-citation alert!!

share|improve this answer

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.

share|improve this answer

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