2013 0004 0003
There are some truly impressive LaTeX solutions for doing
PowerPoint-style font-resizing to fit into a fixed width box. I
recently had need of something more simple: print text on one line
only, scaling the size down instead of allowing it to wrap. The
following LaTeX snippet does exactly this, triggered only if the font
width (before wrapping) exceeds
to handle the
It works like you might expect: check the width of the text, and then
\resizebox to scale it down, if needed. Such logic isn’t always
obvious in LaTeX: arbitrary
defs cannot store length information, so
you have to set the type of the
\namewidth variable as a dimension
before you can assign/test it as a length.
As with most helpful things in LaTeX, we can wrap it up in a reusable macro:
On any reasonable-sized page width, these two lines will not wrap, but the longer line will be stretched horizontally to fit in the available space.
You can find a fully-working (as of TeXLive 2012) gist here.