I'm trying to make a reference to this environment, but it comes out with the double question mark. Is there anything missing from this environment for me to be able to refer to it?
\documentclass{memoir}
\usepackage[utf8]{inputenc}
\usepackage{xcolor}
\usepackage[most]{tcolorbox}
\newcounter{testexample}
\usepackage{xparse}
\def\exampletext{Eksempel} % If English
\NewDocumentEnvironment{testexample}{ O{} }
{
\colorlet{colexam}{red!55!black} % Global example color
\newtcolorbox[use counter=testexample]{testexamplebox}{%
% Example Frame Start
empty,% Empty previously set parameters
title={\exampletext\ \thetcbcounter: #1},% use \thetcbcounter to access the
testexample counter text
% Attaching a box requires an overlay
attach boxed title to top left,
% Ensures proper line breaking in longer titles
minipage boxed title,
% (boxed title style requires an overlay)
boxed title style={empty,size=minimal,toprule=0pt,top=4pt,left=3mm,overlay=
{}},
coltitle=colexam,fonttitle=\bfseries, before=\par\medskip\noindent,parbox=false,boxsep=0pt,left=3mm,right=0mm,top=2pt,breakable,pad at break=0mm,
before upper=\csname @totalleftmargin\endcsname0pt, % Use instead of
parbox=true. %This ensures parskip is inherited by box.
% Handles box when it exists on one page only
overlay unbroken={\draw[colexam,line width=.5pt] ([xshift=-0pt]title.north
west) -- ([xshift=-0pt]frame.south west); },
% Handles multipage box: first page
overlay first={\draw[colexam,line width=.5pt] ([xshift=-0pt]title.north west)
-- ([xshift=-0pt]frame.south west); },
% Handles multipage box: middle page
overlay middle={\draw[colexam,line width=.5pt] ([xshift=-0pt]frame.north west)
-- ([xshift=-0pt]frame.south west); },
% Handles multipage box: last page
overlay last={\draw[colexam,line width=.5pt] ([xshift=-0pt]frame.north west) -
- ([xshift=-0pt]frame.south west); },%
}
\begin{testexamplebox}}
{\end{testexamplebox}\endlist}
\begin{document}
\begin{testexample}[Test]
\label{ex:1}
Here is an example
\end{testexample}
Look at example \ref{ex:1}
\end{document}
tcolorbox
and a reference to it? Edit: that said, you need a label, see section 4.21 in thetcolorbox
manual.\newtcolorbox
inside a\NewDocumentCommand
? In any case, thelabel=foo
option should work\NewDocumentEnvironment
, but my question remains the same