[Tex/LaTex] Misplaced marginpar in twoside+twocolumn layout with pdfpages

double-sidedmarginpar

\includepdf from the pdfpages package messes up the margin placement for this MWE:

\documentclass[10pt,a4paper,twoside,twocolumn]{article}

\usepackage[outer=6cm,
        inner=2.5cm,
        top=2cm,
        marginparwidth=3cm,
        marginparsep=1mm,
        twoside=true
        ]{geometry}
\usepackage{lipsum}
\usepackage{pdfpages}

\begin{document}

\includepdf{cover.pdf}

\lipsum
\marginpar{margin note}
\lipsum

\end{document}

where cover.pdf is a full one page pdf. What I mean by messing up is that the margin note is placed in the inner margin and not the outer one. I assume this is something along the lines of \includepdf not changing the odd/even counters correctly? Is there a better way to do what I am after?

Best Answer

From marginnote documentation:

At double side layout (e.g. using class option twoside) \marginnote needs to know the number of the current page to decide wether the page is odd or even and so wether to use left or right margin. L A T E X uses an asynchronous output. Because of this counter page should not be used to get the number of the current page unless you are at page head or foot. To solve the problem marginnote uses a mechanism similar to labels. But this means, that the correct margin won’t be known at this L A T E X run but only at the next. So after adding or deleting a margin note or after each change of page break you need two L A T E X runs to get all margins right.

The even and odd pages numbers are not properly fetched by the marginpar when \includepdf is used.

A possible solution will be to use marginnote package.

\documentclass[10pt,a4paper,twoside,twocolumn]{article}

\usepackage[outer=6cm,
        inner=2.5cm,
        top=2cm,
        marginparwidth=3cm,
        marginparsep=1mm,
        twoside=true
        ]{geometry}
\usepackage{lipsum}
\usepackage{pdfpages}
\usepackage[fulladjust]{marginnote}

\begin{document}

\includepdf{pgfmanual.pdf}
\lipsum
\marginnote{margin note}
\lipsum

\end{document}

enter image description here