Figure references with the word Figure and not just a number [duplicate]

I reference figures this way: \label{fig:hello} and then just \ref{fig:hello} but the latter returns only the number without the word "Figure". How can I get the word Figure such as "Figure 1"?

marked as duplicate by egreg, Ludovic C., Andrew Swann, user11232, Benedikt BauerNov 13 '13 at 13:59

Use the hyperref and autoref like \label{fig:hello} and then just \autoref{fig:hello} which adds also a nice clicking link to get fast to the position.

\usepackage{hyperref}


Example

Here's a simple unpublished package (fgcite.sty) that can do what you want, with customization. First, the MWE:

\documentclass{article}
\usepackage{fgcite}
\begin{document}
In \fgcite{fg:first}, I see a square.
\begin{figure}[ht]
\centering\fbox{\rule{1in}{0in}\rule{0in}{1in}}
\caption{My caption\label{fg:first}}
\end{figure}

Now, I will change the figure citation style\FgTypeE.  Now, when referencing
\fgcite{fg:first}, I get something different.  \Fgcite{fg:first} at the
beginning of a sentence will make sure it is capitalized, and I can cite
\fgcites{fg:first} and \andfgcite{fg:first}, that is, multiple figures.

\end{document}


And here is the style file. Documentation included at top of file.

\ProvidesPackage {fgcite} [2009/03/23]
%
% by Steven B. Segletes, for the public domain.
%
% 'fgcite prints out the preferred reference format for figure
% citations, e.g., figure 1 as opposed to Fig. (1), fig.(1), etc.
%
% 1) Ability to quickly change from figure x' to Fig(x)' through
%    whole document, with a single line change (\FgTypeC).  This is
%    useful when converting from tech report to manuscript formats;
% 2) Saves typing:
%    With the 'fgcite package, type        \fgcite{fig:myfig}'
%    vs. the traditional LaTeX approach of figure~\ref{fig:myfig}'  .
%
%
% A number of format types are predefined:
%
% FgTypeA : figure x  , figures x and y (ARL report standard)
% FgTypeB : Figure x  , Figures x and y
% FgTypeC : fig. (x)  , figs. (x) and (y)
% FgTypeD : Fig. (x)  , Figs. (x) and (y)
% FgTypeE : fig.(x)   , figs.(x) and (y)
% FgTypeF : Fig.(x)   , Figs.(x) and (y)
% FgTypeG : figure (x), figures (x) and (y)
% FgTypeH : Figure (x), Figures (x) and (y)
% FgTypeI : Fig. x    , Figs. x and y
%
% Other format types are easily added.
%
% Usage:
%
% % In Preamble:
% \usepackage{fgcite}
% \FgTypex  % where x' is A, B, etc.  defaults to FgTypeA
%
% % In Document:
% \Fgcite{ref} ...
% ... \figcite{ref} ...
% \Fgcites{ref1}, \andfgcite{ref2}, and \andfgcite{ref3} ...
% ... \fgcites{ref1}, \andfgcite{ref2}, and \andfgcite{ref3}...
%
% where ref is the LaTeX reference, for example, fig:myfig  .
%
% A literal option [l] is available to use the the argument as the
% actual figure number, rather than as an figure reference:
%
% \fgcite[l]{13}
%
% This literal option can be used with the following calls:
% \Fgcite, \fgcite, \Fgcites, \fgcites and \andfgcite.
%
%
% FgTypeA : figure x  , figures x and y
\newcommand\FgTypeA{%
\def\Fgname{Figure}%
\def\fgname{figure}%
\def\Fgsname{Figures}%
\def\fgsname{figures}%
\def\fgsep{~}%
\def\fgssep{~}%
\def\fgldelimit{}%
\def\fgrdelimit{}%
}
% FgTypeB : Figure x  , Figures x and y
\newcommand\FgTypeB{%
\def\Fgname{Figure}%
\def\fgname{Figure}%
\def\Fgsname{Figures}%
\def\fgsname{Figures}%
\def\fgsep{~}%
\def\fgssep{~}%
\def\fgldelimit{}%
\def\fgrdelimit{}%
}
% FgTypeC : fig. (x)  , figs. (x) and (y)
\newcommand\FgTypeC{%
\def\Fgname{Fig.}%
\def\fgname{fig.}%
\def\Fgsname{Figs.}%
\def\fgsname{figs.}%
\def\fgsep{~}%
\def\fgssep{~}%
\def\fgldelimit{(}%
\def\fgrdelimit{)}%
}
% FgTypeD : Fig. (x)  , Figs. (x) and (y)
\newcommand\FgTypeD{%
\def\Fgname{Fig.}%
\def\fgname{Fig.}%
\def\Fgsname{Figs.}%
\def\fgsname{Figs.}%
\def\fgsep{~}%
\def\fgssep{~}%
\def\fgldelimit{(}%
\def\fgrdelimit{)}%
}
% FgTypeE : fig.(x)  , figs.(x) and (y)
\newcommand\FgTypeE{%
\def\Fgname{Fig.}%
\def\fgname{fig.}%
\def\Fgsname{Figs.}%
\def\fgsname{figs.}%
\def\fgsep{}%
\def\fgssep{}%
\def\fgldelimit{(}%
\def\fgrdelimit{)}%
}
% FgTypeF : Fig.(x)  , Figs.(x) and (y)
\newcommand\FgTypeF{%
\def\Fgname{Fig.}%
\def\fgname{Fig.}%
\def\Fgsname{Figs.}%
\def\fgsname{Figs.}%
\def\fgsep{}%
\def\fgssep{}%
\def\fgldelimit{(}%
\def\fgrdelimit{)}%
}
% FgTypeG : figure (x)  , figures (x) and (y)
\newcommand\FgTypeG{%
\def\Fgname{Figure}%
\def\fgname{figure}%
\def\Fgsname{Figure}%
\def\fgsname{figure}%
\def\fgsep{~}%
\def\fgssep{~}%
\def\fgldelimit{(}%
\def\fgrdelimit{)}%
}
% FgTypeH : Figure (x)  , Figures (x) and (y)
\newcommand\FgTypeH{%
\def\Fgname{Figure}%
\def\fgname{Figure}%
\def\Fgsname{Figures}%
\def\fgsname{Figures}%
\def\fgsep{~}%
\def\fgssep{~}%
\def\fgldelimit{(}%
\def\fgrdelimit{)}%
}
% FgTypeI : Fig. x  , Figs. x and y
\newcommand\FgTypeI{%
\def\Fgname{Fig.}%
\def\fgname{Fig.}%
\def\Fgsname{Figs.}%
\def\fgsname{Figs.}%
\def\fgsep{~}%
\def\fgssep{~}%
\def\fgldelimit{}%
\def\fgrdelimit{}%
}

