# mix marginnotes with marginpars without overlap

We are trying to put the figure caption as well as the footnotes in the margin and got very good results with the tufte-latex package. However, we have to manually adjust the offset of each sidenote or caption so that they do not overlap. Please see the following part of a page. Please note, how reference 64 was manually moved up to not be too close to the caption.

Now, we have to find something fully automatic and I found the marginfix package. It works great and can move \marginpars around to get very pleasing results. Please see this article how it works. I tried to make the sidenote package to combine the look with the automatic feature.

Nevertheless, it is not useful to move a figure caption away from the adjacent figure. Therefore, the caption is placed with a \marginnote from the marginnote package. If the margin gets very crowded, the \marginpars start to overlap with the \marginnotes.

It seems, that was addressed in the first version of marginfix. I could 'block' some part of the margin with \blockmargin. Does anyone know why \blockmargin was dropped in the rewrite of marginfix? I asked the author, but got no response. The repository of marginfix is here.

Or is there another way to 'forbit' some area of the margin for \marginpar?

I tried a MWE to generally demonstrate the problem. Please replace the filename in the \includegraphics macro.

\documentclass[]{article}

\usepackage{lipsum}
\usepackage{graphicx}
\usepackage{marginnote}

\usepackage[paperwidth=170mm, paperheight=240mm, left=40pt, top=40pt, textwidth=260pt, marginparsep=20pt, marginparwidth=100pt, textheight=560pt, footskip=40pt]{geometry}

\begin{document}
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut purus elit, vestibulum ut, placerat ac, adipiscing vitae, felis. Curabitur dictum gravida mauris. Nam arcu libero, nonummy eget, consectetuer id, vulputate a, magna.
\marginpar{This could be a couple of references and other sidenotes.}
Donec vehicula augue eu neque.
\marginpar{This could be a couple of references and other sidenotes.}
Pellentesque habitant morbi tris- tique senectus et netus et malesuada fames ac turpis egestas. Mauris ut leo. Cras viverra metus rhoncus sem. Nulla et lectus vestibulum urna fringilla ultrices.
\marginpar{This could be a couple of references and other sidenotes.}
Phasellus eu tellus sit amet tortor gravida placerat. Integer sapien est, iaculis in, pretium quis, viverra ac, nunc.

\begin{figure}[h]
\marginnote{This would be where the caption should be.}
\includegraphics{broken_loop}
\end{figure}

\lipsum[3]

\end{document}

-
Welcome to TeX.sx! A tip: You can use backticks  to mark your inline code as I did in my edit. –  doncherry Oct 16 '11 at 16:59
Please provide version numbers and dates. I wrote to S. Hicks end of July 2010, someday then he published a first version of marginfix, there were bug reports (I wrote one end of August 2010) and then he published version 0.9.1. To which rewrite do you refer? –  Keks Dose Oct 21 '11 at 14:10
I never used the old version with \blockmargin, but I found the command in the TUGboat article (tug.org/TUGboat/tb31-2/tb98hicks.pdf). In the github repository (github.com/shicks/marginfix/commits/master) it is present in the initial commit (Jun 23, 2010) and was dropped in the next one (Aug 8, 2010). I use marginfix extensively and it works great. Now I want to mix it with figure captions that require \marginnote, those obviously overlap with the \marginpars. \blockmargin would be very helpful. –  Andy Oct 21 '11 at 14:26
I suggest to edit your question: Draft a minimal working example showing your need for a command blocking the margin, refer to the version of marginfix including \blockmargin and ask for somebody to code it. BUT from my own experience with marginfix I doubt that this will work, if not done with care. Marginfix moves marginnotes vertically. How should that be done in case of \blockmargin on the page? Probably you either have to cease using marginfix or captions in the margin. –  Keks Dose Oct 21 '11 at 15:09
@KeksDose: I did edit and we do indeed use captions under the figure instead of in the margin for now. –  Andy Oct 23 '11 at 18:24

If the figure is a float, my first feeling is to allow to the figure float in a more fine place than "here", that is saturated of margin notes.

When the image must be just "here", a manual option is to adjust the alignment caption, for example using amargincap environment of the mcaption package or using SCfigure environment of the package sidecap with normal caption (which can be aligned with \sidecaptionvpos).

But for a general solution to prevent any posible overlapping of the side caption with preceedings \marginpar notes (with some extra separation), simply convert the caption in a \marginpar note, using \figcaption (of package captdef), but outside of the float (that you can omit safely in this case).

\documentclass{article}
\usepackage{lipsum}
\usepackage{xcolor}
\usepackage{graphicx}
\usepackage{marginnote}
\usepackage[paperwidth=170mm, paperheight=240mm, left=40pt, top=40pt, textwidth=260pt, marginparsep=20pt, marginparwidth=100pt, textheight=560pt, footskip=40pt]{geometry}

\usepackage{captdef}

\begin{document}

Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut purus elit, vestibulum ut, placerat ac, adipiscing vitae, felis. Curabitur dictum gravida mauris. Nam arcu libero, nonummy eget, consectetuer id, vulputate a, magna.
\marginpar{This could be a couple of references and other sidenotes.}
Donec vehicula augue eu neque.
\marginpar{This could be a couple of references and other sidenotes.}
Pellentesque habitant morbi tris- tique senectus et netus et malesuada fames ac turpis egestas. Mauris ut leo. Cras viverra metus rhoncus sem. Nulla et lectus vestibulum urna fringilla ultrices.
\marginpar{This could be a couple of references and other sidenotes.}
Phasellus eu tellus sit amet tortor gravida placerat. Integer sapien est, iaculis in, pretium quis, viverra ac, nunc.

\marginpar{\textcolor{red}{\figcaption{
This would be where the caption should be.}}}

\begin{figure}[h]
\centering
\includegraphics[width=\textwidth]{broken_loop}
\end{figure}

% or simply
% \marginpar{\figcaption{...}}
% \noindent\includegraphics{broken_loop}

\lipsum[3]
\end{document}
`
-