# Bug with sidenotes overflow and don't continue to the next page

When using the sidenotes package the sidenote overflow (a pun intended). The sidenotes don't continue to the next page but disappears outside the page.

Here is a minimal working example:

\documentclass[12pt]{book}

\usepackage{float}
\usepackage{caption}
\usepackage{url}

\usepackage{sidenotes}

\usepackage[outer=8cm,marginparsep=1cm,marginpar=6cm]{geometry}

\usepackage{chngcntr}
\counterwithin{sidenote}{section}
\makeatletter
\ExplSyntaxOn
\RenewDocumentCommand \sidenote { o o +m }
{
\@sidenotes@multichecker
\sidenotetext[#1][#2]{#3}
\sidenotemark[#1]
\@sidenotes@multimarker
}
\RenewDocumentCommand \sidenotetext { o o +m }
{
\IfNoValueOrEmptyTF{#1}
{
\refstepcounter{sidenote}
\@sidenotes@placemarginal{#2}{\textsuperscript{\thesidenote}{}~#3}
}
{
\@sidenotes@placemarginal{#2}{\textsuperscript{#1}~#3}
}
}
\ExplSyntaxOff
\makeatother

\begin{document}

\chapter{Example}

\section{Cake}

This is an example.\sidenote{First sidenote.\label{first}} \\
This is second\sidenote{Second sidenote.\label{second}} \\
More text... \\
...
... \\
Then I refer to sidenote \ref{first} and then to sidenote \ref{second}. \\

Darth Vader\sidenote{Dark Lord of the Sith}, also known by his birth name Anakin Skywalker, is a fictional character in the Star Wars franchise. Vader appears in the original span of the saga going from being Anakin Skywalker, the prophesied child who would bring balance to the Force, to his corruption and transformation into Darth Vader, to being the pivotal antagonist, and eventual redemption and fulfillment of the prophecy.

The character was created by George Lucas and has been portrayed by numerous actors. His appearances span the first six Star Wars films, as well as Rogue One\sidenote{Don't miss Darth Vader's scenes, especially the last one, they are awesome!}, and his character is referenced in both Star Wars: The Force Awakens\sidenote{Episode VII, after Disney bought Lucasfilm and the Star Wars franchise. The original trilogy is still the best and Kylo Ren is not as great as Darth Vader. I keep writing here my own thoughts to demonstrate a problem: the sidenotes overflow (a pun intended). The comment doesn't continue to the next page but disappears outside the page.} and Star Wars: The Last Jedi. He is also an important character in the Star Wars expanded universe of television series, video games, novels, literature and comic books. Originally a Jedi prophesied to bring balance to the Force, he falls to the dark side of the Force and serves the evil Galactic Empire at the right hand of his Sith master, Emperor Palpatine (also known as Darth Sidious). He is also the father of Luke Skywalker and Princess Leia Organa, secret husband of Padmé Amidala and grandfather of Kylo Ren.

Darth Vader has become one of the most iconic villains in popular culture, and has been listed among the greatest villains and fictional characters ever. The American Film Institute listed him as the third greatest movie villain in cinema history on 100 Years... 100 Heroes and Villains, behind Hannibal Lecter and Norman Bates.[9] However, other critics consider him a tragic hero, citing his original motivations for the greater good before his fall to the dark side and the redemptive self-sacrifice that leads to his death.

\end{document}


When using the sidenotes package the sidenote overflow (a pun intended). The sidenotes don't continue to the next page but disappears outside the page. The full text of the sidenote is

Episode VII, after Disney bought Lucasfilm and the Star Wars franchise. The original trilogy is still the best and Kylo Ren is not as great as Darth Vader. I keep writing here my own thoughts to demonstrate a problem: the sidenotes overflow (a pun intended). The comment doesn't continue to the next page but disappears outside the page.

Here is a screenshot of the bug:

• To say it is a bug says: the package promises this will work as I want, but it doesn't. It isn't a bug if you just want the package to do something it doesn't do. Are you sure this is a bug? I ask, because it sounds a really very hard thing to do, so I suspect that the package is not meant to do it. – cfr Jun 5 '18 at 1:26
• Doesn't that code give you a lot of bad box warnings? – cfr Jun 5 '18 at 1:28

Reading the manual of the sidenotes package, it uses for sidenotes the command \marginparor in some cases \marginnote from the KOMA-script bundle. Neither provides the ability to have a page break inside a sidenote.