I have several books with toggles/ifs for each of them (I have toggles and ifs because I had several problems with some other packages..) I defined the toggles in my style-File like this:


and defining the type in the Book with the command \printer

Since I have like 70 different products I would like to declare a new product in my style file with \newproduct{printer} and Latex sets up the lines above. How can I do this?


Just give the printer name as a parameter:

  \expandafter\newcommand\csname #1\endcsname{%

Now \defineprinter{printer} will do the same as your sample code.

It's a bit complicated because you want to build commands based on the argument, so \csname is needed for defining \printer (or whatever is passed as argument).

Using \newbool ensures the boolean you're going to define is not already defined. After \newbool{printer} you have \ifprinter, \printertrue and \printerfalse, because \newbool does a \newif internally.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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