0

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.
<to be read again> 
                   \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. –  Apr 05 '20 at 03:29

1 Answers1

1

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}

enter image description here

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.