I am looking to set a background color for my sidebar
s in the memoir class. Is there a way to do this? I am looking to add a light grey background to my side notes so that they stand out. Other options for making them stand out, beyond a simple background color will also be useful.
\documentclass{memoir}
\begin{document}
\setsidebars{*}{3cm}{*}{*}{*}{*}
\sidebar{
\textbf{Tip:}
\smallskip
Here's a really useful trick to comparing fractions. It only works for two
fractions at one time, but you can use it a few times if you have a few fractions.
\smallskip
You can cross-multiply and compare the products to see which fraction is larger.
}
\end{document}
Edit: So after putting in your solution, I am having a conflict with tikz boxes I have used. Here is a MWE with the issue. I figured this would be better than a screenshot. The solution is perfect for what I want, but I have a great many of these tikz boxes throughout the document.
\documentclass{memoir}
\usepackage{lipsum}
\usepackage{mdframed}
\usepackage{tikz}
% Sidebar
\makeatletter
\renewcommand{\sidebar}[1]{%
\insert\sideins{%
\begin{mdframed}[
backgroundcolor=gray!30,
skipabove=0pt,
innertopmargin=0pt,
userdefinedwidth=\sidebarwidth,
frametitle=Tip:,
frametitlebelowskip=0pt]
\hsize\sidebarwidth
\@parboxrestore
\def\baselinestretch{\m@m@footnote@spacing}%
\m@mwhich@margin{\m@msidebar@margin}%
\sidebarform\sidebarfont
\splittopskip=\ht\strutbox
\splitmaxdepth=\dp\strutbox % doesn't do anything useful
\allowbreak
\prevdepth=\dp\strutbox % supersedes a "top-strut"
\vskip-\parskip
\parskip=\smallskipamount% optional
#1%
\ifvmode\else
\unskip\@finalstrut\strutbox
\fi\par
\ifdim\prevdepth>\dp\strutbox \prevdepth=\dp\strutbox \fi
\ifdim\prevdepth>99\p@
\nobreak
\vskip-\prevdepth
\allowbreak
\vskip\dp\strutbox
\fi
\vskip\sidebarvsep\end{mdframed}}%
}
\makeatother
% Tikz
\tikzset{
fancytitle/.style={fill=blue!15,draw=black,thick,text=black,rectangle,rounded corners},
lbox/.style= {draw=black,fill=black!5,thick,rectangle,rounded corners,inner xsep=7pt, inner ysep=15pt},
rbox/.style= {draw=black,fill=white,thick,rectangle,rounded corners,inner xsep=2pt, inner ysep=2pt}
}
\begin{document}
% Tips Sidebar
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\setsidebars{*}{2cm}{*}{*}{*}{*}
% Parameters set with this command. Any command with `*' denotes no change.
% \setsidebars{⟨hsep⟩}{⟨width⟩}{⟨vsep⟩}{⟨topsep⟩}{⟨font⟩}{⟨height⟩}
\sidebar{
Here's a really useful trick to comparing fractions. It only works for two
fractions at one time, but you can use it a few times if you have a few fractions.
You can cross-multiply and compare the products to see which fraction is larger.
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{minipage}{\textwidth}
\begin{tikzpicture}[transform shape]
\node [lbox] (box) {
\begin{minipage}{.4\textwidth}
{
\lipsum[1]
}
\end{minipage}
};
\node[fancytitle,right=8pt] at (box.north west) {Lipsum};
\end{tikzpicture}
\hfill
\begin{tikzpicture}[transform shape]
\node [rbox] (box) {
\begin{minipage}{.4\textwidth}
{
\lipsum[1]
}
\end{minipage}
};
\node[fancytitle,right=8pt] at (box.north west) {Lipsum};
\end{tikzpicture}
\end{minipage}
\end{document}