TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top


Using LyX and KOMA Script to author a technical manual.


The documents are strewn with the following references:


When converted to PDF, this results in "1.1" for the figure number, whereas I would prefer it to read "Figure 1.1". Similarly, for Tables and Listings, they should read "Table 1.1" and "Listing 1.1", respectively.


The caption code is:

\caption{\label{fig:Example-Query-Statement}Example Query Statement}

The reference code is:


The document preamble includes:


The result is: "The screen shot in 1.1 shows ..."

The desired result is: "The screen shot in Figure 1.1 shows ..."



\renewcommand{\ref}[1]{Figure {\oldref{#1}}}






How do you change the \ref command to include a \figurename prefix without having to edit (and thus duplicate) the code for every figure (that already has the \ref)?

Thank you!

share|improve this question
see also: tex.stackexchange.com/questions/5797/… – Caramdir Nov 27 '10 at 18:34
up vote 7 down vote accepted

Hyperref has autoref which takes care of this stuff. It is described briefly here.

This solution doesn't do exactly what you want. That is, it doesn't redefine \ref. But I'm not sure that's a great idea anyway. (weirdly \let\ref\autoref doesn't seem to do anything). So to have what you want, you need to do two things:

Add \usepackage{hyperref} to your preamble and then put \let\ref\autoref just after your \begin{document}

If you don't like the ugly coloured borders hyperref puts on your references see this. Alternatively, you can also add the nohyperref package after the hyperref package.

Hyperref causes lots of nasty package conflicts, so put it near the end of your preamble.

share|improve this answer
@Dave I've added some more information... – Seamus Nov 27 '10 at 19:25
@Dave Jarvis I've changed my answer. It works now. – Seamus Nov 27 '10 at 21:40
@Dave unless you also want hyperlinks, in which case it's better than using cref, since that conflicts with hyperref... – Seamus Nov 28 '10 at 13:42
@Dave if you're using hyperref anyway, why use cref, rather than autoref!? It's one less package to load... – Seamus Nov 28 '10 at 18:31
@Dave once you put the \let\ref\autoref after the \begin{document} it should work fine... And that's the same story with cleveref... – Seamus Nov 28 '10 at 19:50

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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