Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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

replaced by this code


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:

\ifthenelse{\isPackageLoaded{lmodern}}{lmodern loaded}{lmodern NOT loaded}

with error:

! Incomplete \iffalse; all text was ignored after line 35.
<inserted text>

And if I use only etoolbox cs:


I get the error:

! Missing = inserted for \ifnum.
<to be read again>
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.

share|improve this question
You have asked 37 questions but only voted on 3 answers. This might be considered rude. Upvoting an answer is a way to show that an answer is useful (and is something distinct from accepting an answer, see the faq for details). I'd suggest that you go through all your questions and upvote any useful answer to them. –  N.N. Nov 20 '11 at 20:58
I upvoted the answers. It was not not done intentionally. –  Matthias Pospiech Nov 20 '11 at 21:34
@MatthiasPospiech: Thumbs up for getting the Suffrage Badge! Way to go! –  doncherry Nov 20 '11 at 21:42

1 Answer 1

up vote 5 down vote accepted

\providebool expects a string of characters as its argument; so


should be the way to go. However LaTeX already provides a command for testing whether a package has been loaded: \@ifpackageloaded.

However, saying each time \@ifpackageloaded{somepackage}{true}{false} might be cumbersome, particularly in case more than one package has to be considered.


Then you can say


to set the booleans to the correct value and, for instance,

\ifboolexpr{ bool {tpl@p@hyperref} and bool {tpl@p@caption} }
   { what to do in case both packages are loaded }
   { what to do otherwise }
share|improve this answer
So the actual error was the use of \ in my bool command. As a side not: This shall be used within the document and be available to the user. Therefore \@ifpackageloaded is not a good choice. My command is only an alias: \newcommand{\IfElsePackageLoaded}[3]{\ltx@ifpackageloaded{#1}{#2}{#3}}. However my original question (maybe I actually asked two) was how to implement this using LaTeXs internal temp structures. –  Matthias Pospiech Nov 21 '11 at 6:27
Then use \ltx@ifpackageloaded, of course. But \let\IfElsePackageLoaded\ltx@ifpackageloaded is more efficient. –  egreg Nov 21 '11 at 9:47

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.