In the following fragment, my use of \ifthenelse in a \newcommand adds a space:
\documentclass[letterpaper]{article}
\usepackage{ifthen}
\usepackage{graphicx}
\newboolean{color-version}
\setboolean{color-version}{false}
\newcommand{\figsubdir}[0]{%
\ifthenelse{\boolean{color-version}}{color}{bw}%
}
\begin{document}
../figures/GAelectrodynamics/\figsubdir/twoParameterDifferentialFig1
\end{document}
In Reducing space after a result of a command I see to add % signs after all the newlines, and I've done so, but it still seems to be there. This shows up more visibly, if the path above is changed to an \includegraphics statement, such as:
\includegraphics[totalheight=0.4\textheight]{../figures/GAelectrodynamics/\figsubdir/twoParameterDifferentialFig1}
With this \includegraphics, the extra rogue space causes a " Missing endcsname inserted." error, and compilation bombs. If I eliminate the ifthenelse use, using an hardcoded macro like:
\newcommand{\figsubdir}[0]{%
bw%
}
Then there is no extra space (and the \includegraphics also works.) But that defeats the purpose of ifthenelse.
Latex version:
- texlive 2019 (Ubuntu 20.04.1, in a Windows WSL2 VM)
- ifthen 2014/09/29 v1.1c Standard LaTeX ifthen package (DPC)
\includegraphics{../figures/GAelectrodynamics/\def\zzz{bw}\zzz/twoParameterDifferentialFig1}
this does not exapnd to the required path, it contains internal definitions that need to be executed.\ifthenelse
makes many such internal definitions while making its tests.