Contents

Accordion

Companion package

Accordion

A webaccordion shows one of its panes at a time, and the reader moves between them with links placed in the panes themselves. A pane can hold anything; here it is an ordinary amsthm proof. Each pane is typeset by TEX, re-breaks with the column, and starts where the others do.

Euclid’s proof that the primes never run out is over two thousand years old.

Theorem 1. There are infinitely many primes.

Proof idea. If there were finitely many, their product plus one would have a prime factor that is none of them. See the proof

Proof (hide). Supposewere all of them, and let

Nodivides, since each leaves remainder. Yethas a prime factor, and it is none of the– a contradiction.

The same idea shows that there are infinitely many primes of the form, though not, without more work, of the form.

Euclid's proof that the primes never run out is over two thousand years old.
\begin{theorem}
There are infinitely many primes.
\end{theorem}
\begin{webaccordion}
\begin{webpane}[collapsed]
\noindent\textit{Proof idea.} If there were finitely many, their product
plus one would have a prime factor that is none of them.
\webnextpane[See the proof]
\end{webpane}
\begin{webpane}[expanded]
\begin{proof}[\proofname\webpanelink{prev}{ (hide)}]
Suppose $p_1, \dots, p_k$ were all of them, and let
\[ N = p_1 p_2 \cdots p_k + 1 . \]
No $p_i$ divides $N$, since each leaves remainder $1$. Yet $N > 1$ has a
prime factor, and it is none of the $p_i$ -- a contradiction.
\end{proof}
\end{webpane}
\end{webaccordion}
The same idea shows that there are infinitely many primes of the form
$4k + 3$, though not, without more work, of the form $4k + 1$.

Panes and links

The example’s two panes are named collapsed and expanded. There can be any number of panes, \begin{webpane}[name], and links switch between them: \webnextpane goes to the next pane and \webprevpane to the previous one (the text is optional: See more and See less by default). A third, \webpanelink{target}{text}, goes to a pane by name or number, or to next, prev, first or last. Accordions nest.

Why isirrational? Because a fraction for it would have to be reducible forever. Say more

Why isirrational? Ifin lowest terms, then, sois even; thenis even as well, and the fraction was not in lowest terms after all. The full argument Β· Less

Why isirrational? Supposewithpositive integers sharing no factor. Squaring,

sois even, henceis even:. Then, sois even andis even too – contradicting thatandshare no factor. Back to the short answer

\begin{webaccordion}[initial=short]
\begin{webpane}[short]
\noindent\textbf{Why is $\sqrt 2$ irrational?} Because a fraction for it
would have to be reducible forever. \webpanelink{longer}{Say more}
\end{webpane}
\begin{webpane}[longer]
\noindent\textbf{Why is $\sqrt 2$ irrational?} If $\sqrt 2 = p/q$ in lowest
terms, then $p^2 = 2q^2$, so $p$ is even; then $q$ is even as well, and the
fraction was not in lowest terms after all.
\webpanelink{full}{The full argument} \textperiodcentered{} \webpanelink{short}{Less}
\end{webpane}
\begin{webpane}[full]
\noindent\textbf{Why is $\sqrt 2$ irrational?} Suppose $\sqrt 2 = p/q$ with
$p, q$ positive integers sharing no factor. Squaring,
\[ p^2 = 2q^2 , \]
so $p^2$ is even, hence $p$ is even: $p = 2r$. Then $4r^2 = 2q^2$, so
$q^2 = 2r^2$ is even and $q$ is even too -- contradicting that $p$ and $q$
share no factor. \webpanelink{first}{Back to the short answer}
\end{webpane}
\end{webaccordion}

Looks and motion

Switching panes is animated: the accordion’s height eases from one pane to the next, the old pane fades out and the new one slides in. The text after the accordion moves with it. Readers who ask their system for less motion get a plain switch. The look is chosen in the source. variant=card draws a filled box, outline a box with an edge only, and accent a coloured bar with a tint. motion= is slide (the default), fade or none. A CSS custom property can be set in the same place, such as the accent colour.

Is every even number above 2 a sum of two primes? Nobody knows. What is known

Is every even number above 2 a sum of two primes? This is Goldbach’s conjecture, checked by computer up to. Every odd number above 5 is a sum of three primes (Helfgott, 2013). Less

\begin{webaccordion}[variant=accent, motion=fade, --rtx-accent=#c2410c]
\begin{webpane}[question]
\noindent\textbf{Is every even number above 2 a sum of two primes?}
Nobody knows. \webnextpane[What is known]
\end{webpane}
\begin{webpane}[answer]
\noindent\textbf{Is every even number above 2 a sum of two primes?}
This is Goldbach's conjecture, checked by computer up to $4 \cdot 10^{18}$.
Every odd number above 5 is a sum of three primes (Helfgott, 2013).
\webprevpane[Less]
\end{webpane}
\end{webaccordion}

The same settings work from a stylesheet, for a whole site or one kind of block. The companion’s stylesheet defines a few tokens that everything else is made of:

:root {
  --rtx-accent: #2f6fdb;          /* the accent bar */
  --rtx-radius: 6px;              /* corners of every box */
  --rtx-duration: 200ms;          /* every movement */
}
.latex-stream[data-kind="accordion"] {
  --rtx-accordion-motion: fade;   /* slide Β· fade Β· none */
  --rtx-box-padding: .6em 1em;    /* this kind's boxes only */
}
/* The pane showing, and each pane's state, are on the elements: */
.rtx-accordion[data-pane="answer"] { … }
.rtx-pane[data-state="open"] { … }

In print

A PDF prints one pane: the last, the fullest, unless print= names another. The links are left out, and so is anything inside them: the proof above puts its link in its heading, [\proofname\webpanelink{prev}{ (hide)}], with the space inside the link, so the PDF reads Proof. and nothing more. Printing the web page shows the same pane as the PDF. The option initial= picks the pane shown first (default: the first).