# DeclareTCBListing and write percent a file

I don't understand why the environment mytcblisting fails when writing the percentage symbol, I tried with verbatim ignore percent but it didn't work, I get the error:

! Missing \endcsname inserted.
\protect
l.23 T
his is my 5\percent\ text
?


I'm using TeXLive 2020 and this is my sample file:

\documentclass[10pt]{article}
\usepackage{tcolorbox}
\tcbuselibrary{listings,breakable,skins,xparse}
\DeclareTCBListing{mytcblisting}{ O{} }
{%
bottom=-1mm, boxrule=0.4pt, boxsep=0mm, top=-1mm, arc=0mm,%
title~style={draw=none,fill=none}, enhanced, autoparskip, freelance,#1%
}
\begin{document}
% OK, from doc pag 130
\def\percent{\%}
\begin{tcblisting}{title=Normal}
%\begin{center}\bfseries
This is my 5\percent\ text
and this is my 10\% text.
%\end{center}
\end{tcblisting}

% Error

\begin{mytcblisting}
%\begin{center}\bfseries
This is my 5\percent\ text
and this is my 10\% text.
%\end{center}
\end{mytcblisting}

\end{document}

• Your own listing already fails without any sorts of percent signs. And if you replace title~style by title style, i.e. without ~, it works fine.
– user194703
Apr 5, 2020 at 3:29

Your own listing already fails without any sorts of percent signs. And if you replace title~style by title style, i.e. without ~, it works fine.

\documentclass[10pt]{article}
\usepackage{tcolorbox}
\tcbuselibrary{listings,breakable,skins,xparse}
\DeclareTCBListing{mytcblisting}{ O{} }
{%
bottom=-1mm, boxrule=0.4pt, boxsep=0mm, top=-1mm, arc=0mm,%
title style={draw=none,fill=none},
enhanced, autoparskip,
freelance,#1%
}
\begin{document}
% OK, from doc pag 130
\def\percent{\%}
\begin{tcblisting}{title=Normal}
%\begin{center}\bfseries
This is my 5\percent\ text
and this is my 10\% text.
%\end{center}
\end{tcblisting}

% No rror

\begin{mytcblisting}
%\begin{center}\bfseries
This is my 5\percent\ text
and this is my 10\% text.
%\end{center}
\end{mytcblisting}

\end{document}


Of course, I assume that this is not the final design of your box. And I think I know why one might think one has to add a ~. Well, this is a long and unfortunate discussion, no need to fuel it further, especially during these crazy days.

• It's just an outline :) ...the style comes later, but I want the code to work first :( Apr 5, 2020 at 3:39
• But, if it solves the question :) Apr 5, 2020 at 3:40