I am using conditional tests in my .cls file which has two options "final" and "draft". I am rather familiar with conditional tests but I am just curious to know how to define the "or" in the following code.

\if@‎final OR ‎\if@draft FINAL TEST ‎‎ ‎\else NO TEST‎ ‎\fi\fi


I have tried the following code and have gotten the desired result, so I just want to know whether I CAN use something like "\or" in \newif conditional or not. In other word, does such a command (I mean \or) exist at all?

‎\newcommand{‎\mytest‎}‎{\if@‎final FINAL TEST ‎\else‎  ‎\if@draft FINAL TEST ‎‎ ‎\else ‎NO ‎TEST‎ ‎\fi\fi‎‎‎‎‎}‎‎
  • Do you have different outputs based on whether you're final or draft, since your faux if statement doesn't show it?
    – Werner
    Dec 29, 2011 at 22:24
  • In both cases, I want to have "FINAL TEST" on my output. Dec 29, 2011 at 22:31
  • 1
    Yes, \or exists, but is not used in the context of boolean expressions like you might be used to. Instead it is used as a choice conditioning when using \ifcase. See some examples of \or in the TeX Primitive Control Sequence Reference.
    – Werner
    Dec 29, 2011 at 23:56

1 Answer 1


The basis for your OR statement looks like this:

\if@final TRUE\else\if@draft TRUE\else FALSE\fi\fi

The following minimal example illustrates this:

\newif\if@final \newif\if@draft
\newcommand{\test}{\if@final TRUE\else\if@draft TRUE\else FALSE\fi\fi}
% final = false; draft = false
\@finalfalse \@draftfalse \test

% final = true; draft = false
\@finaltrue \@draftfalse \test

% final = false; draft = true
\@finalfalse \@drafttrue \test

% final = true; draft = true
\@finaltrue \@drafttrue \test

yielding the OR truth table:

enter image description here

Comparable output is obtained by using booleans defined via etoolbox:

\usepackage{etoolbox}% http://ctan.org/pkg/etoolbox
%\newif\if@final \newif\if@draft
\newbool{@final} \newbool{@draft}
\newcommand{\test}{\ifboolexpr{bool {@final} or bool {@draft}}{TRUE}{FALSE}}
% final = false; draft = false
\boolfalse{@final} \boolfalse{@draft} \test

% final = true; draft = false
\booltrue{@final} \boolfalse{@draft} \test

% final = false; draft = true
\boolfalse{@final} \booltrue{@draft} \test

% final = true; draft = true
\booltrue{@final} \booltrue{@draft} \test

Of course, you can change the TRUE/FALSE output to whatever you want.

As Marco remarked, etoolbox's boolean flags provide a front-end to LaTeX's \newif. As such you can either define them using \newbool or \newif. See section 3.5 Boolean Flags (p 12 onward) of the etoolbox documentation.

  • 1
    Since \ifboolexpr and \ifboolexpe imply processing overhead, there is generally no benefit in employing them for a single/simple test. etoolbox documentation.
    – Ahmed Musa
    Dec 30, 2011 at 8:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .