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.

While working on a document, it would be helpful if instead of a ? for unresolved references or citations the tag used in the \ref{thisthings} or \cite{Bloke1978} could appear instead.

Is there a package that turns on this behaviour?

share|improve this question
add comment

2 Answers

up vote 12 down vote accepted

Rather than redefining \cite or connected commands, one might consider using the showkeys package, that will print every key and mark every usage of \label so that, during document preparation, cross-references can be checked quite easily.

This has a drawback: line and page break can be different when using or not using the package. However, line and page break are not much of a concern when we are writing our manuscript. When finalizing the project just comment out the call to showkeys: the cross-references should be OK, at that point.

share|improve this answer
    
That is a more useful solution than just replacing the unresolved labels. Thanks! –  Alex Feb 18 '12 at 22:46
add comment

Even if there is no such package, it's easy to modify the corresponding commands with the help of the etoolbox package. This may, however, fail if some package redefines the commands in an incompatible way.

\documentclass{article}

\usepackage{etoolbox}

\makeatletter
\patchcmd{\@setref}{\bfseries ??}{[\texttt{#3}]}{}{%
  \GenericWarning{}{Failed to patch \protect\@setref}}
\patchcmd{\@citex}{\bfseries ?}{\texttt{\@citeb}}{}{%
  \GenericWarning{}{Failed to patch \protect\@citex}}
\makeatother

\begin{document}

\ref{undefined},\pageref{undefined},\cite{undefined}

\end{document}
share|improve this answer
4  
One might also consider the showkeys package. –  egreg Feb 18 '12 at 11:16
    
@egreg: That's cool! Your comment should be an answer. –  Andrey Vihrov Feb 18 '12 at 11:18
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.