# Sidenotes appear on the wrong side for Tufte-Latex Documents

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:

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.

• Margin notes at the top of the page sometimes end up on the wrong side during the initial run of LaTeX. Running it a second time typically corrects the problem. Does that work in your case? – godbyk Apr 1 '15 at 17:49
• @godbyk Thanks for your comment. Unfortunately running Latex several times does not solve the problem – jak Apr 1 '15 at 19:47
• A vaguely remember a package called `marginfix` which is supposed to improve the behaviour of `\marginpar`... May be worth a try. – clemens Apr 1 '15 at 19:51
• @clemens `marginfix` modifies the output routine, I think, and so it may not work with Tufte-LaTeX. You could try the `mparhack` package, though. (I haven't tested it with Tufte-LaTeX yet.) – godbyk Apr 1 '15 at 19:54
• @clemens unfortunately, as godbyk guessed, there are many errors when I try to run markinfix with the tufte class – jak Apr 1 '15 at 20:16

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).

• Nice ! This also corrects the same problem happenning with marginfigure and margintable . – Frédéric Grosshans Mar 9 '16 at 14:45