I am currently in the process of writing a comprehensive theoretical manual for my students. To make it easier to compile texts of varying difficulties for different groups of students, I also make heavy use of modes: These enable me to, say, exclude chapters that are intended for second-year-students from PDFs for first-year-students.
To make reading easier, I'm also using a lot of cross references (\in
and \at
). Unfortunately, that results in a problem, when a section that I'm referencing is excluded during compilation: Obviously, instead of the reference, the final PDF now shows something like "see chapter ??".
I would like to prevent that. Ideally, I would like to set up a new command that shows the full text of the reference only when the reference exists and is being included. Is that possible?
To make clearer what I'm talking about, here's a MWE (the advanced section might be excluded by compiling with context --mode=firstyear ...
):
\defineblock[advanced]
\startmodeset
[firstyear] {\hideblocks[advanced]}
[secondyear] {\keepblocks[advanced]}
[default] {\keepblocks[advanced]}
\stopmodeset
\def\condin#1#2{%
% the text specified by #1 should be hidden,
% when the reference #2 does not exist.
}
\starttext
\chapter{Testing Conditional Cross References}
\beginadvanced
\section[sec:advanced]{Advanced Section}
\input{knuth}
\endadvanced
\section[sec:intermediate]{Intermediate Section}
\input{knuth}
\section[sec:beginner]{Beginner Section}
This section explains the topic in beginner's terms
and refers to another chapter for more advanced details:
Please see \in{section}[sec:advanced] for more details.
This whole sentence should be excluded from the PDF,
when the references sec:advanced does not exist.
\stoptext
Any help would be much appreciated.
firstyear
is enabled? Simply omit the reference:Please see for more details.
or omit the complete line?\doifreferencefoundelse
do what you want?. The other option is to redefine\dummyreference
to something other than??
.\condin{sentence}{reference}
. I didn't know that\doifreferencefoundelse
exists, I will need to experiment with that. Thank you!\doifreferencefoundelse
... what a pity that it's not documented too well. But it does exactly what I needed. Thank you very much! Would you like to post your comment as an answer so that I can accept it?