# How can I progressively scale letters?

How can I reproduce the figure below?

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)

-

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

-

with LaTeX instead of plain TeX:

\documentclass[landscape]{article}
\usepackage[T1]{fontenc}
\usepackage[a4paper]{geometry}
\usepackage{lmodern}
\usepackage{graphicx}
\usepackage{fp}

\newcommand*\PIfrac{141592653589793238462643383279502884197169399375105820974!!}

\pagestyle{empty}
\makeatletter
\newcount\cntm \cntm=1
\def\printNum#1{\expandafter\printNum@i#1\@nil}
\def\printNum@i#1#2#3\@nil{%
\FPdiv{\Scale}{1}{\the\cntm}%
\typeout{==:\Scale}%
\scalebox{\Scale}{#1}\ifnum\the\cntm=1 \kern-10pt\fi%
\ifx#2!\else\expandafter\printNum@i#2#3\@nil\fi}
\makeatother
\begin{document}

\fontsize{6cm}{5.2cm}\selectfont
\scalebox{1.5}{3\kern-15pt,}\kern-20pt\printNum{\PIfrac}

\end{document}


-

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

\documentclass{minimal}

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

% Here are the macros to parse the string character-by-character:
\newcounter{numcharacters}
\def\decreasing#1{\setcounter{numcharacters}{0}\decreasinginternal{#1}}
\def\decreasinginternal#1{\ifx#1\relax\else\decreasingchar#1\enddecreasing\fi}

% This macro will be called on each character of the string:
\def\scaleString#1#2{\pgfmathparse{6/(#2+2)}\scalebox{\pgfmathresult}{#1}}

\begin{document}
\decreasing{3.1415926535897932384626}%
\end{document}


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

-

An eTeX based solution

\newcount\currentStep
\currentStep = 1

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

\def\Show#1%
{\dontleavehmode\scale[width=\the\dimexpr\bodyfontsize/\currentStep\relax]{\hbox{#1}}%

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