TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How can I reproduce the figure below?

alt text

The figure is from an old Knuth paper, which you can get at http://www.math.lsa.umich.edu/~millerpd/docs/501_Winter08/Knuth79.pdf (page 364)

share|improve this question
up vote 7 down vote accepted

http://www.tug.org/texshowcase/, search for "diminuendo.tex"

share|improve this answer

with LaTeX instead of plain TeX:



\newcount\cntm \cntm=1
  \scalebox{\Scale}{#1}\ifnum\the\cntm=1 \kern-10pt\fi%
  \advance\cntm by \@ne%



alt text

share|improve this answer

This code iterates over each token in a string and scales them according to a user-defined function:


\usepackage{graphicx} % For \scalebox
\usepackage{pgf}      % For arithmetic calculations

% Here are the macros to parse the string character-by-character:

% This macro will be called on each character of the string:


Here is the result such that token i is scaled by a factor of 6/(i+2): 3.1415926535897932384626

share|improve this answer

An eTeX based solution

\currentStep = 1

% Do not increment step at 2nd iteration
  {\ifnum\currentStep = 2 
    \else \increment\currentStep


\handletokens 3{\kern-0,2em.\kern-0.1em}1415926535897932384626 \with\Show

alt text

share|improve this answer
You mean a ConTeXt-based solution? – Will Robertson Jan 23 '11 at 0:46
No. It is essentially identical to Herbert's solution, but using \dimexpr instead of the fp package. I wrote the solution in ConTeXt, just because that is what I know better. It should be easily to replicate it in plain or LaTeX. Doesn't the graphics package have a macro to scale a box to a particular width? – Aditya Jan 23 '11 at 1:31

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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