# Expansion issue in tcolorbox

I would like to partially reproduce an example of the tcolorbox manual. The end result (in section 24.1 page 461 of the current documentation) looks like What I am interested in is to nest a \DeclareTotalTCBox with verbatim content inside of a \tcbsidebyside.

According to the documentation source code, this example is obtained with

\begin{dispExample*}{sbs,lefthand ratio=0.6}
\DeclareTotalTCBox{\myverb}{ v }{verbatim,
colframe=red!75!black,colupper=blue}{#1}

\myverb{\textbf} is a \myverb{\LaTeX} command.
\end{dispExample*}


located in doc\latex\tcolorbox\tcolorbox.doc.xparse.tex (in the tcolorbox sources).

The dispExample* environment itself is defined in tex\latex\tcolorbox\tcbdocumentation.code.tex as

\def\enddispExample{%
\endtcbwritetemp\endgroup%
\begin{tcolorbox}%
\tcb@doc@usetemplisting%
\tcblower%
\tcbusetemp%
\end{tcolorbox}%
}

\newenvironment{dispExample*}[1]{%
\tcb@layer@pushup\tcbset{docexample,#1}\begingroup\tcbwritetemp%
}{\enddispExample}


which I can't make much sense of...

My current developments define an \achtung (hello to the german friends here) command based on a \tcbsidebyside and re-use the \myverb from the documentation.

\documentclass{article}
\usepackage[most]{tcolorbox}
\usepackage{lipsum}

% Affichage de boite pour mettre du contenu en évidence
\newcommand{\achtung}[1]{
bicolor,colback=white,colbacklower=orange!5!white,top=1mm,bottom=1mm]{%
{}
}{%
#1
}
}

\DeclareTotalTCBox{\myverb}{ v }{verbatim,colframe=red!75!black,colupper=blue}{#1}

\begin{document}
\achtung{\lipsum[1] \myverb{blablabla}} % <--- remove the \myverb to make the example work.
\end{document}


The obvious reason for this to fail (that I can think of) is that the \achtung somehow swallows the argument of \myverb so some \protect or \noexpand may be of help. Using the \tcbsidebyside directly does not seem to make much difference.

• \myverb is declared to take a verbatim argument so, as usual with verbatim commands, it cannot appear in the argument to another command. Aug 26, 2021 at 11:50
• @PhelypeOleinik Yes, I saw that... But as it is shown in examples, I figured it could be reproduced somehow. Aug 26, 2021 at 12:05

Workaround with verbatimbox.

\documentclass{article}
\usepackage[most]{tcolorbox}
\usepackage{lipsum,verbatimbox}

% Affichage de boite pour mettre du contenu en évidence
\newcommand{\achtung}[1]{
bicolor,colback=white,colbacklower=orange!5!white,top=1mm,bottom=1mm]{%
{}
}{%
#1
}
}

\DeclareTotalTCBox{\myverb}{ v }{verbatim,colframe=red!75!black,colupper=blue}{#1}

\begin{document}
\begin{myverbbox}{\bla}blablabla\end{myverbbox}
\achtung{\lipsum[1] \bla} % <--- remove the \myverb to make the example work.
\end{document}