# create \newtcolorbox with multiple options not working

I would like to create an advanced \newtcolorbox with multiple options and an auto counter but can't get it to work...

The MWE is:

\documentclass[11pt,a4paper]{article}
\usepackage{lmodern}
\usepackage{tcolorbox}
\tcbuselibrary{skins}

\newtcolorbox {mybox4}[2][]
{
enhanced,
colback=white,
colframe=red!65!black,
enlarge top by=10mm,
overlay={%
\path[fill=blue!65,line width=.4mm] (frame.north west)--++(17mm,0)coordinate(n2)--++(0,8mm)--++(-20mm,0) arc (-90:90:-4mm)--cycle;
\node at ([shift={(5mm,4mm)}]frame.north west){\color{white}{
\textbf{\sffamily #1}}};
\path[fill=red!65!blue] ([xshift=.4mm]n2)--++(0,8mm)--++(7mm,0)--++(0,-8mm)--cycle;
\node at ([shift={(4mm,4mm)}]n2){\color{white}{\textbf{\sffamily \themycounter}}};
\node at ([shift={(18mm,4mm)}]n2){
\itshape\textbf{\sffamily #2}};
}}

\newcounter{mycounter}

%----------------------------------------------------------------------------------------
%TCOLORBOXES
%----------------------------------------------------------------------------------------

\begin{document}

\begin{mybox4}{sample}{Solution}
{step=mycounter,label=\themycounter}
This is a \textbf{tcolorbox}.\par
a lot of text here ... This is Example \ref{one}
\tcblower
some text
\end{mybox4}

\end{document}


• You're are totally misusing \newtcolorbox etc. here. If want an auto counter, defining another counter isn't necessary.
– user31729
Apr 22 '18 at 12:34

Unless using the \NewTColorBox macro, the syntax of \newtcolorbox is

\newtcolorbox[init options]{boxname}[number of args][default opt arg]{option}.

The init options can be auto counter or use counter, depending on the requests.

The optional argument should be used here in order to change the default settings of the boxed, usually being specified at the end of the options with #1.

The step option is not really necessary any longer ('citing' from tcolorbox manual, page 98):

\documentclass[11pt,a4paper]{article}
\usepackage{lmodern}
\usepackage[skins]{tcolorbox}

\newtcolorbox[auto counter]{mybox4}[3][]{
enhanced,
colback=white,
colframe=red!65!black,
enlarge top by=10mm,
overlay={%
\path[fill=blue!65,line width=.4mm] (frame.north west)--++(17mm,0)coordinate(n2)--++(0,8mm)--++(-20mm,0) arc (-90:90:-4mm)--cycle;
\node at ([shift={(5mm,4mm)}]frame.north west){\color{white}{
\textbf{\sffamily #2}}};
\path[fill=red!65!blue] ([xshift=.4mm]n2)--++(0,8mm)--++(7mm,0)--++(0,-8mm)--cycle;
\node at ([shift={(4mm,4mm)}]n2){\color{white}{\textbf{\sffamily \thetcbcounter}}};
\node at ([shift={(18mm,4mm)}]n2){
\itshape\textbf{\sffamily #3}};
},
#1
}

\newcounter{mycounter}

%----------------------------------------------------------------------------------------
%TCOLORBOXES
%----------------------------------------------------------------------------------------

\begin{document}

\begin{mybox4}[label=one]{sample}{Solution}
This is a \textbf{tcolorbox}.\par
a lot of text here ... This is Example \ref{one}
\tcblower
some text
\end{mybox4}

\end{document}


• merci @Christian Hupfer. I understand, the approach is obviously not the right one. Then how can I autonumber the boxes showing just the ongoing number but not using the label? I would then rather use the label to reference within the document like \label{}...How can I achieve that? Apr 22 '18 at 14:13
• Does your remark "...change the default settings of the boxed, usually being specified at the end of the options with #1..." related to the \newtcolorbox definitions or to any general settings in tcolorbox boxes? And is it mandatory to set this #1 argument always at the end as 'placeholder' for any options or can I put it also at the beginning? Apr 22 '18 at 14:28
• @aerioeus: you can't without screwing up the mechanism. You need label=....
– user31729
Apr 22 '18 at 14:29
• If you place #1 at the beginning you will override the settings by other ones. That's a logical error!
– user31729
Apr 22 '18 at 14:31
• Merci for the insights @Christian Hupfer ! Apr 22 '18 at 15:28