I had a .tex file where I defined an expression earlier with the \usepackage{ifthen}. Now I want to use \usepackage{etoolbox} for this purpose but don't know how to use it correctly I get an error Undefined control sequence.} after compile.

\setbool{CV}{true}    % <===========================================
\setbool{Letter}{false} %
\ifbool{CV}{% print CV}
\ifbool{Letter}{% print Cover Letter}

where is my mistake with the Undefined control sequence I can't find the error. How is the correct use of ifbool, do I need break from other brace if one expression is true? any help would be appreciated

  • Please see my added answer ... Next time please give a complete MWE not only code snippet ...
    – Mensch
    Commented Aug 23, 2021 at 13:07

2 Answers 2


Based on your given MWE in your old Question change your cv like this (see important code changings marked with <======):

%\usepackage[latin1]{inputenc} % <======================================

\xpatchcmd{\makeletterclosing}{\bfseries \@firstname~\@lastname}
                              {\includegraphics[width=4cm, height=1cm]{unterschrift.jpg}
                               \bfseries \@firstname~\@lastname}

% personal data
\title{Lebenslauf}                               % optional, remove / comment the line if not wanted
\address{asdfdsf 12}{77777 scity}{Germany}
\phone[mobile]{+49~(xxx)~xxx~xxx}                   %

% commands with ifthen <================================================

% commands with etoolbox (alreeady loaded in class moderncv) <==========

%\ifthenelse{\boolean{CV}} % <============================== with ifthen
\ifbool{CV} % <=========================================== with etoolbox 
{% print CV
  \ \\
  \ \\
  \includegraphics[width=4cm, height=1cm]{example-image} \\
  ccity, 10. Oktober 2017
{% print no CV
\title{Bewerbung um XXX}
%\ifthenelse{\boolean{Letter}} % <========================== with ifthen
\ifbool{Letter} % <======================================= with etoolbox
{% print Cover Letter
  \date{ccity, 10.10.2017}
  \opening{\textbf{Sehr geehrte Damen und Herren},}
  \closing{Mit freundlichen Grüßen,}
  \enclosure[Im Anhang]{Lebenslauf}          

  Suspendisse commodo, massa eu congue tincidunt, elit mauris 
  pellentesque orci, cursus tempor odio nisl euismod augue.
{% print no Cover Letter


resulting in the following pdf:

resulting cv without letter


\ifbool{<bool>}{<true>}{<false>} takes three arguments. The first is the boolean variable (defined via \newbool{<bool>}) while the second and third define the branches to follow dependent on the value of the boolean being either <true> or <false>.

enter image description here




\setbool{CV}{true}% Equivalent to \booltrue{CV}
\setbool{Letter}{false}% Equivalent to \boolfalse{Letter}

\ifbool{CV}{print CV}{do not print CV}%

\ifbool{Letter}{print Cover Letter}{do not print Cover Letter}%

  • Thanks Werner I have 3 arguments in my tex file. The third argument (brace) is empty {}. But I have still the error with Undefined control sequence. }
    – Hakikat41
    Commented Aug 23, 2021 at 0:15
  • @Hakikat41: It doesn't show in your code snippet. Can you provide a minimal document that replicates the issue so we can inspect what's going on? It should start with \documentclass and end with \end{document} and allow us to copy-and-paste-and-compile and see exactly the error what you're seeing. Can you do that?
    – Werner
    Commented Aug 23, 2021 at 15:37

You must log in to answer this question.

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