# \if@ statement explanation

I'm trying to tweak some `.cls` to fit my needs, and I'd really appreciate it if someone could explain me these statements:

``````\if@radseminar%
...
\else
...
\fi
``````

If I understand correctly, it will match `@radseminartrue`, right? How can I use OR statement? For example, I tried

``````\if{@radtehnicka% or @radseminar%}
``````

but it didn't match either.

-
Answers to this question might be helpful. tex.stackexchange.com/q/5894/215 –  Seamus Jan 7 '11 at 17:12
Note that `\if@radseminar` is one control sequence. Moreover, an "OR" construct of the sort you're seeking doesn't exist. –  Hendrik Vogt Jan 7 '11 at 17:18

There is no macro `\if@` … the macro you’re seeing is called `\if@radseminar` (yes, the `@` and all that follows is part of the macro name).

TeX doesn’t know boolean evaluation. You cannot just join several conditions together like in other programming languages. You need to test the conditions separately by nesting them:

``````\if@radseminar
<true>
\else
<true>
\fi
<else>
\fi
``````

However, there are LaTeX packages to allow this, e.g. `etoolbox` or `ifthen` (the latter shouldn’t be used any more I’ve been told).

Using `etoolbox`, it should look approximately like this:

``````\ifboolexpr{bool {@radseminar} or bool {@radtehnicka}}{<true>}{<false>}
``````
-
thanks! :) being a programmer, I'm having problems adjusting to latex :D –  Marin Jan 7 '11 at 17:42
What's wrong with ifthen? –  Matthew Leingang Jan 8 '11 at 12:21
@Matthew: to be honest, I don’t know. Philipp called it obsolete in a comment to another answer. I guess it’s simply superseded by the more feature-rich and slightly better designed `etoolbox`. However, I’ve found at least one case where `ifthen` has yielded a different (and IMHO correct) result than `etoolbox`. –  Konrad Rudolph Jan 8 '11 at 14:42

As others pointed out the `\if@` is not a macro just part of a macro name. Using higher-level macros like the ones of the already mentioned `etoolbox` package should be preferred for beginners and/or for documents.

The common method to OR-combine multiple if-switches using lower level macros is to use `\ifcase`. It awaits a number (0 or higher) and then executes only the corresponding branch. The branches are separated by `\or`. The last one can be separated by `\else` which is executed if there is no explicit branch for that number.

``````\ifcase0%
A trick is used here: `0%` is given as default value. Because of the `%` TeX keeps looking for digits which can follow the `0` and are taken as part of a single number. TeX expands all following tokens (e.g. macros) until it finds a non-digit. Then both if-switches are used here which insert a `1` but no other tokens if they are true and expand to nothing if they are false. Therefore TeX keeps looking for further tokens and processes further `\if@... \fi` lines. It stops looking for a number at the `\relax`. If none of the two if-switches are true the final number is `0` so the case 0 branch is executed. If one of them is true the final number is `01` i.e. `1` so case 1 branch is executed. If both are true the final number is `011`, i.e. `11` so the case 11 branch would be executed. However there is neither a case 1 nor 11, because `\else` is used. The in both cases the `\else` branch is executed, effectively OR-combining the two if-switches.