Why latex does not tell me which command is undefined? Announcing the arrival of Valued...

How much damage would a cupful of neutron star matter do to the Earth?

Tannaka duality for semisimple groups

Tips to organize LaTeX presentations for a semester

What is the chair depicted in Cesare Maccari's 1889 painting "Cicerone denuncia Catilina"?

Is it dangerous to install hacking tools on my private linux machine?

Found this skink in my tomato plant bucket. Is he trapped? Or could he leave if he wanted?

Where is the Next Backup Size entry on iOS 12?

RSA find public exponent

What is the origin of 落第?

Moving a wrapfig vertically to encroach partially on a subsection title

Special flights

Flight departed from the gate 5 min before scheduled departure time. Refund options

Why are vacuum tubes still used in amateur radios?

What would you call this weird metallic apparatus that allows you to lift people?

Random body shuffle every night—can we still function?

If Windows 7 doesn't support WSL, then what is "Subsystem for UNIX-based Applications"?

The test team as an enemy of development? And how can this be avoided?

Sally's older brother

As a dual citizen, my US passport will expire one day after traveling to the US. Will this work?

What are the main differences between Stargate SG-1 cuts?

Why weren't discrete x86 CPUs ever used in game hardware?

Nose gear failure in single prop aircraft: belly landing or nose-gear up landing?

Why do early math courses focus on the cross sections of a cone and not on other 3D objects?

Would color changing eyes affect vision?



Why latex does not tell me which command is undefined?



Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern)Test if a package (or package option) is loaded












0















From the beginning, took me a lot of time to come with the following minimal example:



PassOptionsToPackage{main=brazil,english,spanish,french}{babel}

documentclass[
10pt,
a5paper,
]{memoir}

makeatletter
@ifpackagewith{babel}{english}{message{English YES!^^J}}{message{English NO!^^J}}
@ifpackagewith{babel}{brazil}{message{Brazil YES!^^J}}{message{Brazil NO!^^J}}
@ifpackagewith{babel}{turkish}{message{Turkish YES!^^J}}{message{Turkish NO!^^J}}

@ifpackagewith{babel}{brazil}{addtocaptionsbrazil{renewcommand{lstlistingname}{Código}}}{}
@ifpackagewith{babel}{english}{addtocaptionsenglish{renewcommand{lstlistingname}{Code}}}{}
makeatother

begin{document}
chapter{Introduction}
Thing.
end{document}


Runnning this example with:



'latexmk.exe' -cd -f -pdf -interaction=nonstopmode -synctex=1 '--output-directory=cache' -latexoption=-file-line-error -latexoption=-halt-on-error -latexoption=--max-print-line=10000 test1.tex



$ tex --version
MiKTeX-TeX 2.9.6300 (3.14159265) (MiKTeX 2.9.6400)]

...
Package tabularx [2008/07/23] emulated by memoir.
Package titleref [2008/07/23] emulated by memoir.
Package titling [2008/07/23] emulated by memoir.
Package tocbibind [2008/07/23] emulated by memoir.
Package tocloft [2008/07/23] emulated by memoir.
Package tocvsec2 [2008/07/23] emulated by memoir.
Package verbatim [2008/07/23] emulated by memoir.
Package verse [2008/07/23] emulated by memoir.
(D:UserDocumentslatextexmfsinstalltexlatexmemoirmempatch.sty
Package: mempatch 2009/07/24 v6.0f Patches for memoir class v1.6180339
)) English YES!
Brazil NO!
Turkish NO!
test1.tex:17: Undefined control sequence
Here is how much of TeX's memory you used:
3506 strings out of 493314
47031 string characters out of 3134142
129114 words of memory out of 3000000
7118 multiletter control sequences out of 15000+200000
4238 words of font info for 16 fonts, out of 3000000 for 9000
1141 hyphenation exceptions out of 8191
24i,1n,22p,129b,62s stack positions out of 5000i,500n,10000p,200000b,50000s

test1.tex:17: ==> Fatal error occurred, no output PDF file produced!


Latex does not tell me on its log which command is not defined. It only says Undefined control sequence, which is very much useless.



How can I make latex tell me exactly which command he is not finding defined?



Only after a lot of trying, I figured out that the ifpackagewith does not check whether the package is loaded. It only checks whether there is some option on the package name queue.



Then, a fixed version is:



makeatletter
@ifpackageloaded{babel}{@ifpackagewith{babel}{english}{message{English YES!^^J}}{message{English NO!^^J}}}{}
@ifpackageloaded{babel}{@ifpackagewith{babel}{brazil}{message{Brazil YES!^^J}}{message{Brazil NO!^^J}}}{}
@ifpackageloaded{babel}{@ifpackagewith{babel}{turkish}{message{Turkish YES!^^J}}{message{Turkish NO!^^J}}}{}

@ifpackageloaded{babel}{@ifpackagewith{babel}{brazil}{addtocaptionsbrazil{renewcommand{lstlistingname}{Código}}}{}}{}
@ifpackageloaded{babel}{@ifpackagewith{babel}{english}{addtocaptionsenglish{renewcommand{lstlistingname}{Code}}}{}}{}
makeatother


Or just load the babel package with RequirePackage{babel}.





Now, forgetting about the fix, which is load babel or use @ifpackageloaded. Why latex does not tell me which command was undefined from the beginning???



If I remove the -latexoption=-halt-on-error, then, latex tells me the command lstlistingname is undefined, but that is the WRONG command. The command which is undefined is addtocaptions from babel package, which was not loaded.



See here the output from latex:



'latexmk.exe' -cd -f -pdf -interaction=nonstopmode -synctex=1 '--output-directory=cache' -latexoption=-file-line-error -latexoption=--max-print-line=10000 test1.tex



