Positioning of tcolorbox in list environment
For this case, I would replace toggle enlargement
by some direct code:
\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,
code={\checkoddpage\ifoddpage%
\tcbset{grow to left by=-\marginwidth+\@totalleftmargin,
grow to right by=\marginwidth+\@totalleftmargin}%
\else%
\tcbset{grow to left by=\marginwidth+\@totalleftmargin,
grow to right by=\marginwidth+\@totalleftmargin}%
\fi},
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};},}
\makeatother
\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}
\clearpage
\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}
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}
You can adjust the list
environments to compensate. I've used enumitem
to simplify this. I've also used memoir
's facilities to set the margin notes up, which you should certainly do. (No point having it fix the layout if you then go and immediately mess it up again!)
\documentclass[12pt]{memoir}
\usepackage{calc,enumitem,lipsum}
\usepackage[T1]{fontenc}
\setstocksize{297mm}{210mm}
\settrimmedsize{\stockheight}{\stockwidth}{*}
\settypeblocksize{247mm}{120mm}{*}
\setulmargins{25mm}{*}{1}
\setlrmarginsandblock{30mm}{60mm}{*}
\newlength{\marginwidth}
\setmarginnotes{5mm}{45mm}{2.5mm}
\setlength{\marginwidth}{\marginparsep+\marginparwidth}
\setlength{\headwidth}{\textwidth+\marginwidth}
\checkandfixthelayout
\newlength{\myadjustment}
\setlength{\myadjustment}{0pt}
\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+\myadjustment,
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};},
}
\newlength{\myorigadjustment}
\setlist{before=\setlength{\myorigadjustment}{\myadjustment}\setlength{\myadjustment}{\leftmargin},after=\setlength{\myadjustment}{\myorigadjustment}}
\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}