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}
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.
    – user194703
    Commented Apr 5, 2020 at 3:29

1 Answer 1

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.

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .