Infinite loop error when inserting more than onenewtcbinputlisting setting











up vote
2
down vote

favorite












I was attempting to generate different programming languages code snippets to highlight the different syntax in different programming languages like: Python, Matlab and C++ (more to be added later).



In the code given below, I am getting the error:



! TeX capacity exceeded, sorry [input stack size=5000].
cl@chapter ->cl@chapter
@elt {matlab}
l.73 ...code,number within=chapter]{inputcppcode}
[3]{listing options={lan...



Can you tell me how to get rid of this error to get my file to compile correctly?



Thanks.



CODE



documentclass[a4paper, 10pt, oneside, fleqn, openright]{article}
usepackage[no-math]{fontspec}

usepackage{polyglossia}
setdefaultlanguage{french}
setotherlanguages{english}

newcommand{codeimg}{$vcenter{hbox{includegraphics[height=baselineskip]{example-image-a}}}$}
newcommand{codeimgpy}{$vcenter{hbox{includegraphics[height=baselineskip]{example-image-b}}}$}
newcommand{codeimgcpp}{$vcenter{hbox{includegraphics[height=baselineskip]{example-image-c}}}$}

usepackage{calc}
usepackage[usenames,dvipsnames,svgnames,table]{xcolor}
usepackage{pdfpages,graphicx}
usepackage{mdframed}
usepackage{listings}
usepackage{filecontents}
definecolor{light-gray}{gray}{0.92}

definecolor{mainColor}{RGB}{211, 47, 47} % some dark red

renewcommandlstlistingname{Code}
lstset{
language=Python,
numbers=left,
numbersep= 7mm,
numberstyle=color{Black},
stepnumber=1,
tabsize=3,
breakatwhitespace=false,
breaklines=true,
captionpos=b,
basicstyle=color{Black}ttfamily,
commentstyle=color{LimeGreen},
keywordstyle=color{BurntOrange}bfseries,
stringstyle=color{WildStrawberry},
keywords={var, func, extends},
frame=leftline,
framesep=0mm,
xleftmargin=3mm,% marge ajouté à gauche du tableau (à configurer en dernier pour l'alignement global du tableau)
framesep=2mm, %distance texte bord du cadre (limite de la background color)
framerule=0mm,
abovecaptionskip=5mm,
aboveskip=baselineskip,
belowskip=baselineskip
}

usepackage{tcolorbox}
newcounter{data}
newcounter{result}
newcounter{pythoncode}
newcounter{cppcode}
newcounter{matlab}
tcbuselibrary{skins,breakable,listings}
newtcblisting[use counter=lstlisting]{codeblock}[2]{%
enhanced,noparskip,breakable,colback=light-gray,colframe=DarkSlateGray,opacitybacktitle=.8,%
fonttitle=bfseries,before upper={hspace*{-1em}codeimgpy~#2},%
title after break={centeringfootnotesizeitshapestrutlstlistingname~thelstlisting~--~continued},%
listing only,listing options={xleftmargin=-1mm},
after upper={centeringstrutlstlistingname~thelstlisting:~#2},
frame hidden,arc=0pt,outer arc=0pt,boxrule=0pt,frame code={draw[gray,line width=2mm] ([xshift=-0.5pt]frame.north west) -- ([xshift=-0.5pt]frame.south west);},#1}

newtcbinputlisting[use counter=matlab,list inside=matlab,number within=chapter]{inputmatlab}[3]{listing options={style=Matlab-editor},%
enhanced,noparskip,breakable,colback=light-gray,colframe=DarkSlateGray,opacitybacktitle=.8,%
fonttitle=bfseries,before upper={hspace*{-1em}codeimg~#2},%
title after break={centeringfootnotesizeitshapestrut Matlab Code~thematlab~--~continued},%
listing only,listing options={xleftmargin=-1mm,#1,style=Matlab-editor},
after upper={centeringstrut {bfseries Matlab Code~thematlab:}~#2},
frame hidden,arc=0pt,outer arc=0pt,boxrule=0pt,
%
listing file={#3},#1}

newtcbinputlisting[use counter=cppcode,list inside=cppcode,number within=chapter]{inputcppcode}[3]{listing options={language=C++},%
enhanced,noparskip,breakable,colback=light-gray,colframe=DarkSlateGray,opacitybacktitle=.8,%
fonttitle=bfseries,before upper={hspace*{-1em}codeimgcpp~#2},%
title after break={centeringfootnotesizeitshapestrut C++ Code~thecppcode~--~continued},%
listing only,listing options={xleftmargin=-1mm,#1,language=C++},
after upper={centeringstrut {bfseries C++ Code~thecppcode:}~#2},
frame hidden,arc=0pt,outer arc=0pt,boxrule=0pt,
%
listing file={#3},#1}

usepackage[numbered,framed]{matlab-prettifier}

begin{filecontents*}{sample.m}
% create a file for output
!touch testFile.txt
fid = fopen('testFile.text', 'w')
for i=1:10
fprintf(fid,'%6.2f n', i);
end
end{filecontents*}

begin{document}

begin{codeblock}{Les bases de GDScript}
var nombreDeGardes = 4 #déclaration d'une variable
nombreDeGardes = plusDeux(nombreDeGardes) #appel d'une fonction avec la variable nombreDeGardes passée en paramètre

func maFonction(): #cette ligne déclare une nouvelle fonction nommée maFonction
var variable1 = 7 #nouvelle variable dont la valeur est 7
variable2 = ['un', 'deux', 'trois'] #variable assignée à un tableau contenant trois chaines de caractères

func plusDeux(argument1):
return argument1 + 2
end{codeblock}

inputmatlab{Expansion Algorithm}{sample.m}

% https://www.programiz.com/cpp-programming/examples/add-numbers
inputcppcode{Example C++ Code}{cppcodex.cpp}

end{document}









share|improve this question


















  • 2




    I can reproduce the error in the much smaller gist.github.com/moewew/90f5a487685014daee58617d37a9a571. The error goes away if I remove the number within=chapter from the second definition ... seems the bug is hiding there.
    – moewe
    Nov 18 at 6:27






  • 2




    Come to think of it article does not have sections, so the behaviour of number within=chapter is probably undefined. If I go with something like number within=section, everything seems to be fine.
    – moewe
    Nov 18 at 6:31










  • @moewe, Thanks for your inputs. I think you found the solution. If I change the document to book, it works. Thank you!
    – Joe
    Nov 18 at 6:33






  • 1




    Indeed the same error can be reproduced with gist.github.com/moewew/…
    – moewe
    Nov 18 at 6:36















up vote
2
down vote

favorite












I was attempting to generate different programming languages code snippets to highlight the different syntax in different programming languages like: Python, Matlab and C++ (more to be added later).



In the code given below, I am getting the error:



! TeX capacity exceeded, sorry [input stack size=5000].
cl@chapter ->cl@chapter
@elt {matlab}
l.73 ...code,number within=chapter]{inputcppcode}
[3]{listing options={lan...



Can you tell me how to get rid of this error to get my file to compile correctly?



Thanks.



CODE



documentclass[a4paper, 10pt, oneside, fleqn, openright]{article}
usepackage[no-math]{fontspec}

usepackage{polyglossia}
setdefaultlanguage{french}
setotherlanguages{english}

newcommand{codeimg}{$vcenter{hbox{includegraphics[height=baselineskip]{example-image-a}}}$}
newcommand{codeimgpy}{$vcenter{hbox{includegraphics[height=baselineskip]{example-image-b}}}$}
newcommand{codeimgcpp}{$vcenter{hbox{includegraphics[height=baselineskip]{example-image-c}}}$}

usepackage{calc}
usepackage[usenames,dvipsnames,svgnames,table]{xcolor}
usepackage{pdfpages,graphicx}
usepackage{mdframed}
usepackage{listings}
usepackage{filecontents}
definecolor{light-gray}{gray}{0.92}

definecolor{mainColor}{RGB}{211, 47, 47} % some dark red

renewcommandlstlistingname{Code}
lstset{
language=Python,
numbers=left,
numbersep= 7mm,
numberstyle=color{Black},
stepnumber=1,
tabsize=3,
breakatwhitespace=false,
breaklines=true,
captionpos=b,
basicstyle=color{Black}ttfamily,
commentstyle=color{LimeGreen},
keywordstyle=color{BurntOrange}bfseries,
stringstyle=color{WildStrawberry},
keywords={var, func, extends},
frame=leftline,
framesep=0mm,
xleftmargin=3mm,% marge ajouté à gauche du tableau (à configurer en dernier pour l'alignement global du tableau)
framesep=2mm, %distance texte bord du cadre (limite de la background color)
framerule=0mm,
abovecaptionskip=5mm,
aboveskip=baselineskip,
belowskip=baselineskip
}

usepackage{tcolorbox}
newcounter{data}
newcounter{result}
newcounter{pythoncode}
newcounter{cppcode}
newcounter{matlab}
tcbuselibrary{skins,breakable,listings}
newtcblisting[use counter=lstlisting]{codeblock}[2]{%
enhanced,noparskip,breakable,colback=light-gray,colframe=DarkSlateGray,opacitybacktitle=.8,%
fonttitle=bfseries,before upper={hspace*{-1em}codeimgpy~#2},%
title after break={centeringfootnotesizeitshapestrutlstlistingname~thelstlisting~--~continued},%
listing only,listing options={xleftmargin=-1mm},
after upper={centeringstrutlstlistingname~thelstlisting:~#2},
frame hidden,arc=0pt,outer arc=0pt,boxrule=0pt,frame code={draw[gray,line width=2mm] ([xshift=-0.5pt]frame.north west) -- ([xshift=-0.5pt]frame.south west);},#1}

newtcbinputlisting[use counter=matlab,list inside=matlab,number within=chapter]{inputmatlab}[3]{listing options={style=Matlab-editor},%
enhanced,noparskip,breakable,colback=light-gray,colframe=DarkSlateGray,opacitybacktitle=.8,%
fonttitle=bfseries,before upper={hspace*{-1em}codeimg~#2},%
title after break={centeringfootnotesizeitshapestrut Matlab Code~thematlab~--~continued},%
listing only,listing options={xleftmargin=-1mm,#1,style=Matlab-editor},
after upper={centeringstrut {bfseries Matlab Code~thematlab:}~#2},
frame hidden,arc=0pt,outer arc=0pt,boxrule=0pt,
%
listing file={#3},#1}

newtcbinputlisting[use counter=cppcode,list inside=cppcode,number within=chapter]{inputcppcode}[3]{listing options={language=C++},%
enhanced,noparskip,breakable,colback=light-gray,colframe=DarkSlateGray,opacitybacktitle=.8,%
fonttitle=bfseries,before upper={hspace*{-1em}codeimgcpp~#2},%
title after break={centeringfootnotesizeitshapestrut C++ Code~thecppcode~--~continued},%
listing only,listing options={xleftmargin=-1mm,#1,language=C++},
after upper={centeringstrut {bfseries C++ Code~thecppcode:}~#2},
frame hidden,arc=0pt,outer arc=0pt,boxrule=0pt,
%
listing file={#3},#1}

usepackage[numbered,framed]{matlab-prettifier}

begin{filecontents*}{sample.m}
% create a file for output
!touch testFile.txt
fid = fopen('testFile.text', 'w')
for i=1:10
fprintf(fid,'%6.2f n', i);
end
end{filecontents*}

begin{document}

begin{codeblock}{Les bases de GDScript}
var nombreDeGardes = 4 #déclaration d'une variable
nombreDeGardes = plusDeux(nombreDeGardes) #appel d'une fonction avec la variable nombreDeGardes passée en paramètre

func maFonction(): #cette ligne déclare une nouvelle fonction nommée maFonction
var variable1 = 7 #nouvelle variable dont la valeur est 7
variable2 = ['un', 'deux', 'trois'] #variable assignée à un tableau contenant trois chaines de caractères

func plusDeux(argument1):
return argument1 + 2
end{codeblock}

inputmatlab{Expansion Algorithm}{sample.m}

% https://www.programiz.com/cpp-programming/examples/add-numbers
inputcppcode{Example C++ Code}{cppcodex.cpp}

end{document}









share|improve this question


















  • 2




    I can reproduce the error in the much smaller gist.github.com/moewew/90f5a487685014daee58617d37a9a571. The error goes away if I remove the number within=chapter from the second definition ... seems the bug is hiding there.
    – moewe
    Nov 18 at 6:27






  • 2




    Come to think of it article does not have sections, so the behaviour of number within=chapter is probably undefined. If I go with something like number within=section, everything seems to be fine.
    – moewe
    Nov 18 at 6:31










  • @moewe, Thanks for your inputs. I think you found the solution. If I change the document to book, it works. Thank you!
    – Joe
    Nov 18 at 6:33






  • 1




    Indeed the same error can be reproduced with gist.github.com/moewew/…
    – moewe
    Nov 18 at 6:36













up vote
2
down vote

favorite









up vote
2
down vote

favorite











I was attempting to generate different programming languages code snippets to highlight the different syntax in different programming languages like: Python, Matlab and C++ (more to be added later).



In the code given below, I am getting the error:



! TeX capacity exceeded, sorry [input stack size=5000].
cl@chapter ->cl@chapter
@elt {matlab}
l.73 ...code,number within=chapter]{inputcppcode}
[3]{listing options={lan...



Can you tell me how to get rid of this error to get my file to compile correctly?



Thanks.



CODE



documentclass[a4paper, 10pt, oneside, fleqn, openright]{article}
usepackage[no-math]{fontspec}

usepackage{polyglossia}
setdefaultlanguage{french}
setotherlanguages{english}

newcommand{codeimg}{$vcenter{hbox{includegraphics[height=baselineskip]{example-image-a}}}$}
newcommand{codeimgpy}{$vcenter{hbox{includegraphics[height=baselineskip]{example-image-b}}}$}
newcommand{codeimgcpp}{$vcenter{hbox{includegraphics[height=baselineskip]{example-image-c}}}$}

usepackage{calc}
usepackage[usenames,dvipsnames,svgnames,table]{xcolor}
usepackage{pdfpages,graphicx}
usepackage{mdframed}
usepackage{listings}
usepackage{filecontents}
definecolor{light-gray}{gray}{0.92}

definecolor{mainColor}{RGB}{211, 47, 47} % some dark red

renewcommandlstlistingname{Code}
lstset{
language=Python,
numbers=left,
numbersep= 7mm,
numberstyle=color{Black},
stepnumber=1,
tabsize=3,
breakatwhitespace=false,
breaklines=true,
captionpos=b,
basicstyle=color{Black}ttfamily,
commentstyle=color{LimeGreen},
keywordstyle=color{BurntOrange}bfseries,
stringstyle=color{WildStrawberry},
keywords={var, func, extends},
frame=leftline,
framesep=0mm,
xleftmargin=3mm,% marge ajouté à gauche du tableau (à configurer en dernier pour l'alignement global du tableau)
framesep=2mm, %distance texte bord du cadre (limite de la background color)
framerule=0mm,
abovecaptionskip=5mm,
aboveskip=baselineskip,
belowskip=baselineskip
}

usepackage{tcolorbox}
newcounter{data}
newcounter{result}
newcounter{pythoncode}
newcounter{cppcode}
newcounter{matlab}
tcbuselibrary{skins,breakable,listings}
newtcblisting[use counter=lstlisting]{codeblock}[2]{%
enhanced,noparskip,breakable,colback=light-gray,colframe=DarkSlateGray,opacitybacktitle=.8,%
fonttitle=bfseries,before upper={hspace*{-1em}codeimgpy~#2},%
title after break={centeringfootnotesizeitshapestrutlstlistingname~thelstlisting~--~continued},%
listing only,listing options={xleftmargin=-1mm},
after upper={centeringstrutlstlistingname~thelstlisting:~#2},
frame hidden,arc=0pt,outer arc=0pt,boxrule=0pt,frame code={draw[gray,line width=2mm] ([xshift=-0.5pt]frame.north west) -- ([xshift=-0.5pt]frame.south west);},#1}

newtcbinputlisting[use counter=matlab,list inside=matlab,number within=chapter]{inputmatlab}[3]{listing options={style=Matlab-editor},%
enhanced,noparskip,breakable,colback=light-gray,colframe=DarkSlateGray,opacitybacktitle=.8,%
fonttitle=bfseries,before upper={hspace*{-1em}codeimg~#2},%
title after break={centeringfootnotesizeitshapestrut Matlab Code~thematlab~--~continued},%
listing only,listing options={xleftmargin=-1mm,#1,style=Matlab-editor},
after upper={centeringstrut {bfseries Matlab Code~thematlab:}~#2},
frame hidden,arc=0pt,outer arc=0pt,boxrule=0pt,
%
listing file={#3},#1}

newtcbinputlisting[use counter=cppcode,list inside=cppcode,number within=chapter]{inputcppcode}[3]{listing options={language=C++},%
enhanced,noparskip,breakable,colback=light-gray,colframe=DarkSlateGray,opacitybacktitle=.8,%
fonttitle=bfseries,before upper={hspace*{-1em}codeimgcpp~#2},%
title after break={centeringfootnotesizeitshapestrut C++ Code~thecppcode~--~continued},%
listing only,listing options={xleftmargin=-1mm,#1,language=C++},
after upper={centeringstrut {bfseries C++ Code~thecppcode:}~#2},
frame hidden,arc=0pt,outer arc=0pt,boxrule=0pt,
%
listing file={#3},#1}

usepackage[numbered,framed]{matlab-prettifier}

begin{filecontents*}{sample.m}
% create a file for output
!touch testFile.txt
fid = fopen('testFile.text', 'w')
for i=1:10
fprintf(fid,'%6.2f n', i);
end
end{filecontents*}

begin{document}

begin{codeblock}{Les bases de GDScript}
var nombreDeGardes = 4 #déclaration d'une variable
nombreDeGardes = plusDeux(nombreDeGardes) #appel d'une fonction avec la variable nombreDeGardes passée en paramètre

func maFonction(): #cette ligne déclare une nouvelle fonction nommée maFonction
var variable1 = 7 #nouvelle variable dont la valeur est 7
variable2 = ['un', 'deux', 'trois'] #variable assignée à un tableau contenant trois chaines de caractères

func plusDeux(argument1):
return argument1 + 2
end{codeblock}

inputmatlab{Expansion Algorithm}{sample.m}

% https://www.programiz.com/cpp-programming/examples/add-numbers
inputcppcode{Example C++ Code}{cppcodex.cpp}

end{document}









share|improve this question













I was attempting to generate different programming languages code snippets to highlight the different syntax in different programming languages like: Python, Matlab and C++ (more to be added later).



In the code given below, I am getting the error:



! TeX capacity exceeded, sorry [input stack size=5000].
cl@chapter ->cl@chapter
@elt {matlab}
l.73 ...code,number within=chapter]{inputcppcode}
[3]{listing options={lan...



Can you tell me how to get rid of this error to get my file to compile correctly?



Thanks.



CODE



documentclass[a4paper, 10pt, oneside, fleqn, openright]{article}
usepackage[no-math]{fontspec}

usepackage{polyglossia}
setdefaultlanguage{french}
setotherlanguages{english}

newcommand{codeimg}{$vcenter{hbox{includegraphics[height=baselineskip]{example-image-a}}}$}
newcommand{codeimgpy}{$vcenter{hbox{includegraphics[height=baselineskip]{example-image-b}}}$}
newcommand{codeimgcpp}{$vcenter{hbox{includegraphics[height=baselineskip]{example-image-c}}}$}

usepackage{calc}
usepackage[usenames,dvipsnames,svgnames,table]{xcolor}
usepackage{pdfpages,graphicx}
usepackage{mdframed}
usepackage{listings}
usepackage{filecontents}
definecolor{light-gray}{gray}{0.92}

definecolor{mainColor}{RGB}{211, 47, 47} % some dark red

renewcommandlstlistingname{Code}
lstset{
language=Python,
numbers=left,
numbersep= 7mm,
numberstyle=color{Black},
stepnumber=1,
tabsize=3,
breakatwhitespace=false,
breaklines=true,
captionpos=b,
basicstyle=color{Black}ttfamily,
commentstyle=color{LimeGreen},
keywordstyle=color{BurntOrange}bfseries,
stringstyle=color{WildStrawberry},
keywords={var, func, extends},
frame=leftline,
framesep=0mm,
xleftmargin=3mm,% marge ajouté à gauche du tableau (à configurer en dernier pour l'alignement global du tableau)
framesep=2mm, %distance texte bord du cadre (limite de la background color)
framerule=0mm,
abovecaptionskip=5mm,
aboveskip=baselineskip,
belowskip=baselineskip
}

usepackage{tcolorbox}
newcounter{data}
newcounter{result}
newcounter{pythoncode}
newcounter{cppcode}
newcounter{matlab}
tcbuselibrary{skins,breakable,listings}
newtcblisting[use counter=lstlisting]{codeblock}[2]{%
enhanced,noparskip,breakable,colback=light-gray,colframe=DarkSlateGray,opacitybacktitle=.8,%
fonttitle=bfseries,before upper={hspace*{-1em}codeimgpy~#2},%
title after break={centeringfootnotesizeitshapestrutlstlistingname~thelstlisting~--~continued},%
listing only,listing options={xleftmargin=-1mm},
after upper={centeringstrutlstlistingname~thelstlisting:~#2},
frame hidden,arc=0pt,outer arc=0pt,boxrule=0pt,frame code={draw[gray,line width=2mm] ([xshift=-0.5pt]frame.north west) -- ([xshift=-0.5pt]frame.south west);},#1}

newtcbinputlisting[use counter=matlab,list inside=matlab,number within=chapter]{inputmatlab}[3]{listing options={style=Matlab-editor},%
enhanced,noparskip,breakable,colback=light-gray,colframe=DarkSlateGray,opacitybacktitle=.8,%
fonttitle=bfseries,before upper={hspace*{-1em}codeimg~#2},%
title after break={centeringfootnotesizeitshapestrut Matlab Code~thematlab~--~continued},%
listing only,listing options={xleftmargin=-1mm,#1,style=Matlab-editor},
after upper={centeringstrut {bfseries Matlab Code~thematlab:}~#2},
frame hidden,arc=0pt,outer arc=0pt,boxrule=0pt,
%
listing file={#3},#1}

newtcbinputlisting[use counter=cppcode,list inside=cppcode,number within=chapter]{inputcppcode}[3]{listing options={language=C++},%
enhanced,noparskip,breakable,colback=light-gray,colframe=DarkSlateGray,opacitybacktitle=.8,%
fonttitle=bfseries,before upper={hspace*{-1em}codeimgcpp~#2},%
title after break={centeringfootnotesizeitshapestrut C++ Code~thecppcode~--~continued},%
listing only,listing options={xleftmargin=-1mm,#1,language=C++},
after upper={centeringstrut {bfseries C++ Code~thecppcode:}~#2},
frame hidden,arc=0pt,outer arc=0pt,boxrule=0pt,
%
listing file={#3},#1}

usepackage[numbered,framed]{matlab-prettifier}

begin{filecontents*}{sample.m}
% create a file for output
!touch testFile.txt
fid = fopen('testFile.text', 'w')
for i=1:10
fprintf(fid,'%6.2f n', i);
end
end{filecontents*}

begin{document}

begin{codeblock}{Les bases de GDScript}
var nombreDeGardes = 4 #déclaration d'une variable
nombreDeGardes = plusDeux(nombreDeGardes) #appel d'une fonction avec la variable nombreDeGardes passée en paramètre

func maFonction(): #cette ligne déclare une nouvelle fonction nommée maFonction
var variable1 = 7 #nouvelle variable dont la valeur est 7
variable2 = ['un', 'deux', 'trois'] #variable assignée à un tableau contenant trois chaines de caractères

func plusDeux(argument1):
return argument1 + 2
end{codeblock}

inputmatlab{Expansion Algorithm}{sample.m}

% https://www.programiz.com/cpp-programming/examples/add-numbers
inputcppcode{Example C++ Code}{cppcodex.cpp}

end{document}






listings tcbinputlisting






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 18 at 6:15









Joe

3,50731948




3,50731948








  • 2




    I can reproduce the error in the much smaller gist.github.com/moewew/90f5a487685014daee58617d37a9a571. The error goes away if I remove the number within=chapter from the second definition ... seems the bug is hiding there.
    – moewe
    Nov 18 at 6:27






  • 2




    Come to think of it article does not have sections, so the behaviour of number within=chapter is probably undefined. If I go with something like number within=section, everything seems to be fine.
    – moewe
    Nov 18 at 6:31










  • @moewe, Thanks for your inputs. I think you found the solution. If I change the document to book, it works. Thank you!
    – Joe
    Nov 18 at 6:33






  • 1




    Indeed the same error can be reproduced with gist.github.com/moewew/…
    – moewe
    Nov 18 at 6:36














  • 2




    I can reproduce the error in the much smaller gist.github.com/moewew/90f5a487685014daee58617d37a9a571. The error goes away if I remove the number within=chapter from the second definition ... seems the bug is hiding there.
    – moewe
    Nov 18 at 6:27






  • 2




    Come to think of it article does not have sections, so the behaviour of number within=chapter is probably undefined. If I go with something like number within=section, everything seems to be fine.
    – moewe
    Nov 18 at 6:31










  • @moewe, Thanks for your inputs. I think you found the solution. If I change the document to book, it works. Thank you!
    – Joe
    Nov 18 at 6:33






  • 1




    Indeed the same error can be reproduced with gist.github.com/moewew/…
    – moewe
    Nov 18 at 6:36








2




2




I can reproduce the error in the much smaller gist.github.com/moewew/90f5a487685014daee58617d37a9a571. The error goes away if I remove the number within=chapter from the second definition ... seems the bug is hiding there.
– moewe
Nov 18 at 6:27




I can reproduce the error in the much smaller gist.github.com/moewew/90f5a487685014daee58617d37a9a571. The error goes away if I remove the number within=chapter from the second definition ... seems the bug is hiding there.
– moewe
Nov 18 at 6:27




2




2




Come to think of it article does not have sections, so the behaviour of number within=chapter is probably undefined. If I go with something like number within=section, everything seems to be fine.
– moewe
Nov 18 at 6:31




Come to think of it article does not have sections, so the behaviour of number within=chapter is probably undefined. If I go with something like number within=section, everything seems to be fine.
– moewe
Nov 18 at 6:31












@moewe, Thanks for your inputs. I think you found the solution. If I change the document to book, it works. Thank you!
– Joe
Nov 18 at 6:33




@moewe, Thanks for your inputs. I think you found the solution. If I change the document to book, it works. Thank you!
– Joe
Nov 18 at 6:33




1




1




Indeed the same error can be reproduced with gist.github.com/moewew/…
– moewe
Nov 18 at 6:36




Indeed the same error can be reproduced with gist.github.com/moewew/…
– moewe
Nov 18 at 6:36










1 Answer
1






active

oldest

votes

















up vote
5
down vote



accepted










The problematic code is the numberwithin=chapter in the definitions. The article document class does not have a counter chapter since it does not have chapters and so resetting by chapter is not really a well-defined concept.



The same issue can be reproduced with



documentclass{article}
usepackage{tcolorbox}
tcbuselibrary{listings}
newcounter{a}
newcounter{b}

newtcbinputlisting[use counter=a, number within=chapter]{inputverba}[1]{listing file={#1}}
newtcbinputlisting[use counter=b, number within=chapter]{inputverbb}[1]{listing file={#1}}

usepackage{filecontents}
begin{filecontents*}{sample.x}
Lorem
end{filecontents*}

begin{document}
inputverba{sample.x}
inputverbb{sample.x}
end{document}


and ultimately by tracing back what number within does also with



documentclass{article}
newcounter{a}
newcounter{b}

makeatletter
@addtoreset{a}{chapter}%
@addtoreset{b}{chapter}%
makeatletter

begin{document}
Lorem
end{document}


This error occurs when you want to @addtoreset a second time to a counter that does not exist.



Incidentally, @removefromreset has a bit of error checking here, according to source2e (p. 147, file m)




Even through this is internal and the programmer should know what he/she is doing we test here if counter #2 is defined.




but no such error checking is done for @addtoreset.



The solution is to either pick an existing counter to reset with, i.e. number within=section, or to use a document class with chapters, i.e. report or book.






share|improve this answer























    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',
    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%2f460547%2finfinite-loop-error-when-inserting-more-than-one-newtcbinputlisting-setting%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    5
    down vote



    accepted










    The problematic code is the numberwithin=chapter in the definitions. The article document class does not have a counter chapter since it does not have chapters and so resetting by chapter is not really a well-defined concept.



    The same issue can be reproduced with



    documentclass{article}
    usepackage{tcolorbox}
    tcbuselibrary{listings}
    newcounter{a}
    newcounter{b}

    newtcbinputlisting[use counter=a, number within=chapter]{inputverba}[1]{listing file={#1}}
    newtcbinputlisting[use counter=b, number within=chapter]{inputverbb}[1]{listing file={#1}}

    usepackage{filecontents}
    begin{filecontents*}{sample.x}
    Lorem
    end{filecontents*}

    begin{document}
    inputverba{sample.x}
    inputverbb{sample.x}
    end{document}


    and ultimately by tracing back what number within does also with



    documentclass{article}
    newcounter{a}
    newcounter{b}

    makeatletter
    @addtoreset{a}{chapter}%
    @addtoreset{b}{chapter}%
    makeatletter

    begin{document}
    Lorem
    end{document}


    This error occurs when you want to @addtoreset a second time to a counter that does not exist.



    Incidentally, @removefromreset has a bit of error checking here, according to source2e (p. 147, file m)




    Even through this is internal and the programmer should know what he/she is doing we test here if counter #2 is defined.




    but no such error checking is done for @addtoreset.



    The solution is to either pick an existing counter to reset with, i.e. number within=section, or to use a document class with chapters, i.e. report or book.






    share|improve this answer



























      up vote
      5
      down vote



      accepted










      The problematic code is the numberwithin=chapter in the definitions. The article document class does not have a counter chapter since it does not have chapters and so resetting by chapter is not really a well-defined concept.



      The same issue can be reproduced with



      documentclass{article}
      usepackage{tcolorbox}
      tcbuselibrary{listings}
      newcounter{a}
      newcounter{b}

      newtcbinputlisting[use counter=a, number within=chapter]{inputverba}[1]{listing file={#1}}
      newtcbinputlisting[use counter=b, number within=chapter]{inputverbb}[1]{listing file={#1}}

      usepackage{filecontents}
      begin{filecontents*}{sample.x}
      Lorem
      end{filecontents*}

      begin{document}
      inputverba{sample.x}
      inputverbb{sample.x}
      end{document}


      and ultimately by tracing back what number within does also with



      documentclass{article}
      newcounter{a}
      newcounter{b}

      makeatletter
      @addtoreset{a}{chapter}%
      @addtoreset{b}{chapter}%
      makeatletter

      begin{document}
      Lorem
      end{document}


      This error occurs when you want to @addtoreset a second time to a counter that does not exist.



      Incidentally, @removefromreset has a bit of error checking here, according to source2e (p. 147, file m)




      Even through this is internal and the programmer should know what he/she is doing we test here if counter #2 is defined.




      but no such error checking is done for @addtoreset.



      The solution is to either pick an existing counter to reset with, i.e. number within=section, or to use a document class with chapters, i.e. report or book.






      share|improve this answer

























        up vote
        5
        down vote



        accepted







        up vote
        5
        down vote



        accepted






        The problematic code is the numberwithin=chapter in the definitions. The article document class does not have a counter chapter since it does not have chapters and so resetting by chapter is not really a well-defined concept.



        The same issue can be reproduced with



        documentclass{article}
        usepackage{tcolorbox}
        tcbuselibrary{listings}
        newcounter{a}
        newcounter{b}

        newtcbinputlisting[use counter=a, number within=chapter]{inputverba}[1]{listing file={#1}}
        newtcbinputlisting[use counter=b, number within=chapter]{inputverbb}[1]{listing file={#1}}

        usepackage{filecontents}
        begin{filecontents*}{sample.x}
        Lorem
        end{filecontents*}

        begin{document}
        inputverba{sample.x}
        inputverbb{sample.x}
        end{document}


        and ultimately by tracing back what number within does also with



        documentclass{article}
        newcounter{a}
        newcounter{b}

        makeatletter
        @addtoreset{a}{chapter}%
        @addtoreset{b}{chapter}%
        makeatletter

        begin{document}
        Lorem
        end{document}


        This error occurs when you want to @addtoreset a second time to a counter that does not exist.



        Incidentally, @removefromreset has a bit of error checking here, according to source2e (p. 147, file m)




        Even through this is internal and the programmer should know what he/she is doing we test here if counter #2 is defined.




        but no such error checking is done for @addtoreset.



        The solution is to either pick an existing counter to reset with, i.e. number within=section, or to use a document class with chapters, i.e. report or book.






        share|improve this answer














        The problematic code is the numberwithin=chapter in the definitions. The article document class does not have a counter chapter since it does not have chapters and so resetting by chapter is not really a well-defined concept.



        The same issue can be reproduced with



        documentclass{article}
        usepackage{tcolorbox}
        tcbuselibrary{listings}
        newcounter{a}
        newcounter{b}

        newtcbinputlisting[use counter=a, number within=chapter]{inputverba}[1]{listing file={#1}}
        newtcbinputlisting[use counter=b, number within=chapter]{inputverbb}[1]{listing file={#1}}

        usepackage{filecontents}
        begin{filecontents*}{sample.x}
        Lorem
        end{filecontents*}

        begin{document}
        inputverba{sample.x}
        inputverbb{sample.x}
        end{document}


        and ultimately by tracing back what number within does also with



        documentclass{article}
        newcounter{a}
        newcounter{b}

        makeatletter
        @addtoreset{a}{chapter}%
        @addtoreset{b}{chapter}%
        makeatletter

        begin{document}
        Lorem
        end{document}


        This error occurs when you want to @addtoreset a second time to a counter that does not exist.



        Incidentally, @removefromreset has a bit of error checking here, according to source2e (p. 147, file m)




        Even through this is internal and the programmer should know what he/she is doing we test here if counter #2 is defined.




        but no such error checking is done for @addtoreset.



        The solution is to either pick an existing counter to reset with, i.e. number within=section, or to use a document class with chapters, i.e. report or book.







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Nov 18 at 6:55

























        answered Nov 18 at 6:42









        moewe

        83.3k8107320




        83.3k8107320






























             

            draft saved


            draft discarded



















































             


            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f460547%2finfinite-loop-error-when-inserting-more-than-one-newtcbinputlisting-setting%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

            Plaza Victoria

            Puebla de Zaragoza

            Musa