xmemoirmempatch.sty)) English YES!
Brazil NO!
Turkish NO!
test1.tex:15: Undefined control sequence
test1.tex:15: Undefined control sequence

test1.tex:15: LaTeX Error: lstlistingname undefined.

See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help


If I remove the lstlistingname from the input program like this:



makeatletter
@ifpackagewith{babel}{english}{message{English YES!^^J}}{message{English NO!^^J}}
@ifpackagewith{babel}{brazil}{message{Brazil YES!^^J}}{message{Brazil NO!^^J}}
@ifpackagewith{babel}{turkish}{message{Turkish YES!^^J}}{message{Turkish NO!^^J}}

@ifpackagewith{babel}{brazil}{addtocaptionsbrazil{}}{}
@ifpackagewith{babel}{english}{addtocaptionsenglish{}}{}
makeatother


And run back latex again, without the -interaction=nonstopmode and -latexoption=-halt-on-error, then, latex tells me absolutely nothing about which command is undefined!



'latexmk.exe' -cd -f -pdf '--output-directory=cache' -latexoption=-file-line-error -latexoption=--max-print-line=10000 test1.tex



Latexmk: This is Latexmk, John Collins, 19 Jan. 2017, version: 4.52c.
Latexmk: Changing directory to './'
Latexmk: making output directory 'cache'
Latexmk: applying rule 'pdflatex'...
Rule 'pdflatex': Rules & subrules not known to be previously run:
pdflatex
Rule 'pdflatex': The following rules & subrules became out-of-date:
'pdflatex'
------------
Run number 1 of rule 'pdflatex'
------------
------------
Running 'pdflatex -file-line-error --max-print-line=10000 -recorder -output-directory="cache" "test1.tex"'
------------
This is pdfTeX, Version 3.14159265-2.6-1.40.18 (MiKTeX 2.9.6400)
entering extended mode
(test1.tex
LaTeX2e <2017-04-15>
Babel <3.12> and hyphenation patterns for 76 language(s) loaded.
(D:UserDocumentslatextexmfsinstalltexlatexmemoirmemoir.cls
Document Class: memoir 2016/05/16 v3.7f configurable book, report, article document class
(D:UserDocumentslatextexmfsinstalltexgenericoberdiekifpdf.sty) (D:UserDocumentslatextexmfsinstalltexlatexifetexifetex.sty (D:UserDocumentslatextexmfsinstalltexplainifetexifetex.tex)) (D:UserDocumentslatextexmfsinstalltexgenericifxetexifxetex.sty) (D:UserDocumentslatextexmfsinstalltexgenericoberdiekifluatex.sty) (D:UserDocumentslatextexmfsinstalltexlatexmemoirmem10.clo) (D:UserDocumentslatextexmfsinstalltexlatexmemoirmempatch.sty)) English YES!
Brazil NO!
Turkish NO!
test1.tex:15: Undefined control sequence
test1.tex:15: Undefined control sequence
(D:Testcachetest1.aux) [1{D:/User/Documents/latex/texmfs/data/pdftex/config/pdftex.map}] (D:Testcachetest1.aux) )
(see the transcript file for additional information)<D:/User/Documents/latex/texmfs/install/fonts/type1/public/amsfonts/cm/cmbx12.pfb><D:/User/Documents/latex/texmfs/install/fonts/type1/public/amsfonts/cm/cmr10.pfb>
Output written on D:Testcachetest1.pdf (1 page, 21716 bytes).
Transcript written on D:Testcachetest1.log.
=== TeX engine is 'pdfTeX'
Latexmk: Log file says output to 'cache/test1.pdf'
Latexmk: applying rule 'pdflatex'...
Rule 'pdflatex': File changes, etc:
Changed files, or newly in use since previous run(s):
'cache/test1.aux'
------------
Run number 2 of rule 'pdflatex'
------------
------------
Running 'pdflatex -file-line-error --max-print-line=10000 -recorder -output-directory="cache" "test1.tex"'
------------
This is pdfTeX, Version 3.14159265-2.6-1.40.18 (MiKTeX 2.9.6400)
entering extended mode
(test1.tex
LaTeX2e <2017-04-15>
Babel <3.12> and hyphenation patterns for 76 language(s) loaded.
(D:UserDocumentslatextexmfsinstalltexlatexmemoirmemoir.cls
Document Class: memoir 2016/05/16 v3.7f configurable book, report, article document class
(D:UserDocumentslatextexmfsinstalltexgenericoberdiekifpdf.sty) (D:UserDocumentslatextexmfsinstalltexlatexifetexifetex.sty (D:UserDocumentslatextexmfsinstalltexplainifetexifetex.tex)) (D:UserDocumentslatextexmfsinstalltexgenericifxetexifxetex.sty) (D:UserDocumentslatextexmfsinstalltexgenericoberdiekifluatex.sty) (D:UserDocumentslatextexmfsinstalltexlatexmemoirmem10.clo) (D:UserDocumentslatextexmfsinstalltexlatexmemoirmempatch.sty)) English YES!
Brazil NO!
Turkish NO!
test1.tex:15: Undefined control sequence
test1.tex:15: Undefined control sequence
(D:Testcachetest1.aux) [1{D:/User/Documents/latex/texmfs/data/pdftex/config/pdftex.map}] (D:Testcachetest1.aux) )
(see the transcript file for additional information)<D:/User/Documents/latex/texmfs/install/fonts/type1/public/amsfonts/cm/cmbx12.pfb><D:/User/Documents/latex/texmfs/install/fonts/type1/public/amsfonts/cm/cmr10.pfb>
Output written on D:Testcachetest1.pdf (1 page, 21716 bytes).
Transcript written on D:Testcachetest1.log.
=== TeX engine is 'pdfTeX'
Latexmk: Log file says output to 'cache/test1.pdf'
Latexmk: Errors, in force_mode: so I tried finishing targets
Collected error summary (may duplicate other messages):
pdflatex: Command for 'pdflatex' gave return code 1
Refer to 'cache/test1.log' for details
Latexmk: Undoing directory change


