[texhax] Command to find optimum font size of text.

Ulrike Fischer news3 at nililand.de
Thu Nov 12 14:37:50 CET 2015


Am Thu, 12 Nov 2015 07:19:35 -0500 schrieb Gerard E. Seibert:

> I seriously doubt that this can be done; however, I thought I would ask
> anyway.
> 
> We have commands like "\vfill" and "\hrulefill", etcetera that fill a space
> to its maximum capacity. Now, I would like to know if something like that
> exists that can take a "text" phase and and enlarge or decrease its font size
> to fill a predefined space.
> 
> Example, I have a table that has a cell that is 3 inches wide. I want the
> text I enter in that cell to appear as large as possible in that space. I
> can, of course, experiment until I find the optimum size; however, a function
> that did it automatically would be a time saver.
> 
> As I stated, I don't believe anything like that exists, but it doesn't hurt
> to ask.

http://tex.stackexchange.com/questions/26002/fit-text-into-given-box-by-adjusting-the-fontsize

For longer text you can also e.g. use tcolorbox:

\RequirePackage{fix-cm}
\documentclass[a4paper,11pt]{report}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[many]{tcolorbox}
\usepackage{lipsum}
\begin{document}
\begin{tcbraster}[raster columns=3,raster valign=bottom]
\tcboxfit[height=8cm]{\lipsum[1]}
\tcboxfit[height=4cm]{\lipsum[1]}
\tcboxfit[height=2cm]{\lipsum[1]}
\end{tcbraster}
\end{document}

See also
http://tex.stackexchange.com/questions/271829/fit-text-within-a-frame-with-fixed-dimension-shrink-only-if-needed

-- 
Ulrike Fischer 
http://www.troubleshooting-tex.de/



More information about the texhax mailing list