Given Donald Knuth's legendary sense of humor, one cannot help but suppose he would have succumbed to the temptation to add in a "special" command or two that did something unsuspected or unusual just for the fun of it. (And I don't just mean some cute or funny source code comments, but something that actually does something.)

And if not him, then surely someone in the community who has made an extension, document class, package or subversion of TeX, LaTeX, ConTeXt, or a helper program like an editor, etc., decided to have a little fun and throw in an Easter Egg.

Yet, at the moment, I cannot think of a single one. Does anyone know of any?

  • 7
    I see this less as a question, and more as a call to arms for all package writers! But perhaps given the danger of incompatibility between packages and things of that sort, easter eggs would be more annoying than cute, if they led to inexplicable errors... – Seamus Jan 20 '11 at 13:20
  • 11
    also, +1 for the knuth tag... – Seamus Jan 20 '11 at 13:23
  • 3
    It's still January and you are already searching for easter eggs! Be patient! ;-) – Caramdir Jan 20 '11 at 15:38
  • 6
    Just found this old post. What about TeX error messages (and some of their explanations in The TeXbook)? "If you get this error message, you know why, and you deserve no sympathy." (quoting from memory) – mbork Dec 28 '11 at 14:49
  • 15
    @mbork The right quote is: If you have been so devious as to get this message, you will understand it, and you deserve no sympathy. Is there someone who has never had this error message? What can be the procedure to obtain it? – Jean Baldraque Oct 2 '12 at 16:06

This is not quite an answer, but I just wrote the following code, that redefines a command to turn its argument by a random angle

Namely, \easteregg\footnote declares all footnotes to rotate their text by a random amount (between -10 and +10 degrees).

  \expandafter\let\csname old\string#1\endcsname#1%
    \csname old\string#1\endcsname{\protect\globalrand\protect\turnbox{\value{rand}}{##1}\protect\phantom{##1}}}%



\section{More test}

\emph{Some} \emph{emphasized} \emph{text}, 
\emph{with} \emph{random} \emph{directions}

  • 1
    +1 for taking up the challenge, though as you point out it's not quite an answer... – frabjous Jan 20 '11 at 20:51

While reading Computers & Typesetting Volume E: Computer Modern Typefaces, I found a piece of code that actually did something, and should definitely be counted as an Easter egg.

The METAFONT source for the lowercase Greek letter \gamma (see greekl.mf) reads

cmchar "Lowercase Greek gamma";
italcorr x_height#*slant-.5u#;
adjust_fit(0,0); pickup fine.nib;
pos1(hair,180); pos2(vstem+dw,90);
pos4(hair,0); pos5(vair,-90); pos6(hair,-180); pos7(hair,-180);
bot y1=.5772156649h; top y2r=h+oo; y4=y6=-.5d;
bot y5r=-d-o; top y7=h;
lft x1r=hround(.5u-.5hair); x2=3u; rt x4r=hround(w-2u); x5=.5[x4,x6];
rt x4r-lft x6r=hround 1/3[hair,stem]+eps; rt x7l=hround(w-u);
if x4l<x6l: x4l:=x6l:=x5; fi
pos3(hair,angle(z4-z2)+90); x3=superness[x2,x4]; y3=superness[y4,y2];
filldraw stroke z1e{up}...z2e{right}...z3e{z4-z2}
 ...z4e{down}...{left}z5e; % arc
filldraw stroke z5e{left}...z6e{up}..{2(x7-x6),y7-y6}z7e;  % stem
penlabels(1,2,3,4,5,6,7); endchar;

And we see where Knuth hides this Easter egg: The entering stroke (i.e., the left hook of \gamma) starts at about 57.72156649% of x-height above the baseline.

For those who are unfamiliar with the relevant mathematics: That’s the Euler–Mascheroni constant, which is denoted by $\gamma$ in standard literature. This makes the drawing of \gamma incredibly “meta” indeed.

