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 a scientific report and it's required that the first reference to any figure or table (not to equations or sections) in the text is set bold like this:

example

Is there a package for this kind of task?

The acronym package does something similar giving the full description of an acronym when it's used for the first time, so I guess it's not a too special problem.

share|improve this question
add comment

1 Answer

The following works:

enter image description here

\documentclass{article}
\makeatletter
\def\@setref#1#2#3{%
  \ifx#1\relax
    \protect\G@refundefinedtrue
    \nfss@text{\reset@font\bfseries ??}%
    \@latex@warning{Reference `#3' on page \thepage \space
      undefined}%
  \else
    \expandafter\ifx\csname used@#1\endcsname\relax
      \expandafter\global\expandafter\def\csname used@#1\endcsname{used}%
      {\bfseries\expandafter#2#1\null}% Formatting of first reference
    \else
      \expandafter#2#1\null%
    \fi
  \fi%
}
\makeatother
\begin{document}
\begin{figure}
  \centering\rule{150pt}{20pt}
  \caption{A figure}\label{fig:figure}
\end{figure}
See Figure~\ref{fig:figure}. The same reference to Figure~\ref{fig:figure}.
\end{document}

It modifies the macro \@setref which is called from \ref to decide whether a reference exists or not. The formatting is based on a condition to check whether a newly defined macro used@<label> exists or not.

Formatting of the first reference is set using \bfseries and can be modified to suit.

share|improve this answer
    
Thanks for your prompt and detailed answer. Could you modify the example so that the ref{} command prints Fig. x instead of only the number and is still bold for the first time? Sorry for not having been specific enough in my question. –  Deve Mar 15 '12 at 10:20
1  
@Deve: this would require some package (like, AFAIR, cleveref), since in "vanilla" LaTeX you always have to supply the "Ref.~" part yourself. Don't have time to implement it now, if nobody answers (which is unlikely), I'll try to do it tomorrow. –  mbork Mar 15 '12 at 12:23
add comment

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.