7

Could one make the ? which appears for an unfound bibtex key into some other arbitrary string or symbol? I have a large document and it is slow searching through the ? to look for missing bibliographic references. (MWE below, but assume I'm using a referencing style which does not output [?] for missing references, but simply ?. I decided to keep the MWE simple however).

Alternatively if this is not possible, or if this is not wise, I'd be interested to learn why.

\documentclass{article}

\begin{document}

\section{Immanuel Kant}

\cite{Kint} said it all far better than I could.

\begin{thebibliography}{1}
\bibitem{Kant} Kant, I.\ \textit{My Booky Wook} 2004.
\end{thebibliography}
\end{document}
2
  • 2
    That document gives a warning "LaTeX Warning: Citation `Kint' on page 1 undefined on input line 7.". Instead of looking in the compiled document you can use these warnings.
    – pst
    Jul 15, 2015 at 21:16
  • Especially if the environment you use can parse those warnings. For example with AucTeX for Emacs you have to turn on option "Debug Warnings", and then TeXing your document the TeX-next-error command will put you at \cite{Kint} showing the warning in another buffer.
    – pst
    Jul 16, 2015 at 16:18

1 Answer 1

6

You could basically use any symbol for this, I decided for a bunch of + characters, which do not occur very often and stored this to a command, which is then used in a redefined \@citex command, which is called by \cite.

The \@citex command is taken from latex.ltx, i.e. the LaTeX kernel. Of course, any package using a different \cite definition will break this 'hack'.

\documentclass{article}

\newcommand{\myunknownrefsymbol}{++++++}
\makeatletter

\def\@citex[#1]#2{\leavevmode
  \let\@citea\@empty
  \@cite{\@for\@citeb:=#2\do
    {\@citea\def\@citea{,\penalty\@m\ }%
     \edef\@citeb{\expandafter\@firstofone\@citeb\@empty}%
     \if@filesw\immediate\write\@auxout{\string\citation{\@citeb}}\fi
     \@ifundefined{b@\@citeb}{\hbox{\reset@font\bfseries \myunknownrefsymbol}%
       \G@refundefinedtrue
       \@latex@warning
         {Citation `\@citeb' on page \thepage \space undefined}}%
       {\@cite@ofmt{\csname b@\@citeb\endcsname}}}}{#1}}
\makeatother
\begin{document}

\section{Immanuel Kant}

\cite{Kint} said it all far better than I could.

\cite{Kant}

\cite{Kont}

\cite{Einstein}

\begin{thebibliography}{1}
\bibitem{Kant} Kant, I.\ \textit{My Booky Wook} 2004.
\end{thebibliography}
\end{document}
2
  • 1
    A less scary code for the novice: \usepackage{xpatch} \newcommand{\myunknownrefsymbol}{++++++} \makeatletter \xpatchcmd{\@citex} {\bfseries} {\bfseries\myunknownrefsymbol} {} {} \makeatother Jul 15, 2015 at 21:45
  • @GonzaloMedina: I've tried \xpatchcmd as I always did, but I used the \if@... which is useless in this case
    – user31729
    Jul 15, 2015 at 21:49

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .