I know this is a long shot since I cannot really post a minimal working example, but I'll try to describe the issue to the best of my capabilities. I'm running pdflatex twice for the compilation.

I have the following testing macro, which produces the expected result at the beginning of the chapter.

Text1. \marginnote[left]{right}

Some more text. \marginnote[left]{right}

More text, longer sentence. \marginnote[left]{right}}

enter image description here

Unfortunately, after a few pages, marginnote gets confused.

enter image description here

It looks like the first call to \marginnote[left]{right} fixes the alignment for the following two instances.

One could simply use marginpar. I noticed this issue when trying to use sidecaption, which was putting the text over the figure rather than in the margin.

Original issue


enter image description here

  • Seems difficult, I've no idea either. There's always the brute force way of learning how it work in the lowest level (read the TeXbook) and trace through the package code (also is there any error/warning message in the log? Don't ignore them)
    – user202729
    Jul 15, 2022 at 6:17
  • No errors. I'll check the warnings. I'm planning to comment/uncomment out sections of the chapter until I identify the culprit. The bad practice of defining macros within the chapter is going to bite back now. Also, I think the right/left counter got corrupted, since I've noticed some quirks in the previous sidecaption text alignment. Anyway, this is much pain…
    – Atcold
    Jul 15, 2022 at 15:22
  • Figured out… Jeez… It was due to \includeonly{}… Running the whole document without it fixed the issue. I mean, life is unfair… Shall I delete this issue? Answer it myself? What's the expected behaviour here?
    – Atcold
    Jul 15, 2022 at 18:42
  • I guess you could answer it yourself (after making a proper MWE...?) Or better, reporting a bug on appropriate places (if it's really a bug)?
    – user202729
    Jul 16, 2022 at 0:00
  • Hum… The MWE would consist in having multiple files and outdated aux outputs. The library is no longer maintained and it's a collection of hacks, which explains why it broke. I think I should simple close or erase this.
    – Atcold
    Jul 18, 2022 at 18:30

2 Answers 2


So, it turns out that marginnote relies on updated aux files. If you have outdated ones, caused by using the \includeonly{} and several \include{} commands, you may incur in some glitches.

The solution was generating the whole document without \includeonly{}.

I decided not to delete this question for indexing purposes. Hopefully, it'll help others not waste plenty of time on bug hunting.

  • 1
    Right, sometimes it‘s a good idea to delete all files besides your .tex files and compile again.
    – MS-SPO
    Jul 18, 2022 at 18:49

For a systematic approach to identify the trouble makers you may want to adapt this one: How to declutter your main.tex .

Including the preamble an adaptation which converges quickly is „50:50“. If your relevant document part consist of A+B, create two versions, with A or B alone. Say A compiles, but B generates errors. Next dive into part B and repeat.

Many times this ends up at faulty or „shady“ lines of code. Sometimes the (nothing-to-see-here) result forces you to think outside the box, which might suggest deleting a file as you did.

  • 1
    Yeah, I've used \iffalse-\fi construct to ‘comment out code’ without deleting it or actually commenting it (I already have comments, and I didn't want to get confused). Finally, I noticed that the bug was connected to the number of pages that were generated and not to any particular section. Hence, re-generating without \includeonly{} came to my mind.
    – Atcold
    Jul 20, 2022 at 4:54

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .