Contents

Side notes

Typesetting

Side notes

A \marginpar is set in the margin, level with the line it was written on, and typeset by TEX at the margin’s width. Where the window leaves no margin, a small mark in the line opens it instead.

The harmonic seriesdiverges, though very slowly. Its terms tend to zero, which is not enough.

Its partial sums grow like.

The harmonic series $\sum_{n \ge 1} 1/n$ diverges, though very
slowly.\marginpar{\footnotesize Its partial sums grow like $\ln N$.} Its
terms tend to zero, which is not enough.

A page styles side notes with CSS, by .latex-margin-note, and [data-kind="marginpar"] for these. It may also set the margin’s width and its distance from the text, as this example does, with --latex-margin-width and --latex-margin-gap on the block.

DIY: a side note of your own

With the companion package, \usepackage{reflowtex}, a side note can be a command of its own, drawn as the page likes. Any \webaside with the parameter place=margin goes in the margin like a \marginpar; the page draws its kind with a component, as it would any other kind (define in the companion package): the viewer places the note on its line. Here \mysidenote numbers its notes, puts the number in the text, and the page draws the note with the number beside it.

The sum of the reciprocals of the squares,, was an open question for almost a century before Euler settled it in 1734.1 He treatedas if it were a polynomial with roots at, compared coefficients, and found the sum to be. The argument was not rigorous at the time, and Euler knew it.2 The same method gives the sums of,and every even power; for odd powers no such closed form is known, and whetheris irrational is still open.

The Basel problem, posed by Pietro Mengoli in 1650 and named after Euler’s home town.

He gave a rigorous proof in 1741.

The sum of the reciprocals of the squares, $\sum_{n \ge 1} 1/n^2$, was
an open question for almost a century before Euler settled it in
1734.\mysidenote{The Basel problem, posed by Pietro Mengoli in 1650 and
named after Euler's home town.} He treated $\sin x / x$ as if it were a
polynomial with roots at $\pm\pi, \pm 2\pi, \dots$, compared coefficients,
and found the sum to be $\pi^2/6$. The argument was not rigorous at the
time, and Euler knew it.\mysidenote{He gave a rigorous proof in 1741.} The
same method gives the sums of $1/n^4$, $1/n^6$ and every even power; for
odd powers no such closed form is known, and whether $\sum 1/n^5$ is
irrational is still open.

The preamble:

% Accessible formulas: tagging on and luamml loaded, so that LaTeX writes
% every formula's MathML (with classic fonts LaTeX loads luamml only when
% asked). Reflow TeX reads it for screen readers.
\DocumentMetadata{tagging=on}
\tagpdfsetup{math/mathml/luamml/load=true}
% Preamble for the \mysidenote example (content/docs/typesetting/side-notes.md).
\usepackage{microtype}
\usepackage{reflowtex}
\usepackage{xcolor}
% The numbers' colour: in print this blue; on the web the page's accent
% (examples/sidenote.css maps it).
\definecolor{sidenote}{HTML}{2F2CCD}
% \mysidenote{text}: a numbered side note. The number goes in the text, bold
% and in colour; the
% note is an aside of kind "sidenote" with place=margin, which the viewer
% sets in the margin, and the page draws (examples/sidenote.js). In print, a
% \marginpar with the number.
\newcounter{sidenote}
\NewDocumentCommand\mysidenote{+m}{%
  \stepcounter{sidenote}%
  \textsuperscript{\bfseries\color{sidenote}\thesidenote}%
  \ifreflowtex
    \webaside[place=margin, n=\thesidenote]{sidenote}{\footnotesize\raggedright #1}%
  \else
    \marginpar{\footnotesize\textsuperscript{\thesidenote}\,#1}%
  \fi}

The page’s script and its style:

// \mysidenote (latex-preambles/sidenote.tex): each note in the margin with
// its number beside it, on the note's first baseline. The viewer places the
// notes (kind sidenote, place=margin); this draws them.
import { html, useState, define, Typeset } from 'reflowtex/companion';

define('sidenote', ({ instance }) => {
  const [baseline, setBaseline] = useState(0);   // of the note, once laid out
  return html`
    <div class="sidenote">
      <svg class="sidenote-number" aria-hidden="true"><text y=${baseline}>${instance.attrs.n}</text></svg>
      <${Typeset} onMetrics=${m => setBaseline(m.firstBaseline)} />
    </div>`;
});
/* \mysidenote: a rule in the accent colour, the number hanging left of the
   note on its first baseline. The numbers in the text are in the colour
   "sidenote" (#2F2CCD in the preamble): the page's accent, in every theme. */
:root { --latex-color-2f2ccd: var(--lt-primary, #2f2ccd); }
.sidenote { position: relative; padding-left: 20px; border-left: 2px solid var(--lt-primary, currentColor); }
.sidenote-number { position: absolute; left: 7px; top: 0; width: 12px; height: 1px; overflow: visible; }
/* The note sits in the block, so the viewer's rules for its own glyphs
   (.latex-block svg text) reach this number too: outrank them. */
html .latex-block .sidenote-number text {
  fill: var(--lt-primary, currentColor); font: 700 11px ui-sans-serif, system-ui, sans-serif;
  font-weight: 700 !important; }