Page Layoutautosize fonts

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
Post Reply
efo
Posts: 3
Joined: Sat Sep 19, 2009 12:06 am

autosize fonts

Post by efo »

Hi guys,

I was wondering if there is a way to fit a text into a box (or something else) by automatically reducing or increasing the font size. For instance, I specify a 2inx2in box and the text I want in it; and the font size that best fits the box is automatically selected.

Thanks,

Efo

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

frabjous
Posts: 2064
Joined: Fri Mar 06, 2009 12:20 am

autosize fonts

Post by frabjous »

You could try \resizebox from the graphicx package. See its documentation, page 7:

Code: Select all

\resizebox{1in}{!}{Some text}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
This will give "Some text" which is exactly 1 inch long. The ! for the second argument means to vary the height by whatever it needs to in order to maintain the aspect ratio. If you did {!}{1in} it would be 1 inch tall instead. If you specify both parameters, it'll be stretched disproportionally so that it is exactly a rectangle of that size, and so on.
Post Reply