I would like to produce boxes from tcolorbox
which can take two optional arguments, but I'm not sure where to start with. Here is my current MWE :
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[most]{tcolorbox}
\usepackage{lipsum}
\def \ifempty#1{\def\temp{#1} \ifx\temp\empty }
\newtcolorbox[auto counter,number within=chapter]{definition}[1][]{title={ Définition \thetcbcounter \ifempty{#1} \else --- #1 \fi}}
\begin{document}
\begin{definition}[Matrices]
\lipsum[1]
\end{definition}
\end{document}
This is made such that every single box has a counter depending on the chapter we're in. An optional argument can be added in case I would want to give a specific name to the box. I would like to add a second optional argument to add a label (to be able to reference to it) to the box. I can add a key label=
to the color box but I'm not sure about how to add a second optional argument that would fill that key.
How can I add a second argument to the tcolorbox that would add a label=#2
to the list of arguments of the tcolorbox
?
\tcbuselibrary{xparse}
. The explanations of the multiple options are in the documentation of the xparse package.