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.

Possible Duplicate:
Table, Figure, and Listing prefixes
Automatically inserting “Section, Subsection, etc”

I'm using the package hyperref. When referencing my figure, I currently use code like

Figure \ref{fig:chorus-overview} gives an overview of the basic concept.

because \ref will just yield a single integer 1, as opposed to Figure 1.

However, the word Figure is auto-generated for the figure environment caption, so when using a package such as [ngerman]{babel}, it's Abbildung instead, and I need to fix the text before my reference.

Is there any way to directly get the Figure 1 text via \ref or a similar command?

EDIT

Additionally to the steps described in Sveinung's answer (using \autoref from hyperref or \cref from cleveref), I needed to make sure to place the label before the caption in the figure environment, as pointed out by Werner, and to include babel before hyperref/cleveref.

\nameref does not do what I need, since it copies the text of the caption instead.

share|improve this question

marked as duplicate by Werner, Thorsten, lockstep, barbara beeton, Torbjørn T. Jul 8 '12 at 14:49

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.

    
Since the question most likely has something to do with the placement of labels, and/or babel options, it is probably not an exact duplicate. –  Sveinung Jul 8 '12 at 14:32
    
+1 for mentioning that the label needs to go before the caption. –  Will May 2 at 17:07

1 Answer 1

up vote 5 down vote accepted

Load the package cleveref in your preamble and change your \ref{label} to \cref{label}. As egreg emphasizes, the package cleveref must be loaded after hyperref.

Or you may change your \ref{label} to \autoref{label}. See the hyperref manual page 15.

If I misunderstood you, and the problem is that you want the English word Figure instead of the German word Abbildung, you have two possibilities:

  1. Either load babel with the option UKenglish instead of ngerman if your text is in English.
  2. If your text is in German, but you still want to use the English word figure, you can use the babel-environment \begin{otherlanguage} before your figure, see the babel-manual page 6 (use texdoc babel at a command prompt).
share|improve this answer
3  
The package cleveref must be loaded after hyperref. Just a reminder, but it's important because usually it's the other way around and people don't read manuals. :) –  egreg Jul 8 '12 at 14:11
1  
@mic_e: This may be because you have your \label and \caption command inverted. See Where to put the \label on a figure environment? –  Werner Jul 8 '12 at 14:20
    
Then it is most likely a misplaced \label, see @Werner's comment. I suggest you try to make an minimal working example (MWE) –  Sveinung Jul 8 '12 at 14:33
2  
I've solved the problem now. I made two mistakes: First, I included hyperref before including babel, and second, I placed \label before \caption. Thanks for your help. –  mic_e Jul 8 '12 at 14:37
1  
@mic_e Note that, with some exceptions such as cleveref, hyperref should be loaded as the last package. See Which packages should be loaded after hyperref instead of before? –  Torbjørn T. Jul 8 '12 at 14:52

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