[Tex/LaTex] Positioning of tcolorbox in list environment

itemizepositioningtcolorbox

For emphasis some key features in my texts I use tcolorbox, which is pushed to the outside border. in normal text this work fine but in itemize environment it is pushed more outside then I desire. Apparently its moving to right/left border accordingly to itemize leftmargin and not of text margin:

\documentclass[12pt]{memoir}
    \usepackage{calc,lipsum}
    \usepackage[T1]{fontenc}
%---------------------------------------------------------------%
    \setstocksize{297mm}{210mm}
    \settrimmedsize{\stockheight}{\stockwidth}{*}
    \settypeblocksize{247mm}{120mm}{*}
    \setulmargins{25mm}{*}{1}
    \setlrmarginsandblock{30mm}{60mm}{*}
\checkandfixthelayout
    \newlength{\marginwidth}
    \setlength{\marginparwidth}{45mm}
    \setlength{\marginparsep}{5mm}
    \setlength{\marginwidth}{\marginparsep+\marginparwidth}
    \setlength{\headwidth}{\textwidth+\marginwidth}
%---------------------------------------------------------------%
    \usepackage[many]{tcolorbox}
    \usetikzlibrary{shapes}
\newtcolorbox{example}[1]{%
    enhanced,
    colback=teal!10, frame hidden, colframe=teal,
    borderline={1pt}{0pt}{teal, sharp corners},
    top=1mm, bottom=1mm, left=1mm, right=1mm,
        check odd page,
            grow to left by =-\marginwidth,
            grow to right by=\marginwidth,
        toggle enlargement=evenpage,
    enlarge top by=5mm,
    arc=0mm,
    width=\textwidth,
    fontupper=\small\sffamily,
    overlay unbroken and first={%
        \node[trapezium,trapezium left angle=90, trapezium right angle=60,
              fill=teal!60!black,inner xsep=2mm,inner ysep=2pt,yshift=-1pt,
              anchor=bottom left corner,
              text=white,font=\small\bfseries\sffamily]
        at (frame.north west)
            {#1};},}

    \begin{document}
\lipsum[2]
    \begin{example}{<title>}
some text
    \end{example}
\lipsum[2]
\begin{itemize}
    \item   the first item text
    \begin{example}{<title>}
Key features of item \dots
    \end{example}
    \item   the second item text
\end{itemize}
    \end{document}

Question: How to convince tcolorbox to be positioned in the itemize environment the same as in normal text ?

enter image description here

Best Answer

You can adjust the settings with \@totalleftmargin:

\documentclass[12pt]{memoir}
    \usepackage{calc,lipsum}
    \usepackage[T1]{fontenc}
%---------------------------------------------------------------%
    \setstocksize{297mm}{210mm}
    \settrimmedsize{\stockheight}{\stockwidth}{*}
    \settypeblocksize{247mm}{120mm}{*}
    \setulmargins{25mm}{*}{1}
    \setlrmarginsandblock{30mm}{60mm}{*}
\checkandfixthelayout
    \newlength{\marginwidth}
    \setlength{\marginparwidth}{45mm}
    \setlength{\marginparsep}{5mm}
    \setlength{\marginwidth}{\marginparsep+\marginparwidth}
    \setlength{\headwidth}{\textwidth+\marginwidth}
%---------------------------------------------------------------%
    \usepackage[many]{tcolorbox}
    \usetikzlibrary{shapes}
    \makeatletter
\newtcolorbox{example}[1]{%
    enhanced,
    colback=teal!10, frame hidden, colframe=teal,
    borderline={1pt}{0pt}{teal, sharp corners},
    top=1mm, bottom=1mm, left=1mm, right=1mm,
        check odd page,
            grow to left by =\dimexpr-\marginwidth+\@totalleftmargin
            ,
            grow to right by=\dimexpr\marginwidth+\@totalleftmargin,
        toggle enlargement=evenpage,
    enlarge top by=5mm,
    arc=0mm,
    width=\textwidth,
    fontupper=\small\sffamily,
    overlay unbroken and first={%
        \node[trapezium,trapezium left angle=90, trapezium right angle=60,
              fill=teal!60!black,inner xsep=2mm,inner ysep=2pt,yshift=-1pt,
              anchor=bottom left corner,
              text=white,font=\small\bfseries\sffamily]
        at (frame.north west)
            {#1};},}

    \begin{document}
\lipsum[2]
    \begin{example}{<title>}
some text
    \end{example}
\lipsum[2]


\begin{itemize}
    \item   the first item text 
    \begin{example}{<title>}
Key features of item \dots
    \end{example}
    \item   the second item text
\end{itemize}

\newpage
\lipsum[2]
    \begin{example}{<title>}
some text
    \end{example}
\lipsum[2]


\begin{itemize}
    \item   the first item text
    \begin{example}{<title>}
Key features of item \dots
    \end{example}
    \item   the second item text
\end{itemize}

\end{document}