# Use framed package with marginpar

I would like to emphasize a text block and still be able to use margin paragraphs.

A non-MWE:

\documentclass{article}

\usepackage{lipsum}
\usepackage{color}

\usepackage{framed}
\renewenvironment{shaded}{%
\def\FrameCommand{\fboxsep=\FrameSep\colorbox{shadecolor}}%
\MakeFramed{\advance\hsize-\width\FrameRestore\FrameRestore}%
\noindent}%
{\endMakeFramed\noindent}%
\definecolor{shadecolor}{gray}{0.85}

\begin{document}

\lipsum[1]

\begin{shaded}
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. \marginpar{Lorem?}
\lipsum[1-4]
\end{shaded}

\lipsum[7]

\end{document}


How to tweak it to allow the marginpar without loosing the ability for a pagebreak across the emphasized text block? A do not need to use framed if other options are available, but the use of marginpar is required in the original document, where marginfix is used.

• Is framed breakable at all? Use mdframe or tcolorbox in conjunction with marginnote package, for example – user31729 Jul 4 '16 at 16:38
• @Christian Hupfer: framed is perfectly breakable. It even cooperates fine with ntheorem to define framedtheorem or shadedtheorem environments. – Bernard Jul 4 '16 at 18:50
• @Bernard: I see. I never used it really – user31729 Jul 4 '16 at 19:48

## 1 Answer

Load the marginnote package, it works fine in a float environment:

\documentclass{article}
\usepackage{geometry} \usepackage{lipsum}
\usepackage{color}
\usepackage{marginnote} \usepackage{framed}
\renewenvironment{shaded}{%
\def\FrameCommand{\fboxsep=\FrameSep\colorbox{shadecolor}}%
\MakeFramed{\advance\hsize-\width\FrameRestore\FrameRestore}%
\noindent}%
{\endMakeFramed\noindent}%
\definecolor{shadecolor}{gray}{0.85}

\begin{document}

\lipsum[1-3]

\begin{shaded}
\lipsum[1-3]
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. \marginnote{\color{red}\bfseries Lorem?}
\lipsum[4-5]
\end{shaded}

\lipsum[7]

\end{document}


• marginnote does not work for me. I utilize marginfix in the original document. – Andy Jul 4 '16 at 19:59
• Do you mean it doesn't work with the very code I posted? Perhaps there's some incompatibility between marginfix (which I never used) and marginnote? – Bernard Jul 4 '16 at 20:22