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.

I'm writing my PhD thesis in LaTeX and I have a lot of figures - each one is referenced within the text. So I have:

\begin{figure}[h]
...
...
\label{fig:stuff}
\end{figure}

then, later, in the text:

blah blah blah this is shown in \ref{fig:stuff}, which indicates blah blah

and I get:

blah blah blah this is shown in Figure 2.7, which indicates blah blah

I want to make "Figure 2.7" bold - I'm loading the caption package with the labelfont=bf option so that it's bold in the caption of the figure itself, but I'd also like it to be bold in the text. I guess I could do this with

blah blah blah this is shown in \textbf{\ref{fig:stuff}}, which indicates blah blah

but ideally I'd like not to have to change multiple references to all 71 figures...

Any ideas?

share|improve this question
8  
Just from a typographic point of view: I don't think this is a good idea, as it will optically emphasize your references very much and make it stand out of the grey value of the text. –  Benedikt Bauer Dec 21 '12 at 21:52

3 Answers 3

I assume that you want to bold-face your cross-references to make them stand out strongly in the text. However, this is a dubious practice from a typographic point of view. Rather than bold-facing the cross-references, I'd suggest that you make them into hyperlinks that can be assigned a color. To do this, start by loading the hyperref package with the colorlinks option set. Then, use the \autoref command that's provided by the hyperref package to create colored hyperlinks to the objects being cross-referenced. Note that the \autoref command is what one might term fully dynamic: it typesets both the type (such as equation, figure, table, section, etc.) and the number of the cross-referenced object. By using the \autoref command, the hyperlink "target" (the part that's colored) will be highly visible, because it consists of both the type and number of the item being cross-referenced.

An even more flexible and powerful cross-referencing command than \autoref is \cref, provided by the cleveref package; I suggest that you load the cleveref package the nameinlink option set. (Even if you do use \cref, I still recommend you also load the hyperref package with the colorlinks option set. If you load both hyperref and cleveref, be sure to load hyperref first.) Like \autoref, \cref is fully dynamic; the nameinlink option forces the link to consist of both the item's type and number. Unlike \autoref, \cref lets you create cross-references to multiple items of the same type (e.g., equations) and even multiple items of differing types all in one cross-referencing command; the cleveref package will nicely sort and typeset the cross-references being generated without the user having to worry about such details.

For much more on various cross-referencing commands and packages in general, and the hyperref and cleveref packages in particular, see the answers to the question Cross-reference packages: which to use, which conflict?

share|improve this answer

Just redefine \ref:

\let\origref\ref
\def\ref#1{\textbf{\origref{#1}}}
share|improve this answer
5  
If hyperref is loaded this is dangerous; it's better to say \LetLtxMacro{\latexref}{\ref} (it needs the letltxmacro package). –  egreg Dec 21 '12 at 22:22
    
Surely. My answer is a quick hack which breaks a lot of things... –  Boris Dec 21 '12 at 22:54
    
Instead of redefine \ref, why not define a new one: \newcommand{\bref}[1]{\textbf{\ref{#1}}? –  Manuel Dec 21 '12 at 23:09
    
This also works, but if you have a long doc with \refs, it might be easier to redefine \ref. –  Boris Dec 21 '12 at 23:24

In the preambule, you must add :

\usepackage[capitalise]{cleveref} % load after hyperref package
\crefdefaultlabelformat{\textbf{#2#1#3}} % boldface only the number

% boldface only the type in front of the number
\crefname{figure}{\textbf{Figure}}{\textbf{Figures}} 
\Crefname{figure}{\textbf{Figure}}{\textbf{Figures}}

% BONUS
\crefname{table}{\textbf{Table}}{\textbf{Tables}}
\Crefname{table}{\textbf{Table}}{\textbf{Tables}}
\crefname{appendix}{\textbf{Annexe}}{\textbf{Annexes}}
\Crefname{appendix}{\textbf{Annexe}}{\textbf{Annexes}}
\crefname{section}{\textbf{\S}}{\textbf{\S}}
\Crefname{section}{\textbf{\S}}{\textbf{\S}}
\crefname{algorithm}{\textbf{Algorithme}}{\textbf{Algorithmes}}
\Crefname{algorithm}{\textbf{Algorithme}}{\textbf{Algorithmes}}
share|improve this answer
    
Welcome to TeX.SX! –  Claudio Fiandrino Nov 18 '13 at 10:49

Your Answer

 
discard

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.