I'm using luatex and the cleverref package while writing a large document. I often only want to compile only parts of it, but I'd like my output to be a little nicer when I only compile a single chapter.
Instead of an undefined reference being replaced with ??, I would like to insert my own custom text.
Currently my solution is to define new commands \ucref and \ucite and use them instead of \cite and \cref for any cross-chapter reference. When I compile only a specific chapter I define these commands to be:
\newif\ifpublishversion{}
\publishversionfalse{}
%\publishversiontrue{}
\ifpublishversion{}
\newcommand{\ucref}[1]{\color{red} ref{(#1)} \color{black}}
\newcommand{\UCref}[1]{\color{red} ref{(#1)} \color{black}}
\newcommand{\ucite}[1]{[\color{green}#1\color{black}]}
\else
\newcommand{\ucref}[1]{\cref{#1}}
\newcommand{\UCref}[1]{\Cref{#1}}
\newcommand{\ucite}[1]{\cite{#1}}
\fi
And then when I compile the whole document I change them to point to \cref and \cite to get default behavior.
It would be nice if I could just use \cref and \cite everywhere, but when a reference is undefined have latex spit out a warning and then insert this custom "nice" text instead of a ?? double question mark.
Is there a way to write something like ...
% PSEUDOCODE
% Do ways to do something like this exist?
\setundefinedreftext[1]{\ucref{#1}}
\setundefinedcitetext[1]{\ucite{#1}}
\include
to input your chapters. allowing you to typeset just one chapter while making \ref etc still make the correct output is the whole point of the include mechanism.\include
is completely different and all the differences are specifically to address this issue! If you use\include
then after you have done a full run to resolve all references you can use\includeonly[chapter3}
and just typeset chapter3 but all numbering and cross references will work to anywhere in the full document