4

The following codes are taken from source and output side-by-side

\documentclass{article}
\usepackage[skins,listings]{tcolorbox}

\newtcblisting{exampleB}[2][]{%
  colframe=red!50!yellow!50!black,
  colback=white,
  coltitle=red!50!yellow!3!white,
  bicolor,colbacklower=red!50!yellow!5!white,
  fonttitle=\sffamily\bfseries,
  sidebyside,text and listing,
  title=#2,#1}

\newenvironment{cExample}{\begin{exampleB}[lefthand width=3.5cm,text outside listing,  colback=red!50!yellow!5!white,top=0mm,bottom=0mm,left=0mm,right=0mm,
  arc=0mm,boxrule=1pt,watermark text=Source,
  watermark color=yellow!75!red!30!white]{}}{\end{exampleB}}

\let\baExample\exampleB
\let\eaExample\endexampleB
\newenvironment{aExample}   {\baExample[lefthand width=3.5cm,text outside listing,
  colback=red!50!yellow!5!white,top=0mm,bottom=0mm,left=0mm,right=0mm,
  arc=0mm,boxrule=1pt,watermark text=Source,
  watermark color=yellow!75!red!30!white]{}}    {\eaExample}

\begin{document}

\begin{aExample}
\begin{tikzpicture}
\path[fill=yellow!50!white] (0,0) circle (11mm);
\path[fill=white] (0,0) circle (9mm);
\foreach \w/\c in {90/red,210/green,330/blue}
{\path[shading=ball,ball color=\c] (\w:1cm) circle (7mm);}
\end{tikzpicture}
\end{aExample}

%\begin{cExample}
\begin{tikzpicture}
\path[fill=yellow!50!white] (0,0) circle (11mm);
\path[fill=white] (0,0) circle (9mm);
\foreach \w/\c in {90/red,210/green,330/blue}
{\path[shading=ball,ball color=\c] (\w:1cm) circle (7mm);}
\end{tikzpicture}
%\end{cExample}

\end{document}

The environment aExample works, but the environmentcExample (uncomment the begin/end env lines) will throw an error

Runaway argument?

! File ended while scanning use of \next.

<inserted text>

             \par 

1 Answer 1

4

The environment requires verbatim mode. Using \begin{exampleB} and \end{exampleB} confuses the parser. Just use \exampleB and \endexampleB (which is essentially what you did in aExample.

\documentclass{article}
\usepackage[skins,listings]{tcolorbox}

\newtcblisting{exampleB}[2][]{%
  colframe=red!50!yellow!50!black,
  colback=white,
  coltitle=red!50!yellow!3!white,
  bicolor,colbacklower=red!50!yellow!5!white,
  fonttitle=\sffamily\bfseries,
  sidebyside,text and listing,
  title=#2,#1}

\newenvironment{cExample}{%
  \exampleB[
    lefthand width=3.5cm,
    text outside listing,
    colback=red!50!yellow!5!white,
    top=0mm,
    bottom=0mm,
    left=0mm,
    right=0mm,
    arc=0mm,
    boxrule=1pt,
    watermark text=Source,
    watermark color=yellow!75!red!30!white
  ]{}%
}{\endexampleB}

\begin{document}

\begin{cExample}
\begin{tikzpicture}
\path[fill=yellow!50!white] (0,0) circle (11mm);
\path[fill=white] (0,0) circle (9mm);
\foreach \w/\c in {90/red,210/green,330/blue}
{\path[shading=ball,ball color=\c] (\w:1cm) circle (7mm);}
\end{tikzpicture}
\end{cExample}

\end{document}

enter image description here

You must log in to answer this question.

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