The Euler–Mascheroni constant (also called Euler's constant) is a mathematical constant recurring in analysis and number theory, usually denoted by the lowercase Greek letter gamma (γ).


The numerical value of the Euler–Mascheroni constant, to 50 decimal places, is:

0.57721 56649 01532 86060 [...]


The lowercase Greek letter \pi has, in spirit, similar “surprises”:

cmchar "Lowercase Greek pi";
[...] pi_stroke; % hook and bar
pair v[]; v1=(z4-z5) xscaled 3.14159; v2=(z6-z7) xscaled 3.14159;
[...] endchar;

where the subroutine pi_stroke is defined in cmbase.mf as

def pi_stroke = pickup fine.nib;
 y1=x_height-x_height/3.141592653589793; y2=y3; top y3l=x_height;
 filldraw circ_stroke z3e---z2e...{x1-x2,3.14159(y1-y2)}z1e enddef;

To me, however, these appearances of 3.14159 are too “on the nose”. They have far less mystery as Easter eggs than the 0.57721 in \gamma.

  • Technically speaking, 3.14159 is involved whenever METAFONT draws a circle (or an arc of a circle), or whenever a “round pen” is picked. You’d probably call these 3.14159 “too trivial”.
  • Knuth has a well-known fascination about \pi. See, for instance, these public lectures (YouTube links): Why Pi? (2010) and Pi and The Art of Computer Programming (2019). So I’m not really surprised to find 3.14159 sprinkled here and there.
  • 2
    Nice find indeed! – egreg Nov 24 '20 at 16:26
  • 2
    Marvelous observation! – John Nov 24 '20 at 16:31

Given the limitations of the computers at the time TeX was coded, for example, memory space, I guess no one thought about useless commands that take memory space to serve as an easter egg.

But the meaning of the phrase `Easter Egg' might have changed over the years. And there might be a different interpretation of the phrase for users and programmers. I think the most appropriate definition from the view point of the Stanford group can be found in the Hacker's Dictionary by Eric Raymond: A message hidden in the object code of a program as a joke, intended to be found by persons disassembling or browsing the code. Sometimes the intention is not to make a joke but to give credits.

In this sense TeX contains an easter egg.

But this kind of easter eggs is for a certain group of people and probably like a trick of a magician it should not be explained to others. I decided to give some clues but I ask you to find the solution yourself and to have the fun.

The WEB source of TeX contains

The most important output produced by a run of TeX is the ``device independent'' (DVI) file that specifies where characters and rules are to appear on printed pages. The form of these files was designed by David R. Fuchs in 1979.

and later

The i byte is followed by four or more bytes that are all equal to the decimal number 223 (i.e., '337 in octal). TeX puts out four to seven of these trailing bytes, until the total length of the file is a multiple of four bytes, since this works out best on machines that pack four bytes per word; but any number of 223's is allowed, as long as there are at least four of them. In effect, 223 is a sort of signature that is added at the very end.

Binary digits (or bits) are often combined to sequences of three or four to form the octal digits (base 8; digits are 0-7) or hex digits (base 16; digits are 0-9 and A-F), resp.

David Fuchs explains the first version of the DVI format in an TUGboat article and again he wrote:

... which is followed by at least 4 bytes containing the number $223_{10}$ (which is '337 octal).

So maybe the octal value is a clue. Use a calculator in programmer's mode or enter 223 to octal in the Google search line to verify that his conversion is correct. He made a step in the right direction but one has to go twice as far to see the easter egg.

(Metafont has the same convention for GF files.)


I'm not sure if this happened by accident, but I don't think so. If I type tex -v the version number is PI, TeX 3.1415926. This seems to me like an easter egg, then I ended up googling for latex easter eggs and found this question. Hoped for some more but seems like they are well hidden :D

PS: I use Ubuntu 14.04 and installed texmaker and with it Latex I guess, not so sure but everything has been working great so far.

  • 1
    The TeX versioning scheme says than every new version is identified by adding a digit of PI. – Astrinus Dec 1 '16 at 15:57
  • 2
    I'm not sure, this is an easter egg. It's just how Prof. Knuth decided to do version numbering with increasing digits or pi. – samcarter_is_at_topanswers.xyz Dec 1 '16 at 15:57
  • I mean cmon. This is insane^^ and totally and easter egg :D – Hakaishin Dec 1 '16 at 16:20
  • Easter eggs are supposed to be sort of hidden, but this is common knowledge, isn't it? – cfr Dec 25 '20 at 1:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.