In the LATEX book, I have examples printed side-by-side with their source code. This is managed by setting a pair of \vbox
es inside an \hbox
inside displayed math so I could take advantage of the display math spacing before and after. While working on the chapter on \newtheorem
I noticed that the cross-reference information was coming out wrong. It was somehow picking up the number of the subsection (the fact that it’s unnumbered and shouldn’t be calling \refstepcounter
in the first place is its own issue I need to track down but never mind that for now). After far too long digging into source code (remember, \ShowCommand
is your friend), I realized that what was happening was that I was getting the special handling of \label
inside display math from the amsmath
package. The simple fix was to change the \[
…\]
entry into display math to $$
…$$
.
Month: July 2021
For completeness’s sake, I should mention here that I opened a kickstarter for Volume 1 of The Preppy Lion (the LATEX guide for authors). It’s fully funded, but this is a chance to pre-order the book at a lower price than it will be available at post-publication.
I’m setting the body of my LATEX book in Monotype Ehrhardt. I have a long sentimental attachment to this typeface and I’m on my second purchased copy of the face (I bought it originally in PC Type 1 format and now I have the Opentype version on my Mac). Unfortunately, I decided to cheap out and I didn’t buy the Pro version of the font since I figured I wouldn’t need the Eastern European accents. Oops, it turns out that I do kind of want to have access to hačeks and also the macron accent for a section where I talk about mahāprañāpāramita. But how to get these? Well, the macron accent wasn’t even present in the font, giving a missing character symbol where the accent should appear, so I decided, given its typographic simplicity, that I’d “borrow” it from Latin Modern which I knew had the character.
The thing is, the \accent
primitive is a finicky beast. As anyone who’s ever tried to do something like \’{\textbf{a}}
would know, you can’t just throw anything inside an accent command. Instead, a more subtle approach is necessary. Thankfully, this already exists thanks to the \t
accent. Here’s the definition from plain.tex
:
\def\t#1{{\edef\next{\the\font}\the\textfont1\accent"7F\next#1}}
What’s happening here is that TEX saves the current font in the \next
macro, changes to \textfont1¹
and issues the accent command and then returns the font to the saved font.² I ended up doing the following in my class file to give me access to the accent from Computer Modern (well, actually Latin Modern).
{\fontfamily{lmr}\selectfont
\xdef\thelmrfont{\the\font}}
\def\=#1{{\edef\@tempa{\the\font}\thelmrfont\accent"0304\@tempa#1}}
I could have gotten away with replacing the whole song and dance around \thelmrfont
by using \csname TU/lmr/m/n/10\endcsname
but I want the flexibility to adjust the font—I’m already thinking that changing the size to, e.g., 9.5pt might not be a bad idea to make the accent blend better with the provided ñ.
\textfont1
is math italic in plain TEX.\the\font
or\the\textfont1
expand to the command to load the appropriate font, which under LaTeX will be an otherwise difficult to obtain name like\TU/lmr/bx/n/10
.