# Is there a way to prevent marginpars colliding with tabs created using the fancy tabs package

I am automatically creating large documents that use fancytabs as thumb marks and that also use marginpar notes to convey information about the text. (I actually put them in a Tikz lozenge since fancytabs has loaded tikz anyway - see example). The problem is that often in a few hundred page document the marginpar will collide with the fancytab. It is going to be hugely time consuming if I have to shift them manually.

I can work out where on a page the fancy tab is going to appear and as per the example its easy to manually shift the marginpars. I can't work out how to determine where (vertically) the marginpar will appear. Marginpar also takes care to make sure the margin notes don't collide with each other, but I am struggling to work out how to stop the marginpars colliding with the tabs.

Any help or pointers much appreciated.

Here is a short working example

\documentclass[11pt, oneside]{article}
\usepackage{geometry}
\geometry{letterpaper}

\usepackage{amssymb}
\usepackage{fancytabs}
\usepackage{lipsum}
\fancytabsWidth{3cm}

\let\oldmarginpar\marginpar
\renewcommand{\marginpar}[2][anchor=center]{%
\oldmarginpar{
~\\ % Need this, rather strangely, to get the tikz node to anchor properly.
\tikz \draw node (one) [] at (0,0) {}  node (two) [anchor=north,text     width=2.0cm,draw,align=left,text badly ragged,fill=black!05,rounded corners,#1] at   (0,0) {\baselineskip=-2pt ~\\#2 \\ } ;      }
}

\begin{document}
\lipsum[1]
\fancytab{fancy tab}{2}
\textbf{Some more text which will contain a little margin note, the problem being that the margin note collides with the fancy tab that we have created. Is there a way to get the margin note to shift down below the tab}
\marginpar{This note collides}
\marginpar[yshift=-2cm]{This one has been manually shifted out the way}
\lipsum
\end{document}


• There is a related question here. I would expect, that there is no solution, yet, as well. The author of marginfix is working on it. Look for phantom or blockmargin in the documentation. I have not tried it in a while. – Andy May 30 '14 at 4:56
• Thanks, I did have a go with marginfix, but the latest version causes the colliding tab to disappear. Still the fact that its doing something may give me the "in" I need. – user2466401 Jun 2 '14 at 3:48

The simplest answer: adjust the value of \fancytabsWidth as a fraction of the parameter \oddsidemargin:
\fancytabsWidth{0.75\oddsidemargin}

This will place the tab apart and let a white of 0.25\oddsidemarginbetween the marginpar and the tab. Eventually you may need to adjust the size of the font used inside the tab.
This is not the vertical solution you wanted, but I think it is the most elegant and disrupting. It does not work however, when you set a layout where the oddsidemargin is too thin.