# Compile error “Missing \endcsname inserted.” with code and tcolorbox

I get this error when trying to compile into pdf my document. It is important to know that my project did compile a month ago without errors: I opened it today and it fails without being modified at all. I include a MWE.

\documentclass[a4paper, oneside, 10pt]{book}
\usepackage[english]{babel}
\usepackage[pdftex]{graphicx}
\usepackage{eso-pic}
\usepackage{listings}
\usepackage{xcolor}
\usepackage[utf8]{inputenc}
\usepackage{listings}
\usepackage[breakable,listings]{tcolorbox}
\usepackage{setspace}
\usepackage{booktabs}
\usepackage{indentfirst}
\usepackage{epigraph}
\usepackage{hyperref}
\usepackage[toc]{glossaries}
\usepackage{fancyhdr}
\usepackage{varioref}

\definecolor{base03}{HTML}{002B36}
\definecolor{base02}{HTML}{073642}
\definecolor{base01}{HTML}{586E75}
\definecolor{base00}{HTML}{657B83}
\definecolor{base0}{HTML}{839496}
\definecolor{base1}{HTML}{93A1A1}
\definecolor{base2}{HTML}{EEE8D5}
\definecolor{base3}{HTML}{FDF6E3}
\definecolor{yellow}{HTML}{B58900}
\definecolor{orange}{HTML}{CB4B16}
\definecolor{red}{HTML}{DC322F}
\definecolor{magenta}{HTML}{D33682}
\definecolor{violet}{HTML}{6C71C4}
\definecolor{blue}{HTML}{268BD2}
\definecolor{cyan}{HTML}{2AA198}
\definecolor{green}{HTML}{859900}

\lstdefinelanguage{JavaScript}{
keywords={
typeof,new,true,false,catch,function,return,null,catch,switch,var,if,in,
while,do,else,case,break, try},
ndkeywords={class,export,boolean,throw,implements,import,this},
sensitive=false,
comment=[l]{//},
morecomment=[s]{/*}{*/},
morestring=[b]',
morestring=[b]"
}

\newtcblisting[auto counter,list inside=codeList,number within=section]{codeBox}[1]{
breakable,
bottomrule at break=0pt,
toprule at break=0pt,
title=Code~\thetcbcounter: #1,
colback=base2,
colframe=base02,
listing only,
listing options={
language=JavaScript,
keywordstyle=\color{yellow},
stringstyle=\color{blue},
basicstyle=\ttfamily\footnotesize\color{base01},
identifierstyle=\color{base02},
ndkeywordstyle=\color{red}\bfseries,
breaklines=true,
breakautoindent=true,
breakindent=30pt,
escapeinside={~}{~},
showstringspaces=false,
captionpos=b
},
list entry=\thetcbcounter~~#1,
before=\bigskip\noindent,
fontupper=\singlespacing\vskip -1.5em
}

\begin{document}

\begin{codeBox}
code here
the end command will produce the error when compiling
\end{codeBox}

\end{document}


When compiling, I get:

! Missing \endcsname inserted.
<to be read again>
\tcb@lsttp@tcolorbox
l.85 \end{codeBox}

• If I remove the first optional argument to \newtcblisting there is no problem. – egreg Apr 28 '14 at 17:07
• Do you talk about auto counter? – b3by Apr 28 '14 at 17:10
• Ok, I get it. list inside is the problem. Thank you! – b3by Apr 28 '14 at 17:16
• @b3by Could you post a self-answer? – Joseph Wright May 6 '14 at 7:52
• @JosephWright unfortunately I can't, I need 15 points at least. – b3by May 7 '14 at 9:43

The very same MWE doesn't compile (with the same error message) with tcolorbox 3.00 for me. I'm not an expert on this, but I think this might be a bug in the tcolorbox package. It works fine for me if I apply this patch to the tcolorbox.sty file:

diff --git a/texmf/tex/latex/tcolorbox/tcolorbox.sty b/texmf/tex/latex/tcolorbox/tcolorbox.sty
index 4555182..c8ea54d 100644
--- a/texmf/tex/latex/tcolorbox/tcolorbox.sty
+++ b/texmf/tex/latex/tcolorbox/tcolorbox.sty
@@ -1186,7 +1186,7 @@
\else%
\csedef{tcb@lstof@#2}{\kvtcb@new@listof}%
\csedef{tcb@lsttp@#2}{\kvtcb@new@listtype}%
-    \appto\tcb@new@colopt{,add to list={\csname tcb@lstof@\kvtcb@savedelimiter\endcsname}{\csname tcb@lsttp@\kvtcb@savedelimiter\endcsname}}%
+    \appto\tcb@new@colopt{,add to list={\csname tcb@lstof@#2\endcsname}{\csname tcb@lsttp@#2\endcsname}}%
\fi%
\kvtcb@init@hook%
}%

• If you think you've got a good patch, you should probably contact the author of tcolorbox directly about it. – jub0bs May 15 '14 at 16:01
• I've seen the problem now. This patch is correct! The bug-fixed version 3.03 (2014/05/16) is on its way to CTAN. – Thomas F. Sturm May 16 '14 at 14:19

Ok, I got it. If the codeBox is defined as:

\newtcblisting[auto counter,list inside=codeList,number within=section]{codeBox}[1]{ ... }


my boxes are correctly compiled. There is a drawback, that is, codes will not be listed in the list of listings.