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 use underlay
options combined with remember
and frame hidden
.
remember
allows to make reference to other frame pictures or use current page
node in overlay|underlay
additions. frame hidden
avoid spurious lines behind your filled rectangles.
\documentclass{book}
\usepackage[many]{tcolorbox}
\usepackage{lipsum}
\begin{document}
\chapter{Foo bar}
\lipsum[1-2]
\begin{tcolorbox}[oversize,
remember,
sharp corners,
breakable,
enhanced,
frame hidden,
underlay first={\fill[green!30!white] (frame.north-|current page.west) rectangle (current page.south east);},
underlay last={\fill[green!30!white] (current page.north west) rectangle (current page.east|-frame.south);},
colframe=blue,
colupper=black,
bottom=10pt,
top=10pt,
]
\lipsum[2-3]
\end{tcolorbox}
\lipsum[2]
\end{document}
Update: How to preserve header?
I don't know how to solve this problem. To my understanding you want that something which is drawn later (colored box) doesn't cover something which is already printed on your page (header). It's possible that tcolorbox
leaves some information about a broken box which could be used to know that some background must be added to next page before the header is printed. But I don't know how to use it. May be follow up question attracts interest of more smart brains than mine.
The best I can do, which looks horrible, is making a hole for header area with tikzpagenodes
package help.
\documentclass{book}
\usepackage[many]{tcolorbox}
\usepackage{lipsum}
\usepackage{tikzpagenodes}
\begin{document}
\chapter{Foo bar}
\lipsum[1-2]
\begin{tcolorbox}[oversize,
remember,
sharp corners,
breakable,
enhanced,
frame hidden,
interior hidden,
underlay first={\fill[green!30!white] (frame.north-|current page.west)
rectangle (current page.south east);},
underlay last={\begin{scope}[even odd rule, fill=green!30!white]
\fill[clip] (current page.north west) rectangle
(current page.east|-frame.south)
(current page header area.north west) rectangle
(current page header area.south east);
\end{scope}
},
colframe=blue,
colupper=black,
bottom=10pt,
top=10pt,
]
\lipsum[2-3]
\end{tcolorbox}
\lipsum[2]
\end{document}
Best Answer
To vertically align both sides you have to fix a
sidebyside align
option. About the pie not being centered. It is centered into left box, but as you hide the separation, it looks like missplaced.As I don't know how to change the separation between text and frame in side by side boxes, I propose to use an alternative construction. It's a simple
tcolorbox
with a large left separation and the pie added as an overlay. This way you can control its position.