7

I have a LaTeX code which gives me the error Incomplete \iffalse; all text was ignored after line 43. }. Although this code may look a little large, removing a single letter (!) from almost anywhere (!!!) causes the code to compile.

\documentclass{article}
\usepackage{geometry}
\usepackage[utf8]{inputenc}
\PassOptionsToPackage{defaults=hu-min}{magyar.ldf}
\usepackage[magyar]{babel}

\usepackage{listings}
\begin{document}
    \begin{center}
        {\LARGE\textbf{C}}

        {\Large G}

        1
    \end{center}
    A
    \section{}
    A C++ többek között a  is híres. Andrei Alexandrescu azt nyilatkozta, hogy amikor a Facebooknál a backend kódján 1\%ot sikerült optimalizálni, b mint 10 évnyi fizetését spórolta meg a cégnek végrehn a  nyelvekkz

    A C++-szal kapcsolatban az egyik gyakori tévhit, hogy egy alacsony szintű nyelvről van szó. Bár a nyelv lehetőséget biztosít arra, hogy n hozzáférjostalmbbször a  tünteeket az absztrakciókat a prítás során.

    A C++ filozófiájának fontos eleme, hogy ha nem használunk egy adott nyelvi eszközt, akkor annak ne legyen hatása a program teljesítményére.

    Fontos, hogy a C++ alapvetően nem egy objektum orientált nyelv. Bár számos nyelvi eszköA funkcráni. 

    \medskip
    Cél: a tárgy során kialakítani a nyelvvel kapcsolintuíciót, ami segítéségével elkerülhetőek alapvető hibák is. Az előzménytárgyakban az egyszerűség kedvéért gyakran féligazságok hangzottak el, ezeket kell rakni.
    \subsection{+?}
    Alapvetően a nyelv kéllis szabváannak implementációiból ók + szabványkönyvtárak).  A szabv a nyelv nyeát, valamint a szemantikát: mtenek a duló programok (nem deEmellett a szabvány definiálja a szabványkönyvtárat is, amit os C++ fordító mellé szállítaz első C++ szabvt. További szabványai: 

    A szabvány
    \subsection{}
    Ez a jegyzet feltételezi, hogy az Olvasó elvégezte a c. tárgyat, és a Programozás tárgyat vagy ezzel párhuzamosan végzi, vagy mljesítette. Így unk arra, hogy az Olvasó tisztáb és, létre tud hozni és meg is tudja hívni azokat, ké egy helyes  kódot lefordítani (még lamint egyszerűbb algoritmusokat is tud
    \section{}
    \begin{lstlisting}


;

i
{

}
    \end{lstlisting}
\end{document}

I'm completely stuck at this point. This is a part of a 110+ page book, and even if I'm using tricks such as removing a couple words here and there to make it compile, any addition or removal of code above this point may cause the code not to compile again.

The entire code: http://people.inf.elte.hu/szelethus/LaTeX/cpp/01gy_cpp/01gy_cpp.tex Issues arise at around code snippet containing the Hello World program (the very first code snippet).

  • 1
    Welcome to TeX.SE. Remove the white space just before ; in the lstlisting environment. –  Jun 25 '17 at 21:00
  • 1
    The problem is imho the page break in the middle of the listings. The changes from magyar and the changes from listings clashes there. – Ulrike Fischer Jun 25 '17 at 21:25
  • @ChristianHupfer Maybe my "minimal working example" was a little too minimal. Here is the entirety of the listlisting code: #include

    using namespace std;

    int main() { cout << "Hello World!" << endl; }

    – Kristóf Umann Jun 25 '17 at 21:42
  • Elaborating on @UlrikeFischer’s comment, it can be easily seen that, indeed, the error occurs while outputting page 1, or, more precisely, during the relevant \shipout: you can tell this from the dangling [1with no cloding ] (yet) that can be seen a couple of lines above. To get additional debug information, you could add a line that says \errorcontextlines = 100 (for example) right after \begin{document}. – GuM Jun 25 '17 at 23:44

4 Answers4

3

magyar.ldf actively prevents \initiate@active@char to write code to \AtBeginDocument which would add catcode changes to the aux-file.

This has the effect that when \subsection{+?} is written to the aux the code from listings interferes. (I didn't try to find out the details. magyar.ldf is imho a rather bad example of a language file, it patches all sorts of internal commands and is probably incompatible with a lot of other things).

You can try to get around the problem by adding the following to your preamble.

\usepackage[magyar]{babel}

\makeatletter
\expandafter\let\csname active@char\string?\endcsname\relax
\expandafter\let\csname active@char\string!\endcsname\relax
\expandafter\let\csname active@char\string:\endcsname\relax


\initiate@active@char{?}
\initiate@active@char{!}
\initiate@active@char{:}
\makeatother
Dalker
  • 429
Ulrike Fischer
  • 327,261
  • This is it! Thanks a lot. You can see the entirety of the code here: http://people.inf.elte.hu/szelethus/LaTeX/cpp/01gy_cpp/01gy_cpp.tex Note that when you comment out the line \section{Előszó} (77th line as of now), it causes an error when this little code snippet isn't in the preamble. – Kristóf Umann Jun 26 '17 at 10:38
  • 1
    I had the same problem and this solved it (although I definitely do not have a magyar language file around, language of my document is French). Just a little note: last line of your fix should probably be \makeatother, not \makeatletter again -- edited answer correspondingly as I just realized I actually could. – Dalker Nov 02 '19 at 06:08
  • @Talker Thanks for the edit. If you have a similar error with french you should better ask a new question with a minimal example. The french module is well maintained and it is worth to investigate instead of using some work arounds. – Ulrike Fischer Nov 02 '19 at 08:04
3

Although I have to admit I do not really understand what causes this bug (I had the same behaviour as that described by the question), based on Ulrike Fischer's answer plus some other "hack" I already had around to fix hyphens in lstlistings, I found that the following code also fixes the issue. It has the advantage of being clearly defined in the scope of lstlisting, without affecting the rest of the document in any way:

\lstset{ % ... whatever was already there ...
        literate=% ... any other literates already there ...
                 {!}{!}1
                 {?}{?}1
                 {:}{:}1
}
Dalker
  • 429
2

In general there are several reasons which cause Incomplete \iffalse; all text was ignored after line X. }.

Independent of the example from OP, if it helps someone in future: In my case I had this error when writing \import{other/titlepage.tex} instead of \import{other}{titlepage.tex} anywhere.

anion
  • 121
  • 2
1

I encountered the same problem with my french document, but @Dalker answer did not solve it*.

Based on this question: Package listings: Error "Undefined control sequence." because of single-quote-symbol?, revealing conflicts with textcomp, I had to move the \usepackage{listings} much later in the preamble, and it worked. I suppose there might be some interferences with packages like babel-french, textcomp, icomma, textgreek...


* for the record, it generates this error:

! Undefined control sequence.
:...ble \else \lst@XPrintToken \let \lst@scanmode 
                                                  \lst@scan@m \lst@token {:}..