[Tex/LaTex] Sidenotes appear on the wrong side for Tufte-Latex Documents

sidenotestufte

The Tufte-Latex class has an option to place the margin for even pages on the left-hand side and for uneven pages on the right-hand side:

\documentclass[twoside,symmetric]{tufte-book}

but unfortunately some sidenotes are still on the wrong side:

enter image description here

Is there any possibility to avoid this?

EDIT: The problem appears almost always for sidenotes in the first three sentences of a new page. Inserting

\newpage 

or

 \clearpage

by hand above the problematic footnotes solves the problem, but obviously this is a bad solution.

Best Answer

Because LaTeX's output routine runs asynchronously with TeX's page builder, margin notes can appear on the wrong side of the page when they're near the top of the page.

As LaTeX places margin notes, it looks to see if it's currently on a recto or verso page and places the margin note accordingly. However, TeX may come along after the margin note has been placed and decide to move the margin note (along with a few regular lines of text) to the following page. When TeX moves the material to the next page, the margin note stays in the same position.

The mparhack package works around this problem by adding label to each margin note and recording which page it falls on. When you run LaTeX a second time, it looks at which page the margin note ended up on and adjusts its position accordingly.

To use this package, just load it in the preamble of your document:

\usepackage{mparhack}

and then run LaTeX a couple times (first to record the pages the margin notes landed on, and again to fix misplaced margin notes).

Related Question