1

I have a figure to be referenced as below. Why, using \ref{fig:customers} to show the label, is the word "Figure" missing? Only the figure number is shown: "3.2". How can I change it to "Figure 3.2"?

Potential customers are listed in the `\ref{fig:customers}` below.

\begin{figure}[htbp!]
\centering
\includegraphics[scale=0.8]{needs_customers.png}
%[clip=true]
\caption{Potential Customers, Requirement and Constraints}
\label{fig:customers}
\end{figure}
  • 2
    Welcome to TeX.SE. A longer discussion of which LaTeX packages provide support for cross-referencing, see Cross-reference packages: which to use, which conflict. You may be particularly interested in \autoref (from the hyperref package) and \cref (from the cleveref package). – Mico Mar 11 '17 at 21:24
  • 2
    By default the counter type is not shown in the referencing, i.e. Figure etc. As Mico mentioned, cleveref and hyperref provide special commands for this. – user31729 Mar 11 '17 at 21:30
5

There are packages that do that. One of them is hyperref:

\documentclass{scrartcl}

\usepackage{graphicx}
\usepackage{hyperref}

\begin{document}
\begin{figure}
\centering
\includegraphics[width=0.2\textwidth]{example-image}
\caption{An example}
\label{fig:example}
\end{figure}

Please see \autoref{fig:example}.
\end{document}

results

Another option is the cleveref-package:

\documentclass{scrartcl}

\usepackage{graphicx}
\usepackage{cleveref}

\begin{document}
\begin{figure}
\centering
\includegraphics[width=0.2\textwidth]{example-image}
\caption{An example}
\label{fig:example}
\end{figure}

Please see \cref{fig:example}
\end{document}
2

The default behaviour of the references to some certain counter do not provide the name of the counter (say figure or table etc.).

hyperref and cleveref amongst other packages provide this missing feature however, there might be other packages as well.

Here I present a solution which is working and quite quick if there should be no other package included (sometimes this is demanded by publishers and their weird settings!)

Without special package: Change the \p@figure references formatter macro to use \figurename.

The hyperref package is used here to show that the redefinition of \p@figure still works with hyperref.

\documentclass{article}

\usepackage{graphicx}

\usepackage{hyperref}

\makeatletter
\renewcommand{\p@figure}{\figurename\ }
\makeatother

\begin{document}

You must see the incredible \ref{fig:foo}.

\clearpage
\begin{figure}
\centering
\caption{Foo caption}
\label{fig:foo}
\end{figure}

\end{document}

enter image description here

  • Very interesting. I never thought of something like that. But this makes it hard to use something where the figure name has to be changed declined. – Skillmon Mar 11 '17 at 21:35
  • @Skillmon: It's quite handy (and sometimes there must be 'dirty' tricks with this \p@.... macros to allow some special form of referencing.) Of course, for more than just one counter type this might get tedious – user31729 Mar 11 '17 at 21:37
  • The varioref package also provides a similar service. – Peter Flynn Feb 15 at 20:47
  • @PeterFlynn: I know, but I don't use that package – user31729 Feb 15 at 20:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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