I have a custom environment for code like this (it is a modified version of the code here):
\documentclass[12pt,a4paper]{report}
\usepackage[many]{tcolorbox}
\tcbuselibrary{minted,skins}
\definecolor{Gray}{gray}{0.9}
\newtcblisting{code}[2][python]{
colback=Gray,
listing engine=minted,
minted language=#1,
listing only,
skin=tile,
width=#2\textwidth,
}
\BeforeBeginEnvironment{code}{\centering}
\AfterEndEnvironment{code}{}
\begin{document}
\begin{code}[python]{0.8}
print("This is some sample code")
\end{code}
\end{document}
What I want is to be able to optionally specify the programming language used and the width of the box that holds the code, in a way that the default values for each are:
Programming language:
python
Width:
0.8\textwidth
(note: what I want to be able to change is the0.8
, not the\textwidth
)
So far, I have only managed to have the programming language as optional, with the required default value, but I have not managed to be able to make the width optional as well.
Is there any way to have multiple optional arguments with multiple default values?