How can I use an if conditonal in LaTeX? If the conditon is true I want to execute a code and if not then continue. Sorry for my example code and English. I dont know how to do it.

\usepackage{ifthen} %Paket einbinden
\newboolean{persoenlich} %Deklaration einer boolschen Variable
\setboolean{persoenlich}{false} %Zuweisung eines Wertes.

For your information -> Cross-post https://texwelt.de/wissen/fragen/23136/wie-funktioniert-eine-if-abfrage-in-latex


2 Answers 2


There are different possibilities.

Plain style would be:


This defines three macros, \MyIfThingytrue to set it to true, \MyIfThingyfalse to set it to false and \ifMyIfThingy. You can use it the following way:


There are high level implementations in LaTeX like those provided by etoolbox:



The difference between toggles and booleans in etoolbox are that the bools are internally build upon \newif while the toggles are implemented differently and only use one macro per toggle.

Then there are LaTeX3 booleans like:


\bool_new:N \l_my_bool_thingy_bool
\bool_set_true:N \l_my_bool_thingy_bool
\bool_set_false:N \l_my_bool_thingy_bool

\bool_if:NTF \l_my_bool_thingy_bool
  { True }
  { False }

But you should only use LaTeX3 booleans if you code in expl3...


With ifthen, you do


Replace True with the code you want to execute if the boolean returns true and similarly for False.

You must log in to answer this question.

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