davidcarlisle / dpctex

Assorted TeX packages
94 stars 30 forks source link

numdef seems to fail with \listoffigures #1

Open cbhushan opened 8 years ago

cbhushan commented 8 years ago

numdef has been life savior for me for a while (Found it here). Thanks a lot for it.

Unfortunately, I am facing difficulty to make \listoffigures work properly with it. I am using pdflatex on Linux. Here is a simple code to reproduce the error:

\documentclass{article}
\usepackage{amsmath, amssymb, amsfonts}

\usepackage{numdef} 
\num\newcommand{\B0}[0]{B$_{\text{0}}$}

\begin{document}
\listoffigures % works fine without this line

Hello world! This is \B0.

\begin{figure}
  \centering
  Here goes the fig..
  \caption{Hello again! This is \B0-caption.}
\end{figure}

\end{document}

Here is the error:

$ pdflatex test.tex 
This is pdfTeX, Version 3.1415926-2.5-1.40.14 (TeX Live 2013/Debian)
 restricted \write18 enabled.
entering extended mode
(./test.tex
LaTeX2e <2011/06/27>
Babel <3.9h> and hyphenation patterns for 2 languages loaded.
(/usr/share/texlive/texmf-dist/tex/latex/base/article.cls
Document Class: article 2007/10/19 v1.4h Standard LaTeX document class
(/usr/share/texlive/texmf-dist/tex/latex/base/size10.clo))
(/usr/share/texlive/texmf-dist/tex/latex/amsmath/amsmath.sty
For additional information on amsmath, use the `?' option.
(/usr/share/texlive/texmf-dist/tex/latex/amsmath/amstext.sty
(/usr/share/texlive/texmf-dist/tex/latex/amsmath/amsgen.sty))
(/usr/share/texlive/texmf-dist/tex/latex/amsmath/amsbsy.sty)
(/usr/share/texlive/texmf-dist/tex/latex/amsmath/amsopn.sty))
(/usr/share/texlive/texmf-dist/tex/latex/amsfonts/amssymb.sty
(/usr/share/texlive/texmf-dist/tex/latex/amsfonts/amsfonts.sty))
(/home/cbhushan/texmf/tex/latex/local/numdef.sty) (./test.aux) (./test.lof
(./test.lof (./test.lof (./test.lof (./test.lof (./test.lof (./test.lof
(./test.lof (./test.lof (./test.lof (./test.lof (./test.lof (./test.lof
(./test.lof
! TeX capacity exceeded, sorry [text input levels=15].
\@filef@und ->test.lof 

l.1 ...B$_{\text {0}}$\num@count = 0-caption.}}{1}

!  ==> Fatal error occurred, no output PDF file produced!
Transcript written on test.log.

And here is the content of test.lof (test.log is similar to the output above).

\contentsline {figure}{\numberline {1}{\ignorespaces Hello again! This is \edef \B {\B }\futurelet \@tempa \let \afterassignment \let 0=0B$_{\text {0}}$\num@count = \afterassignment \let 0=0B$_{\text {0}}$\num@count = \afterassignment \let 0=0B$_{\text {0}}$\num@count = 0-caption.}}{1}
davidcarlisle commented 8 years ago

Thanks for your interest, I guess you are the first person to contact me about that in the 30 years since I wrote it:-)

This is just the usual latex "feature" of fragile commands in moving arguments need \protect so if you delete the .lof file and then edit your file to have

\caption{Hello again! This is \protect\B0-caption}

it should work fine,

David

On 10 January 2016 at 22:38, C Bhushan notifications@github.com wrote:

numdef has been life savior for me for a while (Found it here http://texstackexchangecom/a/66695) Thanks a lot for it

Unfortunately, I am facing difficulty to make \listoffigures work properly with it I am using pdflatex on Linux Here is a simple code to reproduce the error:

\documentclass{article} \usepackage{amsmath, amssymb, amsfonts}

\usepackage{numdef} \num\newcommand{\B0}[0]{B$_{\text{0}}$}

\begin{document} \listoffigures % works fine without this line

Hello world! This is \B0

\begin{figure} \centering Here goes the fig \caption{Hello again! This is \B0-caption} \end{figure}

\end{document}

Here is the error:

$ pdflatex testtex This is pdfTeX, Version 31415926-25-14014 (TeX Live 2013/Debian) restricted \write18 enabled entering extended mode (/testtex LaTeX2e <2011/06/27> Babel <39h> and hyphenation patterns for 2 languages loaded (/usr/share/texlive/texmf-dist/tex/latex/base/articlecls Document Class: article 2007/10/19 v14h Standard LaTeX document class (/usr/share/texlive/texmf-dist/tex/latex/base/size10clo)) (/usr/share/texlive/texmf-dist/tex/latex/amsmath/amsmathsty For additional information on amsmath, use the `?' option (/usr/share/texlive/texmf-dist/tex/latex/amsmath/amstextsty (/usr/share/texlive/texmf-dist/tex/latex/amsmath/amsgensty)) (/usr/share/texlive/texmf-dist/tex/latex/amsmath/amsbsysty) (/usr/share/texlive/texmf-dist/tex/latex/amsmath/amsopnsty)) (/usr/share/texlive/texmf-dist/tex/latex/amsfonts/amssymbsty (/usr/share/texlive/texmf-dist/tex/latex/amsfonts/amsfontssty)) (/home/cbhushan/texmf/tex/latex/local/numdefsty) (/testaux) (/testlof (/testlof (/testlof (/testlof (/testlof (/testlof (/testlof (/testlof (/testlof (/testlof (/testlof (/testlof (/testlof (/testlof ! TeX capacity exceeded, sorry [text input levels=15] \@filef@und ->testlof

l1 B$_{\text {0}}$\num@count = 0-caption}}{1}

! ==> Fatal error occurred, no output PDF file produced! Transcript written on testlog

And here is the content of testlof (testlog is similar to the output above)

\contentsline {figure}{\numberline {1}{\ignorespaces Hello again! This is \edef \B {\B }\futurelet \@tempa \let \afterassignment \let 0=0B${\text {0}}$\num@count = \afterassignment \let 0=0B${\text {0}}$\num@count = \afterassignment \let 0=0B$_{\text {0}}$\num@count = 0-caption}}{1}

— Reply to this email directly or view it on GitHub https://github.com/davidcarlisle/dpctex/issues/1.

http://dpcarlisle.blogspot.com/