# Command to make new command

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:

 \newtoggle{printer}
\togglefalse{printer}
\newif\ifprinter
\printerfalse
\newcommand{\printer}{\printertrue\toggletrue{printer}}


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:

\newcommand{\defineprinter}[1]{%
\newtoggle{#1}%
\togglefalse{#1}%
\newbool{#1}%
\boolfalse{#1}%
\expandafter\newcommand\csname #1\endcsname{%
\booltrue{#1}\toggletrue{#1}%
}%
}


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.