% Default to Figure Type A format
\FgTypeA
%
% For citing a figure at the beginning of a sentence
\newcommand\Fgcite[2][]{%
\if l#1%
\Fgname\fgsep\fgldelimit#2\fgrdelimit
\else%
\Fgname\fgsep\fgldelimit\ref{#2}\fgrdelimit
\fi
}
% For citing a figure in the middle of a sentence
\newcommand\fgcite[2][]{%
\if l#1%
\fgname\fgsep\fgldelimit#2\fgrdelimit
\else%
\fgname\fgsep\fgldelimit\ref{#2}\fgrdelimit
\fi
}
% For citing the first of multiple figures at the beginning of a sentence
\newcommand\Fgcites[2][]{%
\if l#1%
\Fgsname\fgssep\fgldelimit#2\fgrdelimit
\else%
\Fgsname\fgssep\fgldelimit\ref{#2}\fgrdelimit
\fi
}
% For citing the first of multiple figures in the middle of a sentence
\newcommand\fgcites[2][]{%
\if l#1%
\fgsname\fgssep\fgldelimit#2\fgrdelimit
\else%
\fgsname\fgssep\fgldelimit\ref{#2}\fgrdelimit
\fi
}
% For citing a figure number without the leading word figure, fig, etc.
% Used in conjuction with \Fgcites and \fgcites
\newcommand\andfgcite[2][]{%
\if l#1%
\fgldelimit#2\fgrdelimit
\else%
\fgldelimit\ref{#2}\fgrdelimit
\fi
}
%
\endinput
`
• Why unpublished? :-) – user11232 Nov 14 '13 at 0:02
• @HarishKumar I never got around to writing any documentation, and it seemed there were other packages that did similar things. But perhaps I should reconsider... – Steven B. Segletes Nov 14 '13 at 10:54
• Certainly you should :-) – user11232 Nov 14 '13 at 13:04