Multicol – Using Margin Notes and Tikz Overlay with Multicols

marginparmulticol

As seen on page 200 of pgf manual is there a way to put notes in the margin but on the same level as the place it is called ?

One can deal with the right-left positionning with the help of this question margin notes multicolumn, but how to deal with up-down level ?

Edit

With your help, here is my try. Still vertical alignement problem.

\documentclass[french]{article}
\usepackage[marginparsep=3pt, top=2cm, bottom=1.5cm, left=1.5cm, right=1.5cm]{geometry}
\setlength{\parindent}{0pt}
\setlength{\headsep}{1em}
\usepackage{tikz,lipsum}
\usepackage{multicol,zref-savepos}

\def\Note#1{%
\zsavepos{#1}%
%%%%%%--------
\ifnum20000000<\number\zposx{#1}%
    \begin{tikzpicture}[remember picture,overlay]
    \coordinate (here) at (0,0);
    \draw (current page.east |- here)
            node[left]{\makebox[1.2cm][l]{#1}};
    \end{tikzpicture}%to prevent adding extra space before text
\else
    \begin{tikzpicture}[remember picture,overlay]
    \coordinate (here) at (0,0);
    \draw (current page.west |- here)
            node[right]{\makebox[1.2cm][r]{#1}};
    \end{tikzpicture}%to prevent adding extra space before text
\fi%
\ignorespaces
}

\begin{document}
\begin{multicols}{2}

\lipsum[1]

Un essai de note dans la colonne de gauche.\hfill\Note{1pt}

\lipsum[2-3]

\Note{1.5pt} Un essai de note dans la colonne de droite.
\lipsum[4-5]
\end{multicols}

\end{document}

enter image description here

Best Answer

I'm surprised this works. The actual location of the origin isn't usually fixed until the picture is completed and the current bounding box is fit into the text area.

\documentclass{article}
\usepackage{tikz}
\usepackage{lipsum}

\begin{document}

\lipsum[1]

\begin{tikzpicture}[remember picture,overlay]
\coordinate (here) at (0,0);
\draw (current page.west |- here) node[right]{Margin note};
\end{tikzpicture}%to prevent adding extra space before text
\lipsum[2-4]

\end{document}

full page