The vertical alignment of a \marginnote with a display equation is unexpected.
Minimal Working Example
\documentclass{kaobook}
\usepackage[english]{babel}
\usepackage{blindtext}
\usepackage{kaobiblio}
\usepackage{kaotheorems}
\usepackage{kaorefs}
\begin{document}
\title{Bug Report}
\author{Author}
\date{\today}
\frontmatter
\KOMAoptions{twoside=semi}
\maketitle
\KOMAoptions{twoside=false}
\mainmatter
\setchapterstyle{kao}
This sentence ends with math:
\begin{equation*}
V(P)[i] = V(P)[i-1] \cup V(P[i]) \,, i = 1, \cdots, n \,.
\end{equation*}
\marginnote{a marginnote}
This sentence ends with math:
\begin{equation*}
V(P)[i] = V(P)[i-1] \cup V(P[i]) \,, i = 1, \cdots, n \,.
\end{equation*}
\marginpar{a marginpar}
This sentence ends with math:
\begin{equation*}
V(P)[i] = \frac{1}{2} \sum_{i=1}^{n} x_{i} \,.
\end{equation*}
\marginnote{taller equation}
% https://tex.stackexchange.com/questions/63012/using-marginnote-inside-a-math-environment-in-tufte-book
\def\mathnotealign#1{%
\tag*{\rlap{\hspace\marginparsep\smash{\parbox[t]{\marginparwidth}{%
\footnotesize#1}}}}
}
\def\mathnoteeqn#1{%
\tag*{\kern1sp\rlap{\hspace\marginparsep\smash{\parbox[t]{\marginparwidth}{%
\footnotesize#1}}}}
}
This sentence ends with math:
\begin{equation*}
V(P)[i] = \frac{1}{2} \sum_{i=1}^{n} x_{i} \,.
\mathnoteeqn{a note within}
\end{equation*}
An align environment follows
\begin{align*}
&\int\int\int t\ dt^3\mathnotealign{first note}\\
=&\int\int \frac{t^2}{2}\ dt^2\\
=&\int \frac{t^3}{6}\ dt\\
=&\frac{t^4}{24}\mathnotealign{second note}
\end{align*}
The same two environments, but with the notes messed up:
\begin{equation*}
V(P)[i] = \frac{1}{2} \sum_{i=1}^{n} x_{i} \,.
\mathnotealign{a note within}
\end{equation*}
\begin{align*}
&\int\int\int t\ dt^3\mathnoteeqn{first note}\\
=&\int\int \frac{t^2}{2}\ dt^2\\
=&\int \frac{t^3}{6}\ dt\\
=&\frac{t^4}{24}\mathnoteeqn{second note}
\end{align*}
\end{document}
Expected behavior:
The margin note begins on the same line as the equation environment.
Actual behavior:
The margin note begins after the end of the equation environment:
Additional Information
This issue also occurs with \documentclass{article} and \usepackage{marginnote}, so it is not specific to kaobook or KOMA-script, but it would be nice to have a solution.
I copied the \mathnoteeqn and \mathnotealign definitions from tex.stackexchange. Ideally one definition would suffice, but the comments on the answer suggest using two different definitions depending on which environment the note is in.
Prerequisites
Description
The vertical alignment of a
\marginnote
with a display equation is unexpected.Minimal Working Example
Expected behavior: The margin note begins on the same line as the equation environment.
Actual behavior: The margin note begins after the end of the equation environment:
Additional Information
This issue also occurs with
\documentclass{article}
and\usepackage{marginnote}
, so it is not specific to kaobook or KOMA-script, but it would be nice to have a solution.I copied the
\mathnoteeqn
and\mathnotealign
definitions from tex.stackexchange. Ideally one definition would suffice, but the comments on the answer suggest using two different definitions depending on which environment the note is in.