2

MWE:

\documentclass{article}
\usepackage{listings, tcolorbox}
\tcbuselibrary{listings,skins,theorems,xparse}

\newenvironment{mybox}
  {\begin{tcolorbox}\begin{lstlisting}}
  {\end{lstlisting}\end{tcolorbox}}

\begin{document}

\begin{tcolorbox}\begin{lstlisting}
This is my \LaTeX\ box.
\end{lstlisting}\end{tcolorbox}

% \begin{mybox}
% This is my \LaTeX\ box too!
% \end{mybox}

\end{document}

My environment doesn't work. Maybe I need a primer on \newenvironment?

1

Here is an example of the tcolorbox manual section 4.13 p 302:

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

\newtcblisting{mybox}[2][]{%
colback=red!5!white,
colframe=red!75!black,
fonttitle=\bfseries,
title=#2,#1}

\begin{document}

\begin{mybox}[listing only]{Listing Box}
This is my \LaTeX\ box.
\end{mybox}
\bigskip

\begin{mybox}[listing side text]{Listing Box}
This is my \LaTeX\ box.
\end{mybox}

\end{document}

Output:

newtcblisting

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy