I have defined a python environment in my document using tcolorbox. I would like to add a title to the listing. However, the compiler complains about adding the following to pythoncode environment:
\begin{pythoncode}[colback=red!5!white,colframe=red!75!black,title=My nice heading]
When I remove the above options and only use \begin{pythoncode}[], the code compiles successfully. In below is a MWE about this problem.
\documentclass{book}
\usepackage[left=1.00in, right=1.00in, top=1.00in, bottom=1.00in]{geometry}
\usepackage{amsmath}
\usepackage[pdftex]{graphicx, color}
\usepackage{hyperref}
\hypersetup{ %
pdfborder = {0 0 0},
colorlinks=true,
}
\usepackage[T1]{fontenc}
\usepackage{tcolorbox}
\tcbuselibrary{minted,skins,breakable}
\newtcblisting{pythoncode}[1][]{
listing engine=minted,
breakable,
colback=bg,
colframe=black!70,
listing only,
minted style=colorful,
minted language=python,
minted options={linenos=true,numbersep=3mm,texcl=true,#1},
left=5mm,enhanced,
overlay={\begin{tcbclipinterior}\fill[black!25] (frame.south west)
rectangle ([xshift=5mm]frame.north west);\end{tcbclipinterior}}
}
\definecolor{bg}{rgb}{0.85,0.85,0.85}
\begin{document}
\section{Python example}
\begin{pythoncode}[colback=red!5!white,colframe=red!75!black,title=My nice heading]
# indent your Python code to put into an email
import glob
# glob supports Unix style pathname extensions
python_files = glob.glob('*.py')
for file_name in sorted(python_files):
print ' ------' + file_name
with open(file_name) as f:
for line in f:
print ' ' + line.rstrip()
print
\end{pythoncode}
\end{document}
Could someone shed light on this problem?
bgcolor. – shashashamti2008 May 08 '14 at 22:20[colback=red!5!white,colframe=red!75!black....which changes the background colour tored!5!whitewhich is nearly white. It does not remove the background color – cmhughes May 08 '14 at 22:38minted optionsand one totcolorboxat the same time? – shashashamti2008 May 08 '14 at 23:12xparse) – cmhughes May 09 '14 at 02:50