TransWikia.com

"Incomplete iffalse; all text was ignored after line x" with lstlisting

TeX - LaTeX Asked by Kristóf Umann on March 15, 2021

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}
        {LARGEtextbf{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).

4 Answers

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
expandafterletcsname active@charstring?endcsnamerelax
expandafterletcsname active@charstring!endcsnamerelax
expandafterletcsname active@charstring:endcsnamerelax


initiate@active@char{?}
initiate@active@char{!}
initiate@active@char{:}
makeatother

Correct answer by Ulrike Fischer on March 15, 2021

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
}

Answered by Dalker on March 15, 2021

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 {:}..

Answered by PlasmaBinturong on March 15, 2021

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.

Answered by anion on March 15, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP