3

On the question Is it possible to keep my translation together with original text? I learned how to do an if, however when I use it like on this document:

\documentclass[10pt,a5paper,twoside]{memoir}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}

\usepackage[brazil]{babel}
\usepackage[showframe,pass]{geometry}

\newif\ifdebug
\debugfalse
\debugtrue

\begin{document}

Arquivo compilado \ifdebug22:00\else\currenttime\fi h do dia \ifdebugTODAY\else\today\if.

\end{document}

It throws the error:

! Undefined control sequence.
l.81 ...else\currenttime\fi h do dia \ifdebugTODAY
                                                  \else\today\if.
The control sequence at the end of the top line
of your error message was never \def'ed. If you have
misspelled it (e.g., `\hobx'), type `I' and the correct
spelling (e.g., `I\hbox'). Otherwise just continue,
and I'll forget about whatever was undefined.

! Extra \else.
l.81 ...currenttime\fi h do dia \ifdebugTODAY\else
                                                  \today\if.
I'm ignoring this; it doesn't match any \if.

)
! Incomplete \if; all text was ignored after line 81.
<inserted text> 
                \fi 
<*> ./test2.tex

The file ended while I was skipping conditional text.
This kind of error happens when you say `\if...' and forget
the matching `\fi'. I've inserted a `\fi'; this might work.

! Emergency stop.
<*> ./test2.tex

*** (job aborted, no legal \end found)

But if I change the if line adding some spaces:

Arquivo \ifdebug 22:00 \else \currenttime \fi h do dia \ifdebug TODAY \else \today \if .

The error became:

! Incomplete \iftrue; all text was ignored after line 81.
<inserted text> 
                \fi 
<*> ./test2.tex

The file ended while I was skipping conditional text.
This kind of error happens when you say `\if...' and forget
the matching `\fi'. I've inserted a `\fi'; this might work.

! Emergency stop.
<*> ./test2.tex

*** (job aborted, no legal \end found)

Related:

  1. Incomplete \iffalse; all text was ignored after line 1499
  2. ! Incomplete \iffalse; all text was ignored after line 22. In \IEEEauthorblockN
  3. "Incomplete \iffalse; all text was ignored after line x" with lstlisting
  4. incomplete \ifodd , all text was ignored... error
7

There are two errors from typos:

Arquivo compilado \ifdebug22:00\else\currenttime\fi h do dia \ifdebugTODAY\else\today\if.

The first error is \ifdebugTODAY, which refers to an unknown \debugTODAY conditional, so the space between \ifdebug and TODAY matters here.

The space is not necessary for \ifdebug22:00 since the digits after \ifdebug clearly delimit the name of the debug conditional.

The second error is the \if at the end. It should read \fi.

\documentclass[10pt,a5paper,twoside]{memoir}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}

\usepackage[brazil]{babel}
\usepackage[showframe,pass]{geometry}

\newif\ifdebug
\debugfalse
\debugtrue

\begin{document}

Arquivo compilado \ifdebug 22:00\else\currenttime\fi h do dia \ifdebug TODAY\else\today\fi.

\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.