While writing software documentation, the need arose for a command that automatically hyphenates camelCase words at uppercase letters, e.g. camel-Case. Furthermore, these camelCase words are typeset to a certain color. @David Carlisle provided the solution here via a command \zzz{camelCase}.
However, some of the camelCase variables are documented for internal use only. To this end there is a flag defined as
\newboolean{\internal}
\setboolean{internal}{true}
in a config file. In another post @Steven B. Segletes introduced a new command \zzzconditional to make variables disappear if \internal is false.
Now for the grand finale =) A large number of paragraphs in my document contain \zzzconditional commands but are also for internal use only, e.g.
\ifthenelse{\boolean{internal}}{%
Here is a paragraph for internal use which will only appear when the \textbackslash internal flag is set to TRUE. But I also refer to a camelCase variable \zzzconditional{InpShaftActTrqSpdRndVar} using the aforementioned command.%
}{}%
Unfortunately,~custom hyphenation defined in \zzzconditional does not work in this context. More precisely,~hyphenation breaks entirely which results in overfull lines (see MWE).
Is there any implementation that allows the use of \zzzconditional inside an \ifthenelse command?
The following MWE consists of a main file that loads another file codeInput.tex through the \input command. Here is the code for the MWE's main file:
\documentclass{scrartcl}
\usepackage{xcolor}
\usepackage{ifthen}
\def\zzcolor{\color{red}}
% --------------------------------------------
% Definition of \zzz for text formatting and hyphenation
% --------------------------------------------
\makeatletter
\def\zzz{\leavevmode\begingroup
\def\zzelt##1{%
\catcode`##1\active\uccode`\~`##1\uppercase{%
\def~{\egroup\egroup\-\hbox\bgroup\bgroup\zzcolor\string##1}}}%
\zz@Alph{}%
\@zzz}
\def\zz@Alph#1{%
\zzelt A\zzelt B\zzelt C\zzelt D\zzelt E\zzelt F\zzelt G\zzelt H\zzelt I\zzelt J\zzelt
K\zzelt L\zzelt M\zzelt N\zzelt O\zzelt P\zzelt Q\zzelt R\zzelt S\zzelt T\zzelt U\zzelt V\zzelt W\zzelt X\zzelt
Y\zzelt Z}
\def\@zzz#1{\textbf{\texttt{\hbox\bgroup\bgroup\zzcolor#1\egroup\egroup}}\endgroup}
\makeatother
% --------------------------------------------
% Flag to set internal version of document
% --------------------------------------------
\newboolean{internal}
\setboolean{internal}{true}
% --------------------------------------------
% Definition of \zzzconditional which should work like \zzz, but only print to document if interal flag is TRUE
% --------------------------------------------
% helper command
\newcommand\removetheargument[1]{\leavevmode\unskip}
% command
\newcommand{\zzzconditional}{%
\ifthenelse{\boolean{internal}}{%
\zzz%
}{
\removetheargument%
}%
}
\begin{document}
\section{Test}
Here is an example of how \textbackslash zzz\{\} hyphenates camelCase words. A variable \zzz{InpShaftActTrqSpdRndVar} is hyphenated at capital letters thanks to the amazing support here on StackExchange.
Now here is an example of \textbackslash zzzconditional\{\}'s hyphenation. A variable \zzzconditional{InpShaftActTrqSpdRndVar} is hyphenated at capital letters. %
% +++++ internal flag set to false +++++
\setboolean{internal}{false}%
% ++++++++++++++++++++++++++++++++++++++
Having set the \textbackslash internal flag to false, the variable \zzzconditional{InpShaftActTrqSpdRndVar} will disappear. Look at the tex code of this example to see that \textbackslash zzzconditional\{InpShaftActTrqSpdRndVar\} was used in the previous sentence.
% +++++ internal flag set to true +++++
\setboolean{internal}{true}%
% +++++++++++++++++++++++++++++++++++++
\ifthenelse{\boolean{internal}}{%
Here is a paragraph which appears only when the \textbackslash internal flag is true. However, inside this \textbackslash ifthenelse\{\}\{\}\{\} construct the hypenation in \textbackslash zzzconditional\{\} is broken. Instead it will result in an overfull line. This is shown in the following example \zzzconditional{InpShaftActTrqSpdRndVar}.%
}{}%
\ifthenelse{\boolean{internal}}{%
The issue issue also persists if I use the command \textbackslash zzz\{\}, for example \zzz{InpShaftActTrqSpdRndVar}. So the core issue does not seem to be with \textbackslash zzzconditional\{\}.%
}{}%
\ifthenelse{\boolean{internal}}{%
\input{codeInput}%
}{}%
\end{document}
And here is the code for the external file codeInput.tex:
However,~if I use \textbackslash ifthenelse in the main document to \textbackslash input the text from an external file codeInput.tex,~\textbackslash zzzconditional will work. Look at this variable \zzzconditional{InpShaftActTrqSpdRndVar} for example. Unfortunately this workaround is not feasible in the scope of my document\footnote{Large software documentation with so many internal paragraphs that is not practical to create an individual file for loading each one.}.


\ifthenelse, those are at least predictable in their limitations. – Skillmon May 16 '18 at 11:18