I'm new to LaTeX so I'm not quite sure how to proceed with this. I'm trying to have different versions of the same document, depending on which variables are set. What I want is to change the whole document changing one line.
So far, I've been trying something I found in a template, but I haven't been able to get it to work.
\newif\if@thing\@thingfalse
\newcommand*{\displaything}{\@thingtrue}
That way, when I write \displaything
, the variable should be set. If someday I don't want the variable, I'd just comment this line. Then, I want to pass this variable to another command, like this:
\newcommand*{\foo}[2]{
\ifthenelse{#1}
{
% do something if set, using #2
}
{
% do something else if not set, using #2 (default)
}
}
The idea is to have multiple \foo
calls with more arguments, and different flag-things, and then use them like this:
\foo{\@thing}{arg}, \foo{@thing2}{arg}
Maybe this isn't even the right way to do it, any thoughts?
\ifthenelse
does not take as its argument a command created with\newif
. You have to do something like\newboolean{thing}
and the later\ifthenelse{\boolean{thing}}
.\ifthenelse
isn't followed by an if-command in braces, but rather by a boolean expression in braces. See cfr's answer. See also theifthen
documentation for what syntax is required by\ifthenelse
.