[texhax] referencing figures, prepend word "Fig"

W. J. Metzger wesley.metzger at cern.ch
Wed Apr 9 10:32:48 CEST 2008


define a new command in the preamble	

\newcommand{\Fig}[1]{Fig.\,\ref{#1}}%

then   \Fig{fig:dataflow1654}

Good luck,  Wes

On Tue, 2008-04-08 at 20:29 +0100, Andy Farnell wrote:
> Dear tex hackers,
> 
> When I started writing I was unsure of whether to use the word "figure",
> "diagram", "fig" or whatever, so I decided to defer that decision until
> later. Throughout the text all references are given as \ref{fig:foobar},
> or \ref{tab:atable} and so forth.
> 
> Now, I want to automatically prepend the word "Fig" or "Table" to each
> reference depending on the three characters that appear before the colon.
> 
> Such that
> 
> In \ref{fig:dataflow1654} you can see ...
> 
> Becomes
> 
> In Fig 1.2 you can see ...
> 
> 
> and likewise for table references of the form \ref{tab:table345} which
> would become
> 
> In Table 1.7 a summary is given ...
> 
> Is it possible to redefine \ref to do this?
> 
> Gratefully in anticipation of any help,
> 
> Andy
> 
-- 
W. J. Metzger <wesley.metzger at cern.ch>



More information about the texhax mailing list