Thesis II: Explaining Chains of Inequalities
which the margin is not too small to contain.
This post is on how I like to explain long chains of inequalities in
papers, and the changes I made to kaobook to move these
explanations to the margins.
My usual setup
Usually, I like to tag a sequence of inequalities in my papers with explanations of how each one arises. For example, the page below mentions the lemmas or properties that are used to obtain one line of the chain of inequalities from the previous line.
In papers, I like to explain how a chain of inequalities arise as in this figure.
The first chain at the top of the page is obtained using something like the following
\begin{align*}
\x{t}
&= \sum_e \xe{t}
= [...] \\
&\le [...] \tag{by \cref{lem:ApxLoad}} \\
&\le [...] \tag{by \cref{lem:OracleReturn}}\\
&\le [...] \tag{\qedhere}
\end{align*}
The final \qedhere is just to make sure that the box
that finishes the proof environment stays on the last line of the
align* environment and doesn’t create a new blank line in
the proof which, imo, looks ugly.
Directly using this in kaobook
When implemented directly in kaobook, it looks like
this.
First attempt at using the above strategy directly in kaobook.
The point of kaobook is to use the margins to explain things, so this
was a great opportunity to use the explanations I already had in my
papers directly to fill up the margins. For this, I added the following
in my headers (before \begin{document}), in particular I
separately included it in a formatting.tex file that I
include before the \begin{document}. I stole this by
frankensmashing various stack exchange answers together.
\makeatletter
\newcommand{\leqnomode}{\tagsleft@true\let\veqno\@@leqno}
\newcommand{\reqnomode}{\tagsleft@false\let\veqno\@@eqno}
\if@twoside%
\def\maketag@@@#1{%
\iftagsleft@%
\hbox{\llap{\kern-\marginparsep\m@th\normalfont#1}\kern1sp}%
\else%
\hbox{\rlap{\kern\marginparsep\m@th\normalfont#1}\kern1sp}%
\fi%
}
\def\taggableenvs{equation,equation*,align,align*,alignat,alignat*}
\@for\env:=\taggableenvs\do{%
\AtBeginEnvironment{\env}{\Ifthispageodd{\reqnomode}{\leqnomode}}%
}
\else%
\def\maketag@@@#1{\hbox{\rlap{\kern\marginparsep\m@th\normalfont#1}\kern1sp}}%
\fi
\makeatother
It checks if you are in two-sided mode, and moves the tag outside the correct margin. Then, the same page looks the like following in two-sided and one-sided mode respectively.
Equation tags for the same page in verso and recto with the above code in kaobook.
I haven’t had the misfortune of trying to read this for the first time to see if it helps explain things better, but I think (more like hope) it does. Maybe once I forget the things here I’ll come back and see if it helps.
Comments