I would like to know more about the temporary commands of LaTeX, such as \@tempa, \@tempswatrue
especially for the following construct, where I wonder if my replacement is correct:
% Provide bool for loaded package
\newcommand\isPackageLoaded[1]{%
\providebool{\tpl@idstring@#1}
\IfElsePackageLoaded{#1}{%
\setboolean{\tpl@idstring@#1}{true}%
}{%
\setboolean{\tpl@idstring@#1}{false}
}%
\boolean{\tpl@idstring@#1}%
}
replaced by this code
\newcommand\isPackageLoaded[1]{%
\IfElsePackageLoaded{#1}{%
\@tempswatrue
}{%
\@tempswafalse
}%
\boolean{\@tempswa}%
}
EDIT: I should add, that the first code is also wrong:
! Undefined control sequence.
\isPackageLoaded #1->\providebool {\tpl@idstring@
#1} \IfElsePackageLoaded {...
EDIT2: working on the boolean sequence, there are some iften vs etoolbox problems.
Using only ifthen commands it does not work:
\newcommand\isPackageLoaded[1]{%
\provideboolean{tpl@package@#1}%
\IfElsePackageLoaded{#1}%
{\setboolean{tpl@package@#1}{true}}
{\setboolean{tpl@package@#1}{false}}%
\boolean{tpl@package@#1}%
}
\begin{document}
\ifthenelse{\isPackageLoaded{lmodern}}{lmodern loaded}{lmodern NOT loaded}
\end{document}
with error:
! Incomplete \iffalse; all text was ignored after line 35.
<inserted text>
\fi
And if I use only etoolbox cs:
\newcommand\isPackageLoaded[1]{%
\providebool{tpl@package@#1}%
\IfElsePackageLoaded{#1}%
{\setbool{tpl@package@#1}{true}}
{\setbool{tpl@package@#1}{false}}%
\boolean{tpl@package@#1}%
}
I get the error:
! Missing = inserted for \ifnum.
<to be read again>
\escapechar
l.35 \ifthenelse{\isPackageLoaded{lmodern}}
{lmodern loaded}{lmodern NOT loaded}
I was expecting to see `<', `=', or `>'. Didn't.
It seems that both do not work together. But using only one of them does not work for me.