I have been typesetting a two-columned book where I sometimes need to put a mark in the margin to say, that particular line might need special attention. (The book is actually a psalter – for chanting.)
Because it isn't possible to use \marginpar
in the multicol
environment, I use
\marginnote
from the package marginnote
instead. The problem is, that all the
margin notes appear in the outer margin of the page. I need each to appear
next to the column, where it occurs – some in the inner margin, some in the outer margin – to match the problematic lines closely.
Is there any way to achieve this? I searched the internet thoroughly and haven't found anything relevant…
\documentclass{article}
\usepackage{multicol}
\usepackage{marginnote}
\begin{document}
\begin{multicols}{2}
Some text, a very long one.
And somewhere in the middle of it I need a (very small) margin note, like this:
Text text text\marginnote{\textbf{!}} and more text...
\end{multicols}
\end{document}
Best Answer
One can use
\pdfsavepos
to detect if the mark is on the left or right column. This is best done using Heiko Oberdiek'szref
package.Since we can get the actual
x-position
of the mark (insp
units) we can use it to detect if we are in the left or right columns.A somewhat simplistic implementation is shown in the minimal below.
You might need to run the example more than once for the position to settle. This works both for
pdfLaTeX
asXeLaTeX
.The MWE is dependent on the actual geometry used, but one can automate the calculations. Also the boxes have been kept simple for clarity. Substituting:
will enable paragraphs to be inserted.