I'm trying to create a command that will allow me to add little "important notes" on the margin of my document. I have managed to make it work as long as as I use the "left" option for the box and the page number is odd. But when I try to place it on an even numbered page it doesn't show anything, whether I use the "left" or "right" options.
\documentclass[a4paper,11pt]{book}
\usepackage[outer=5cm, heightrounded, marginparwidth=4cm, marginparsep=0.5cm]{geometry}
\usepackage[T1]{fontenc} % to get Type 1 fonts
\usepackage[utf8]{inputenc} % to enable non ASCII characters
\usepackage{lmodern}
\usepackage[english]{babel}
\usepackage{marginnote}
\usepackage{xcolor}
\usepackage[most,breakable,many]{tcolorbox}
\tcbset{before skip=0pt,after skip=0pt}
\usepackage{lipsum} % dummy text
%%%%%%%%%%%%%%%%%%%%%%%%% Important Note %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcounter{important}
\newtcolorbox[use counter=important]
{important}[1][]
{title=Important Note~\thetcbcounter,
width=4cm,
left=0pt,
right=0pt,
fonttitle=\bfseries\color{white},
colframe=olive,
colback=olive!10,
#1
}
\newcommand\Limportant[3][]{%
\marginnote[#1]{%
\makebox[0pt][l]{\begin{important}[label=#3]
#2
\end{important}}}}%
\newcommand\Rimportant[3][]{%
\marginnote[#1]{%
\makebox[0pt][r]{\begin{important}[label=#3]
#2
\end{important}}}}%
\begin{document}
\lipsum[1]
\Limportant[-2cm]{\lipsum[75]}.
\vfill
\pagebreak
\lipsum[1]
\Rimportant{\lipsum[75]}.
\end{document}
Ideally I would like to combine both options so that it automatically decides on which side it should be placed, but I have not figured out how to calculate '$'\pagenumber modulo 2 '$' so I could potentially include it as a command with cases.
In the same command I might have written something wrong because adding the optional command for vertical adjustment has no effect (the -2cm at '$'\Limportant[-2cm]{\lipsum[75]}'$')
tcolorbox
has a command to check for odd and even pages. Please consider to accept answers to your questions instead of piling up new questions!