Why latex does not tell which command is not defined? Does it hurt him? Is he afraid it is too much information and I cannot handle it by myself???



Is there some fix I can apply to latex, so it starts telling me which commands is not defined when there is some error?



References:




  1. http://tex.stackexchange.com/questions/228936/setting-entries-of-list-of-listings-in-latex-package-listings

  2. Test if a package (or package option) is loaded









share



























    0















    From the beginning, took me a lot of time to come with the following minimal example:



    PassOptionsToPackage{main=brazil,english,spanish,french}{babel}

    documentclass[
    10pt,
    a5paper,
    ]{memoir}

    makeatletter
    @ifpackagewith{babel}{english}{message{English YES!^^J}}{message{English NO!^^J}}
    @ifpackagewith{babel}{brazil}{message{Brazil YES!^^J}}{message{Brazil NO!^^J}}
    @ifpackagewith{babel}{turkish}{message{Turkish YES!^^J}}{message{Turkish NO!^^J}}

    @ifpackagewith{babel}{brazil}{addtocaptionsbrazil{renewcommand{lstlistingname}{Código}}}{}
    @ifpackagewith{babel}{english}{addtocaptionsenglish{renewcommand{lstlistingname}{Code}}}{}
    makeatother

    begin{document}
    chapter{Introduction}
    Thing.
    end{document}


    Runnning this example with:



    'latexmk.exe' -cd -f -pdf -interaction=nonstopmode -synctex=1 '--output-directory=cache' -latexoption=-file-line-error -latexoption=-halt-on-error -latexoption=--max-print-line=10000 test1.tex



    $ tex --version
    MiKTeX-TeX 2.9.6300 (3.14159265) (MiKTeX 2.9.6400)]

    ...
    Package tabularx [2008/07/23] emulated by memoir.
    Package titleref [2008/07/23] emulated by memoir.
    Package titling [2008/07/23] emulated by memoir.
    Package tocbibind [2008/07/23] emulated by memoir.
    Package tocloft [2008/07/23] emulated by memoir.
    Package tocvsec2 [2008/07/23] emulated by memoir.
    Package verbatim [2008/07/23] emulated by memoir.
    Package verse [2008/07/23] emulated by memoir.
    (D:UserDocumentslatextexmfsinstalltexlatexmemoirmempatch.sty
    Package: mempatch 2009/07/24 v6.0f Patches for memoir class v1.6180339
    )) English YES!
    Brazil NO!
    Turkish NO!
    test1.tex:17: Undefined control sequence
    Here is how much of TeX's memory you used:
    3506 strings out of 493314
    47031 string characters out of 3134142
    129114 words of memory out of 3000000
    7118 multiletter control sequences out of 15000+200000
    4238 words of font info for 16 fonts, out of 3000000 for 9000
    1141 hyphenation exceptions out of 8191
    24i,1n,22p,129b,62s stack positions out of 5000i,500n,10000p,200000b,50000s

    test1.tex:17: ==> Fatal error occurred, no output PDF file produced!


    Latex does not tell me on its log which command is not defined. It only says Undefined control sequence, which is very much useless.



    How can I make latex tell me exactly which command he is not finding defined?



    Only after a lot of trying, I figured out that the ifpackagewith does not check whether the package is loaded. It only checks whether there is some option on the package name queue.



    Then, a fixed version is:



    makeatletter
    @ifpackageloaded{babel}{@ifpackagewith{babel}{english}{message{English YES!^^J}}{message{English NO!^^J}}}{}
    @ifpackageloaded{babel}{@ifpackagewith{babel}{brazil}{message{Brazil YES!^^J}}{message{Brazil NO!^^J}}}{}
    @ifpackageloaded{babel}{@ifpackagewith{babel}{turkish}{message{Turkish YES!^^J}}{message{Turkish NO!^^J}}}{}

    @ifpackageloaded{babel}{@ifpackagewith{babel}{brazil}{addtocaptionsbrazil{renewcommand{lstlistingname}{Código}}}{}}{}
    @ifpackageloaded{babel}{@ifpackagewith{babel}{english}{addtocaptionsenglish{renewcommand{lstlistingname}{Code}}}{}}{}
    makeatother


    Or just load the babel package with RequirePackage{babel}.





    Now, forgetting about the fix, which is load babel or use @ifpackageloaded. Why latex does not tell me which command was undefined from the beginning???



    If I remove the -latexoption=-halt-on-error, then, latex tells me the command lstlistingname is undefined, but that is the WRONG command. The command which is undefined is addtocaptions from babel package, which was not loaded.



    See here the output from latex:



    'latexmk.exe' -cd -f -pdf -interaction=nonstopmode -synctex=1 '--output-directory=cache' -latexoption=-file-line-error -latexoption=--max-print-line=10000 test1.tex



    xmemoirmempatch.sty)) English YES!
    Brazil NO!
    Turkish NO!
    test1.tex:15: Undefined control sequence
    test1.tex:15: Undefined control sequence

    test1.tex:15: LaTeX Error: lstlistingname undefined.

    See the LaTeX manual or LaTeX Companion for explanation.
    Type H <return> for immediate help


    If I remove the lstlistingname from the input program like this:



    makeatletter
    @ifpackagewith{babel}{english}{message{English YES!^^J}}{message{English NO!^^J}}
    @ifpackagewith{babel}{brazil}{message{Brazil YES!^^J}}{message{Brazil NO!^^J}}
    @ifpackagewith{babel}{turkish}{message{Turkish YES!^^J}}{message{Turkish NO!^^J}}

    @ifpackagewith{babel}{brazil}{addtocaptionsbrazil{}}{}
    @ifpackagewith{babel}{english}{addtocaptionsenglish{}}{}
    makeatother


    And run back latex again, without the -interaction=nonstopmode and -latexoption=-halt-on-error, then, latex tells me absolutely nothing about which command is undefined!



    'latexmk.exe' -cd -f -pdf '--output-directory=cache' -latexoption=-file-line-error -latexoption=--max-print-line=10000 test1.tex



    Latexmk: This is Latexmk, John Collins, 19 Jan. 2017, version: 4.52c.
    Latexmk: Changing directory to './'
    Latexmk: making output directory 'cache'
    Latexmk: applying rule 'pdflatex'...
    Rule 'pdflatex': Rules & subrules not known to be previously run:
    pdflatex
    Rule 'pdflatex': The following rules & subrules became out-of-date:
    'pdflatex'
    ------------
    Run number 1 of rule 'pdflatex'
    ------------
    ------------
    Running 'pdflatex -file-line-error --max-print-line=10000 -recorder -output-directory="cache" "test1.tex"'
    ------------
    This is pdfTeX, Version 3.14159265-2.6-1.40.18 (MiKTeX 2.9.6400)
    entering extended mode
    (test1.tex
    LaTeX2e <2017-04-15>
    Babel <3.12> and hyphenation patterns for 76 language(s) loaded.
    (D:UserDocumentslatextexmfsinstalltexlatexmemoirmemoir.cls
    Document Class: memoir 2016/05/16 v3.7f configurable book, report, article document class
    (D:UserDocumentslatextexmfsinstalltexgenericoberdiekifpdf.sty) (D:UserDocumentslatextexmfsinstalltexlatexifetexifetex.sty (D:UserDocumentslatextexmfsinstalltexplainifetexifetex.tex)) (D:UserDocumentslatextexmfsinstalltexgenericifxetexifxetex.sty) (D:UserDocumentslatextexmfsinstalltexgenericoberdiekifluatex.sty) (D:UserDocumentslatextexmfsinstalltexlatexmemoirmem10.clo) (D:UserDocumentslatextexmfsinstalltexlatexmemoirmempatch.sty)) English YES!
    Brazil NO!
    Turkish NO!
    test1.tex:15: Undefined control sequence
    test1.tex:15: Undefined control sequence
    (D:Testcachetest1.aux) [1{D:/User/Documents/latex/texmfs/data/pdftex/config/pdftex.map}] (D:Testcachetest1.aux) )
    (see the transcript file for additional information)<D:/User/Documents/latex/texmfs/install/fonts/type1/public/amsfonts/cm/cmbx12.pfb><D:/User/Documents/latex/texmfs/install/fonts/type1/public/amsfonts/cm/cmr10.pfb>
    Output written on D:Testcachetest1.pdf (1 page, 21716 bytes).
    Transcript written on D:Testcachetest1.log.
    === TeX engine is 'pdfTeX'
    Latexmk: Log file says output to 'cache/test1.pdf'
    Latexmk: applying rule 'pdflatex'...
    Rule 'pdflatex': File changes, etc:
    Changed files, or newly in use since previous run(s):
    'cache/test1.aux'
    ------------
    Run number 2 of rule 'pdflatex'
    ------------
    ------------
    Running 'pdflatex -file-line-error --max-print-line=10000 -recorder -output-directory="cache" "test1.tex"'
    ------------
    This is pdfTeX, Version 3.14159265-2.6-1.40.18 (MiKTeX 2.9.6400)
    entering extended mode
    (test1.tex
    LaTeX2e <2017-04-15>
    Babel <3.12> and hyphenation patterns for 76 language(s) loaded.
    (D:UserDocumentslatextexmfsinstalltexlatexmemoirmemoir.cls
    Document Class: memoir 2016/05/16 v3.7f configurable book, report, article document class
    (D:UserDocumentslatextexmfsinstalltexgenericoberdiekifpdf.sty) (D:UserDocumentslatextexmfsinstalltexlatexifetexifetex.sty (D:UserDocumentslatextexmfsinstalltexplainifetexifetex.tex)) (D:UserDocumentslatextexmfsinstalltexgenericifxetexifxetex.sty) (D:UserDocumentslatextexmfsinstalltexgenericoberdiekifluatex.sty) (D:UserDocumentslatextexmfsinstalltexlatexmemoirmem10.clo) (D:UserDocumentslatextexmfsinstalltexlatexmemoirmempatch.sty)) English YES!
    Brazil NO!
    Turkish NO!
    test1.tex:15: Undefined control sequence
    test1.tex:15: Undefined control sequence
    (D:Testcachetest1.aux) [1{D:/User/Documents/latex/texmfs/data/pdftex/config/pdftex.map}] (D:Testcachetest1.aux) )
    (see the transcript file for additional information)<D:/User/Documents/latex/texmfs/install/fonts/type1/public/amsfonts/cm/cmbx12.pfb><D:/User/Documents/latex/texmfs/install/fonts/type1/public/amsfonts/cm/cmr10.pfb>
    Output written on D:Testcachetest1.pdf (1 page, 21716 bytes).
    Transcript written on D:Testcachetest1.log.
    === TeX engine is 'pdfTeX'
    Latexmk: Log file says output to 'cache/test1.pdf'
    Latexmk: Errors, in force_mode: so I tried finishing targets
    Collected error summary (may duplicate other messages):
    pdflatex: Command for 'pdflatex' gave return code 1
    Refer to 'cache/test1.log' for details
    Latexmk: Undoing directory change


    Why latex does not tell which command is not defined? Does it hurt him? Is he afraid it is too much information and I cannot handle it by myself???



    Is there some fix I can apply to latex, so it starts telling me which commands is not defined when there is some error?



    References:




    1. http://tex.stackexchange.com/questions/228936/setting-entries-of-list-of-listings-in-latex-package-listings

    2. Test if a package (or package option) is loaded









    share

























      0












      0








      0








      From the beginning, took me a lot of time to come with the following minimal example:



      PassOptionsToPackage{main=brazil,english,spanish,french}{babel}

      documentclass[
      10pt,
      a5paper,
      ]{memoir}

      makeatletter
      @ifpackagewith{babel}{english}{message{English YES!^^J}}{message{English NO!^^J}}
      @ifpackagewith{babel}{brazil}{message{Brazil YES!^^J}}{message{Brazil NO!^^J}}
      @ifpackagewith{babel}{turkish}{message{Turkish YES!^^J}}{message{Turkish NO!^^J}}

      @ifpackagewith{babel}{brazil}{addtocaptionsbrazil{renewcommand{lstlistingname}{Código}}}{}
      @ifpackagewith{babel}{english}{addtocaptionsenglish{renewcommand{lstlistingname}{Code}}}{}
      makeatother

      begin{document}
      chapter{Introduction}
      Thing.
      end{document}


      Runnning this example with:



      'latexmk.exe' -cd -f -pdf -interaction=nonstopmode -synctex=1 '--output-directory=cache' -latexoption=-file-line-error -latexoption=-halt-on-error -latexoption=--max-print-line=10000 test1.tex



      $ tex --version
      MiKTeX-TeX 2.9.6300 (3.14159265) (MiKTeX 2.9.6400)]

      ...
      Package tabularx [2008/07/23] emulated by memoir.
      Package titleref [2008/07/23] emulated by memoir.
      Package titling [2008/07/23] emulated by memoir.
      Package tocbibind [2008/07/23] emulated by memoir.
      Package tocloft [2008/07/23] emulated by memoir.
      Package tocvsec2 [2008/07/23] emulated by memoir.
      Package verbatim [2008/07/23] emulated by memoir.
      Package verse [2008/07/23] emulated by memoir.
      (D:UserDocumentslatextexmfsinstalltexlatexmemoirmempatch.sty
      Package: mempatch 2009/07/24 v6.0f Patches for memoir class v1.6180339
      )) English YES!
      Brazil NO!
      Turkish NO!
      test1.tex:17: Undefined control sequence
      Here is how much of TeX's memory you used:
      3506 strings out of 493314
      47031 string characters out of 3134142
      129114 words of memory out of 3000000
      7118 multiletter control sequences out of 15000+200000
      4238 words of font info for 16 fonts, out of 3000000 for 9000
      1141 hyphenation exceptions out of 8191
      24i,1n,22p,129b,62s stack positions out of 5000i,500n,10000p,200000b,50000s

      test1.tex:17: ==> Fatal error occurred, no output PDF file produced!


      Latex does not tell me on its log which command is not defined. It only says Undefined control sequence, which is very much useless.



      How can I make latex tell me exactly which command he is not finding defined?



      Only after a lot of trying, I figured out that the ifpackagewith does not check whether the package is loaded. It only checks whether there is some option on the package name queue.



      Then, a fixed version is:



      makeatletter
      @ifpackageloaded{babel}{@ifpackagewith{babel}{english}{message{English YES!^^J}}{message{English NO!^^J}}}{}
      @ifpackageloaded{babel}{@ifpackagewith{babel}{brazil}{message{Brazil YES!^^J}}{message{Brazil NO!^^J}}}{}
      @ifpackageloaded{babel}{@ifpackagewith{babel}{turkish}{message{Turkish YES!^^J}}{message{Turkish NO!^^J}}}{}

      @ifpackageloaded{babel}{@ifpackagewith{babel}{brazil}{addtocaptionsbrazil{renewcommand{lstlistingname}{Código}}}{}}{}
      @ifpackageloaded{babel}{@ifpackagewith{babel}{english}{addtocaptionsenglish{renewcommand{lstlistingname}{Code}}}{}}{}
      makeatother


      Or just load the babel package with RequirePackage{babel}.





      Now, forgetting about the fix, which is load babel or use @ifpackageloaded. Why latex does not tell me which command was undefined from the beginning???



      If I remove the -latexoption=-halt-on-error, then, latex tells me the command lstlistingname is undefined, but that is the WRONG command. The command which is undefined is addtocaptions from babel package, which was not loaded.



      See here the output from latex:



      'latexmk.exe' -cd -f -pdf -interaction=nonstopmode -synctex=1 '--output-directory=cache' -latexoption=-file-line-error -latexoption=--max-print-line=10000 test1.tex



      xmemoirmempatch.sty)) English YES!
      Brazil NO!
      Turkish NO!
      test1.tex:15: Undefined control sequence
      test1.tex:15: Undefined control sequence

      test1.tex:15: LaTeX Error: lstlistingname undefined.

      See the LaTeX manual or LaTeX Companion for explanation.
      Type H <return> for immediate help


      If I remove the lstlistingname from the input program like this:



      makeatletter
      @ifpackagewith{babel}{english}{message{English YES!^^J}}{message{English NO!^^J}}
      @ifpackagewith{babel}{brazil}{message{Brazil YES!^^J}}{message{Brazil NO!^^J}}
      @ifpackagewith{babel}{turkish}{message{Turkish YES!^^J}}{message{Turkish NO!^^J}}

      @ifpackagewith{babel}{brazil}{addtocaptionsbrazil{}}{}
      @ifpackagewith{babel}{english}{addtocaptionsenglish{}}{}
      makeatother


      And run back latex again, without the -interaction=nonstopmode and -latexoption=-halt-on-error, then, latex tells me absolutely nothing about which command is undefined!



      'latexmk.exe' -cd -f -pdf '--output-directory=cache' -latexoption=-file-line-error -latexoption=--max-print-line=10000 test1.tex



      Latexmk: This is Latexmk, John Collins, 19 Jan. 2017, version: 4.52c.
      Latexmk: Changing directory to './'
      Latexmk: making output directory 'cache'
      Latexmk: applying rule 'pdflatex'...
      Rule 'pdflatex': Rules & subrules not known to be previously run:
      pdflatex
      Rule 'pdflatex': The following rules & subrules became out-of-date:
      'pdflatex'
      ------------
      Run number 1 of rule 'pdflatex'
      ------------
      ------------
      Running 'pdflatex -file-line-error --max-print-line=10000 -recorder -output-directory="cache" "test1.tex"'
      ------------
      This is pdfTeX, Version 3.14159265-2.6-1.40.18 (MiKTeX 2.9.6400)
      entering extended mode
      (test1.tex
      LaTeX2e <2017-04-15>
      Babel <3.12> and hyphenation patterns for 76 language(s) loaded.
      (D:UserDocumentslatextexmfsinstalltexlatexmemoirmemoir.cls
      Document Class: memoir 2016/05/16 v3.7f configurable book, report, article document class
      (D:UserDocumentslatextexmfsinstalltexgenericoberdiekifpdf.sty) (D:UserDocumentslatextexmfsinstalltexlatexifetexifetex.sty (D:UserDocumentslatextexmfsinstalltexplainifetexifetex.tex)) (D:UserDocumentslatextexmfsinstalltexgenericifxetexifxetex.sty) (D:UserDocumentslatextexmfsinstalltexgenericoberdiekifluatex.sty) (D:UserDocumentslatextexmfsinstalltexlatexmemoirmem10.clo) (D:UserDocumentslatextexmfsinstalltexlatexmemoirmempatch.sty)) English YES!
      Brazil NO!
      Turkish NO!
      test1.tex:15: Undefined control sequence
      test1.tex:15: Undefined control sequence
      (D:Testcachetest1.aux) [1{D:/User/Documents/latex/texmfs/data/pdftex/config/pdftex.map}] (D:Testcachetest1.aux) )
      (see the transcript file for additional information)<D:/User/Documents/latex/texmfs/install/fonts/type1/public/amsfonts/cm/cmbx12.pfb><D:/User/Documents/latex/texmfs/install/fonts/type1/public/amsfonts/cm/cmr10.pfb>
      Output written on D:Testcachetest1.pdf (1 page, 21716 bytes).
      Transcript written on D:Testcachetest1.log.
      === TeX engine is 'pdfTeX'
      Latexmk: Log file says output to 'cache/test1.pdf'
      Latexmk: applying rule 'pdflatex'...
      Rule 'pdflatex': File changes, etc:
      Changed files, or newly in use since previous run(s):
      'cache/test1.aux'
      ------------
      Run number 2 of rule 'pdflatex'
      ------------
      ------------
      Running 'pdflatex -file-line-error --max-print-line=10000 -recorder -output-directory="cache" "test1.tex"'
      ------------
      This is pdfTeX, Version 3.14159265-2.6-1.40.18 (MiKTeX 2.9.6400)
      entering extended mode
      (test1.tex
      LaTeX2e <2017-04-15>
      Babel <3.12> and hyphenation patterns for 76 language(s) loaded.
      (D:UserDocumentslatextexmfsinstalltexlatexmemoirmemoir.cls
      Document Class: memoir 2016/05/16 v3.7f configurable book, report, article document class
      (D:UserDocumentslatextexmfsinstalltexgenericoberdiekifpdf.sty) (D:UserDocumentslatextexmfsinstalltexlatexifetexifetex.sty (D:UserDocumentslatextexmfsinstalltexplainifetexifetex.tex)) (D:UserDocumentslatextexmfsinstalltexgenericifxetexifxetex.sty) (D:UserDocumentslatextexmfsinstalltexgenericoberdiekifluatex.sty) (D:UserDocumentslatextexmfsinstalltexlatexmemoirmem10.clo) (D:UserDocumentslatextexmfsinstalltexlatexmemoirmempatch.sty)) English YES!
      Brazil NO!
      Turkish NO!
      test1.tex:15: Undefined control sequence
      test1.tex:15: Undefined control sequence
      (D:Testcachetest1.aux) [1{D:/User/Documents/latex/texmfs/data/pdftex/config/pdftex.map}] (D:Testcachetest1.aux) )
      (see the transcript file for additional information)<D:/User/Documents/latex/texmfs/install/fonts/type1/public/amsfonts/cm/cmbx12.pfb><D:/User/Documents/latex/texmfs/install/fonts/type1/public/amsfonts/cm/cmr10.pfb>
      Output written on D:Testcachetest1.pdf (1 page, 21716 bytes).
      Transcript written on D:Testcachetest1.log.
      === TeX engine is 'pdfTeX'
      Latexmk: Log file says output to 'cache/test1.pdf'
      Latexmk: Errors, in force_mode: so I tried finishing targets
      Collected error summary (may duplicate other messages):
      pdflatex: Command for 'pdflatex' gave return code 1
      Refer to 'cache/test1.log' for details
      Latexmk: Undoing directory change


      Why latex does not tell which command is not defined? Does it hurt him? Is he afraid it is too much information and I cannot handle it by myself???



      Is there some fix I can apply to latex, so it starts telling me which commands is not defined when there is some error?



      References:




      1. http://tex.stackexchange.com/questions/228936/setting-entries-of-list-of-listings-in-latex-package-listings

      2. Test if a package (or package option) is loaded









      share














      From the beginning, took me a lot of time to come with the following minimal example:



      PassOptionsToPackage{main=brazil,english,spanish,french}{babel}

      documentclass[
      10pt,
      a5paper,
      ]{memoir}

      makeatletter
      @ifpackagewith{babel}{english}{message{English YES!^^J}}{message{English NO!^^J}}
      @ifpackagewith{babel}{brazil}{message{Brazil YES!^^J}}{message{Brazil NO!^^J}}
      @ifpackagewith{babel}{turkish}{message{Turkish YES!^^J}}{message{Turkish NO!^^J}}

      @ifpackagewith{babel}{brazil}{addtocaptionsbrazil{renewcommand{lstlistingname}{Código}}}{}
      @ifpackagewith{babel}{english}{addtocaptionsenglish{renewcommand{lstlistingname}{Code}}}{}
      makeatother

      begin{document}
      chapter{Introduction}
      Thing.
      end{document}


      Runnning this example with:



      'latexmk.exe' -cd -f -pdf -interaction=nonstopmode -synctex=1 '--output-directory=cache' -latexoption=-file-line-error -latexoption=-halt-on-error -latexoption=--max-print-line=10000 test1.tex



      $ tex --version
      MiKTeX-TeX 2.9.6300 (3.14159265) (MiKTeX 2.9.6400)]

      ...
      Package tabularx [2008/07/23] emulated by memoir.
      Package titleref [2008/07/23] emulated by memoir.
      Package titling [2008/07/23] emulated by memoir.
      Package tocbibind [2008/07/23] emulated by memoir.
      Package tocloft [2008/07/23] emulated by memoir.
      Package tocvsec2 [2008/07/23] emulated by memoir.
      Package verbatim [2008/07/23] emulated by memoir.
      Package verse [2008/07/23] emulated by memoir.
      (D:UserDocumentslatextexmfsinstalltexlatexmemoirmempatch.sty
      Package: mempatch 2009/07/24 v6.0f Patches for memoir class v1.6180339
      )) English YES!
      Brazil NO!
      Turkish NO!
      test1.tex:17: Undefined control sequence
      Here is how much of TeX's memory you used:
      3506 strings out of 493314
      47031 string characters out of 3134142
      129114 words of memory out of 3000000
      7118 multiletter control sequences out of 15000+200000
      4238 words of font info for 16 fonts, out of 3000000 for 9000
      1141 hyphenation exceptions out of 8191
      24i,1n,22p,129b,62s stack positions out of 5000i,500n,10000p,200000b,50000s

      test1.tex:17: ==> Fatal error occurred, no output PDF file produced!


      Latex does not tell me on its log which command is not defined. It only says Undefined control sequence, which is very much useless.



      How can I make latex tell me exactly which command he is not finding defined?



      Only after a lot of trying, I figured out that the ifpackagewith does not check whether the package is loaded. It only checks whether there is some option on the package name queue.



      Then, a fixed version is:



      makeatletter
      @ifpackageloaded{babel}{@ifpackagewith{babel}{english}{message{English YES!^^J}}{message{English NO!^^J}}}{}
      @ifpackageloaded{babel}{@ifpackagewith{babel}{brazil}{message{Brazil YES!^^J}}{message{Brazil NO!^^J}}}{}
      @ifpackageloaded{babel}{@ifpackagewith{babel}{turkish}{message{Turkish YES!^^J}}{message{Turkish NO!^^J}}}{}

      @ifpackageloaded{babel}{@ifpackagewith{babel}{brazil}{addtocaptionsbrazil{renewcommand{lstlistingname}{Código}}}{}}{}
      @ifpackageloaded{babel}{@ifpackagewith{babel}{english}{addtocaptionsenglish{renewcommand{lstlistingname}{Code}}}{}}{}
      makeatother


      Or just load the babel package with RequirePackage{babel}.





      Now, forgetting about the fix, which is load babel or use @ifpackageloaded. Why latex does not tell me which command was undefined from the beginning???



      If I remove the -latexoption=-halt-on-error, then, latex tells me the command lstlistingname is undefined, but that is the WRONG command. The command which is undefined is addtocaptions from babel package, which was not loaded.



      See here the output from latex:



      'latexmk.exe' -cd -f -pdf -interaction=nonstopmode -synctex=1 '--output-directory=cache' -latexoption=-file-line-error -latexoption=--max-print-line=10000 test1.tex



      xmemoirmempatch.sty)) English YES!
      Brazil NO!
      Turkish NO!
      test1.tex:15: Undefined control sequence
      test1.tex:15: Undefined control sequence

      test1.tex:15: LaTeX Error: lstlistingname undefined.

      See the LaTeX manual or LaTeX Companion for explanation.
      Type H <return> for immediate help


      If I remove the lstlistingname from the input program like this:



      makeatletter
      @ifpackagewith{babel}{english}{message{English YES!^^J}}{message{English NO!^^J}}
      @ifpackagewith{babel}{brazil}{message{Brazil YES!^^J}}{message{Brazil NO!^^J}}
      @ifpackagewith{babel}{turkish}{message{Turkish YES!^^J}}{message{Turkish NO!^^J}}

      @ifpackagewith{babel}{brazil}{addtocaptionsbrazil{}}{}
      @ifpackagewith{babel}{english}{addtocaptionsenglish{}}{}
      makeatother


      And run back latex again, without the -interaction=nonstopmode and -latexoption=-halt-on-error, then, latex tells me absolutely nothing about which command is undefined!



      'latexmk.exe' -cd -f -pdf '--output-directory=cache' -latexoption=-file-line-error -latexoption=--max-print-line=10000 test1.tex



      Latexmk: This is Latexmk, John Collins, 19 Jan. 2017, version: 4.52c.
      Latexmk: Changing directory to './'
      Latexmk: making output directory 'cache'
      Latexmk: applying rule 'pdflatex'...
      Rule 'pdflatex': Rules & subrules not known to be previously run:
      pdflatex
      Rule 'pdflatex': The following rules & subrules became out-of-date:
      'pdflatex'
      ------------
      Run number 1 of rule 'pdflatex'
      ------------
      ------------
      Running 'pdflatex -file-line-error --max-print-line=10000 -recorder -output-directory="cache" "test1.tex"'
      ------------
      This is pdfTeX, Version 3.14159265-2.6-1.40.18 (MiKTeX 2.9.6400)
      entering extended mode
      (test1.tex
      LaTeX2e <2017-04-15>
      Babel <3.12> and hyphenation patterns for 76 language(s) loaded.
      (D:UserDocumentslatextexmfsinstalltexlatexmemoirmemoir.cls
      Document Class: memoir 2016/05/16 v3.7f configurable book, report, article document class
      (D:UserDocumentslatextexmfsinstalltexgenericoberdiekifpdf.sty) (D:UserDocumentslatextexmfsinstalltexlatexifetexifetex.sty (D:UserDocumentslatextexmfsinstalltexplainifetexifetex.tex)) (D:UserDocumentslatextexmfsinstalltexgenericifxetexifxetex.sty) (D:UserDocumentslatextexmfsinstalltexgenericoberdiekifluatex.sty) (D:UserDocumentslatextexmfsinstalltexlatexmemoirmem10.clo) (D:UserDocumentslatextexmfsinstalltexlatexmemoirmempatch.sty)) English YES!
      Brazil NO!
      Turkish NO!
      test1.tex:15: Undefined control sequence
      test1.tex:15: Undefined control sequence
      (D:Testcachetest1.aux) [1{D:/User/Documents/latex/texmfs/data/pdftex/config/pdftex.map}] (D:Testcachetest1.aux) )
      (see the transcript file for additional information)<D:/User/Documents/latex/texmfs/install/fonts/type1/public/amsfonts/cm/cmbx12.pfb><D:/User/Documents/latex/texmfs/install/fonts/type1/public/amsfonts/cm/cmr10.pfb>
      Output written on D:Testcachetest1.pdf (1 page, 21716 bytes).
      Transcript written on D:Testcachetest1.log.
      === TeX engine is 'pdfTeX'
      Latexmk: Log file says output to 'cache/test1.pdf'
      Latexmk: applying rule 'pdflatex'...
      Rule 'pdflatex': File changes, etc:
      Changed files, or newly in use since previous run(s):
      'cache/test1.aux'
      ------------
      Run number 2 of rule 'pdflatex'
      ------------
      ------------
      Running 'pdflatex -file-line-error --max-print-line=10000 -recorder -output-directory="cache" "test1.tex"'
      ------------
      This is pdfTeX, Version 3.14159265-2.6-1.40.18 (MiKTeX 2.9.6400)
      entering extended mode
      (test1.tex
      LaTeX2e <2017-04-15>
      Babel <3.12> and hyphenation patterns for 76 language(s) loaded.
      (D:UserDocumentslatextexmfsinstalltexlatexmemoirmemoir.cls
      Document Class: memoir 2016/05/16 v3.7f configurable book, report, article document class
      (D:UserDocumentslatextexmfsinstalltexgenericoberdiekifpdf.sty) (D:UserDocumentslatextexmfsinstalltexlatexifetexifetex.sty (D:UserDocumentslatextexmfsinstalltexplainifetexifetex.tex)) (D:UserDocumentslatextexmfsinstalltexgenericifxetexifxetex.sty) (D:UserDocumentslatextexmfsinstalltexgenericoberdiekifluatex.sty) (D:UserDocumentslatextexmfsinstalltexlatexmemoirmem10.clo) (D:UserDocumentslatextexmfsinstalltexlatexmemoirmempatch.sty)) English YES!
      Brazil NO!
      Turkish NO!
      test1.tex:15: Undefined control sequence
      test1.tex:15: Undefined control sequence
      (D:Testcachetest1.aux) [1{D:/User/Documents/latex/texmfs/data/pdftex/config/pdftex.map}] (D:Testcachetest1.aux) )
      (see the transcript file for additional information)<D:/User/Documents/latex/texmfs/install/fonts/type1/public/amsfonts/cm/cmbx12.pfb><D:/User/Documents/latex/texmfs/install/fonts/type1/public/amsfonts/cm/cmr10.pfb>
      Output written on D:Testcachetest1.pdf (1 page, 21716 bytes).
      Transcript written on D:Testcachetest1.log.
      === TeX engine is 'pdfTeX'
      Latexmk: Log file says output to 'cache/test1.pdf'
      Latexmk: Errors, in force_mode: so I tried finishing targets
      Collected error summary (may duplicate other messages):
      pdflatex: Command for 'pdflatex' gave return code 1
      Refer to 'cache/test1.log' for details
      Latexmk: Undoing directory change


      Why latex does not tell which command is not defined? Does it hurt him? Is he afraid it is too much information and I cannot handle it by myself???



      Is there some fix I can apply to latex, so it starts telling me which commands is not defined when there is some error?



      References:




      1. http://tex.stackexchange.com/questions/228936/setting-entries-of-list-of-listings-in-latex-package-listings

      2. Test if a package (or package option) is loaded







      errors pdftex miktex latexmk compilation-error





      share












      share










      share



      share










      asked 2 mins ago









      useruser

      1,28821030




      1,28821030






















          0






          active

          oldest

          votes












          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "85"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f485830%2fwhy-latex-does-not-tell-me-which-command-is-undefined%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















          draft saved

          draft discarded




















































          Thanks for contributing an answer to TeX - LaTeX Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f485830%2fwhy-latex-does-not-tell-me-which-command-is-undefined%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Paper upload error, “Upload failed: The top margin is 0.715 in on page 3, which is below the required...

          Emraan Hashmi Filmografia | Linki zewnętrzne | Menu nawigacyjneGulshan GroverGulshan...

          How can I write this formula?newline and italics added with leqWhy does widehat behave differently if I...