I would like to make my text fit a certain size "box" at a specific location. The two problems I am encountering are as follows:
This long string should wrap when it hits the 4.5 inch limit but it does not:
\documentclass[landscape]{article}
\usepackage[top=1.5in, bottom=1.125in, left=.25in, right=6.25in,textwidth=4.5in, textheight=5.875in]{geometry}
\begin{document}
ddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd
\end{document}
And this one just remains constant but I would like to force it to fit the entire 4.5in x 5.875in box, as in enlarge the text to make it fit the box.
\documentclass[landscape]{article}
\usepackage[top=1.5in, bottom=1.125in, left=.25in, right=6.25in,textwidth=4.5in, textheight=5.875in]{geometry}
\begin{document}
{\Huge This should fit in a 4.5in x 5.875in box but that is close to the left edge of paper, but it is not conforming to the box size desired....
\end{document}
Thanks for the help.
Best Answer
This could be a job for the fitbox options of package
tcolorbox
. As commented, your first text needs hyphenations. But your second text can sized using the following code. I added a yellow background to show the 4.5in x 5.875in box.Note that I included a scalable font package (
lmodern
) to enable the font scaling mechanism.The first code adapts the font to fit the text inside the given box. Still, at the top and bottom of the box remain two very small blank areas. If it is important to remove them, a final stretching can be added using the following code. Note that the outer box is just for coloring the example.