I have a two-sided document with fairly large margins and figures spreading into the margins. I'd like to set marginnotes/sidenotes with the following requirements:
- superscript number from sidenotes package
- raggedoutside like marginnote package, i.e. depending on where the note appears, it's raggedleft (even) or raggedright (odd)
- notes should not spread further than the figure. This is currently defined through the
marginparwidth
settings ofgeometry
and should not break with a new package.
Here's my MWE using both sidenotes and marginnoted to show the difference:
\documentclass[a4paper,11pt,twoside,openright,parskip=half]{scrbook}
\usepackage[ngerman, english]{babel}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{calc}
\makeatletter
\newlength \figwidth
\setlength \figwidth {-3cm}
\makeatother
\usepackage{geometry}
\geometry{a4paper, top=30mm, left=30mm, right=55mm, bottom=35mm, marginparwidth=-\figwidth-1em, marginparsep=1em}
\usepackage{marginnote}
\usepackage{sidenotes}
\renewcommand*{\marginfont}{\footnotesize}
\newcommand{\smallside}[1]{\sidenote{\footnotesize{#1}}}
\usepackage{caption}
\usepackage{graphicx}
\usepackage[strict]{changepage}
\newenvironment{widefigure}[1][tbp]
{\begin{figure}[#1]\begin{adjustwidth*}{0cm}{\figwidth}\centering}%
{\end{adjustwidth*}\end{figure}}
\usepackage{blindtext}
\begin{document}
\begin{widefigure}[tbp]
\includegraphics[width=\linewidth, height=9cm]{example-image}
\caption{Some figure caption in here that does not really matter but should be long enough to fill the line and also break}
\end{widefigure}
\blindtext
\marginnote{some long text for the margin}
\blindtext
\smallside{some long text for the margin}
\blindtext
%\newpage
\begin{widefigure}[tbp]
\includegraphics[width=\linewidth, height=9cm]{example-image}
\caption{Some figure caption in here that does not really matter but should be long enough to fill the line and also break}
\end{widefigure}
\marginnote{some extremely long text for the margin going on many lines}
\blindtext
\smallside{some extremely long text for the margin going on many lines}
\blindtext
\end{document}
Best Answer
\sidenote
uses\marginnote
when an offset is given and\marginpar
otherwise.\marginnote
does the\raggedleft
/\raggedright
stuff but\marginpar
doesn't. On the other hand\marginpar
tries to float the notes so that they don't bump into each other.So there are basically two solutions:
(1) Give an offset in the definition of
\smallside
:But then your sidenote will no longer float, so they can bump into each other. But you do get the proper ragged stuff.
(2) Change the definition of the sidenote macro part where the choice is made between
\marginpar
and\marginnote
and supply the\ragged...
stuff to\marginpar
.By the way, I think there are some spurious spaces in the
sidenotes
package. I had to get rid of some in the above macro definition.