Only time for a short post. Foreign words are italicized frequently in English; however, et al., i.e., e.g., and etc. probably should not be. It draws unnecessary attention to the words and modern style manuals will tell you not to… Continue Reading →
This is silly. There are better ways to do it. Still, it was sort of fun to write. \endlinechar=-1 \newread\in \newwrite\out \message{Please enter input file name: } \read16to\inname \openin\in=\inname \relax \ifeof\in \immediate\write16{Failed to open \inname.} \expandafter\end \fi \message{Please enter output… Continue Reading →
University thesis committees are fairly well-known in the typesetting world for having the most absurd requirements. One example requires heading text to be typeset centered and no more than 4.5 in wide in which the lines become progressively shorter. This… Continue Reading →
One thing that I dislike about LaTeX’s output—especially in two columns—is that lines of prose are not typeset on a grid. I’m hoping to do a series of posts on little things that can be done to improve the situation…. Continue Reading →
It’s probably fairly uncontroversial to say that floats are one of the main areas where LaTeX performs poorly in comparison to WYSIWYG editors. The basic complaint is that floats just don’t go where we want them. To compensate for this,… Continue Reading →
Somewhat mysteriously, in the middle of the chapter on macros in The TeXbook, Knuth defines \rhead—the macro he uses to keep track of the running headline. The definition itself is a little odd in that when \rhead is executed, it… Continue Reading →
Recent versions of pdfTeX contain primitives for generating random integers. \pdfuniformdeviate num generates a uniformly distributed random integer in the range [0, num). \pdfnormaldeviate generates a normally distributed random integer with mean 0 and “a unit of 65536”. (I’ve never… Continue Reading →
When quoting Lamport about writing Greek letters being as easy as writing “… as easy as $\pi$” in The TeXbook, Knuth cites the book as LaTeX Document Preparation System. He comments, Note: the final manual has a slightly different wording… Continue Reading →
Some time ago, I gave recommendations for packages to use to produce output in Times roman fonts (and others that look nice with Times). Doing this has the downside that certain aspects of the Times math fonts are really ugly…. Continue Reading →
One of the most commonly asked questions is how to change font sizes in LaTeX beyond those offered by \tiny through \Huge. There are a number of different font parameters that can be selected using the New Font Selection Scheme…. Continue Reading →
Here’s a great one from the source code to TeX. It’s the beginning of section 1154. The simplest math formula is, of course, ‘$ $’, when no noads are generated. The next simplest cases involve a single character, e.g., ‘$x$’…. Continue Reading →
Okay, this one isn’t a comment in code, yet it amuses me anyway. This is Exercise 24.1 in The TeXbook. Can you think of a reason why you might want ‘A12’ to be a ‹hex digit› even though the letter… Continue Reading →
Scattered throughout Knuth’s programs are a number of great comments. I really enjoy encountering these and I thought I’d share them. (As I wrote in my first post, this blog is mostly a way for me to collect pieces of… Continue Reading →
As currently implemented in LaTeX, \mbox and \fbox (among others) have a bizarre limitation: their arguments cannot change category codes. One practical consequence of this is that \verb is not allowed in the arguments. This limitation is completely artificial and… Continue Reading →
Two things that annoyed me with making LaTeX packages using a .dtx file were the duplication of the copyright/license info and that nearly every line in the file was commented out. About the only thing that wasn’t commented out was… Continue Reading →
I’m not totally sure why one would want to center the last line in a paragraph, but the excellent TeX by Topic provides a surprising solution. \leftskip=0pt plus.5fil \rightskip=0pt plus-.5fil \parfillskip=0pt plus1fil The reason this works is that for all… Continue Reading →
The simplest way to count the number of lines in a file seems to be to use the ε-TeX primitive \readline. (One could probably get away with using the TeX primitive \read instead, but that reads lines according to the… Continue Reading →
Unfortunately, the current version of pdfTeX is lacking a \expanded primitive that would fully expand its argument, similar to the full expansion that happens for the replacement text of an \edef. However, there is a trick that will keep expanding… Continue Reading →
Everybody loves a good quine. The most obvious, and most cheating way to write a “quine” In LaTeX is to use the listings package. \documentclass{article} \usepackage{listings} \lstset{language=[LaTeX]TeX} \begin{document} \lstinputlisting{\jobname} \end{document} This is not very exciting and it’s cheating on two… Continue Reading →
The TeX primitive \number will convert anything that can be converted to a number into a decimal number and what’s more, it is expandable. That is \edef\foo{\number\count37} will define \foo to be whatever the value of count register 37 is…. Continue Reading →
As LaTeX tutorials are quick to point out, \vspace{x} can disappear at the top or bottom of pages. This is because each \vspace expands to two \vskips which are discardable. Thus, if you write \vspace{3in} near the bottom of the… Continue Reading →
By popular demand, here is the Sieve of Eratosthenes written in Plain TeX. \newcount\cm\cm100 \newcount\ci \newcount\cj \def\prime{prime} \def\composite{composite} \def\set#1#2{\global\expandafter\let\csname s\number#1\endcsname#2} \def\get#1{\csname s\number#1\endcsname} \def\doprime{% \set\ci\prime \cj\ci \loop \advance\cj\ci \ifnum\cj<\cm \set\cj\composite \repeat } \ci2 \loop\ifnum\ci<\cm \expandafter\ifx\csname s\number\ci\endcsname\relax \begingroup \doprime \endgroup \fi \advance\ci1… Continue Reading →
Someone asked about the architecture of LaTeX. After avoiding the question for a day, I decided to answer. Since it’s possible the question will be closed and possibly deleted, I figured I’d reproduce the relevant portion of my answer here…. Continue Reading →
I have two versions of my cv: one for public consumption and one which contains extra private bibliography entries for work that is in submission. Obviously these are mostly the same so I had one one that had a \newif\ifpublic… Continue Reading →
On occasion, one has cause to compare two boxes and compute the maximum of the two widths. If the two boxes are 0 and 2, then the standard way to do that is something like \ifdim\wd0>\wd2 \dimen0 \wd0 \else \dimen0… Continue Reading →
© 2025 TeX.social