Ajustar o texto ao tamanho específico exato

Ajustar o texto ao tamanho específico exato

Gostaria de fazer com que meu texto se ajustasse a uma "caixa" de determinado tamanho em um local específico. Os dois problemas que estou encontrando são os seguintes:

Essa longa string deve quebrar quando atingir o limite de 4,5 polegadas, mas isso não acontece:

\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}

E este permanece constante, mas eu gostaria de forçá-lo a caber em toda a caixa de 4,5 pol. x 5,875 pol., como ampliar o texto para que caiba na caixa.

\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}

Obrigado pela ajuda.

Responder1

Este poderia ser um trabalho para ofitboxopções de pacote tcolorbox. Conforme comentado, seu primeiro texto precisa de hifenizações. Mas seu segundo texto pode ser dimensionado usando o código a seguir. Adicionei um fundo amarelo para mostrar a caixa de 4,5 pol. x 5,875 pol.

Observe que incluí um pacote de fontes escalonáveis ​​( lmodern) para ativar o mecanismo de dimensionamento de fontes.

\documentclass[landscape]{article}
\usepackage[top=1.5in, bottom=1.125in, left=.25in, right=6.25in,textwidth=4.5in, textheight=5.875in]{geometry}
\usepackage{lmodern}% for scalable fonts!
\usepackage[many]{tcolorbox}

\begin{document}
\tcboxfit[blank,width=4.5in,height=5.875in,
  fit basedim=20pt,fit fontsize macros,valign=center,
  frame style={fill=yellow!50!white}% remove this line to remove the yellow background
]%
{\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}

insira a descrição da imagem aqui

O primeiro código adapta a fonte para caber no texto dentro da caixa fornecida. Ainda assim, na parte superior e inferior da caixa permanecem duas pequenas áreas em branco. Se for importante removê-los, um alongamento final pode ser adicionado usando o código a seguir. Observe que a caixa externa serve apenas para colorir o exemplo.

\documentclass[landscape]{article}
\usepackage[top=1.5in, bottom=1.125in, left=.25in, right=6.25in,textwidth=4.5in, textheight=5.875in]{geometry}
\usepackage{lmodern}% for scalable fonts!
\usepackage[many]{tcolorbox}

\begin{document}
\tcbox[blank,width=4.5in,height=5.875in,frame style={fill=yellow!50!white}]{% just for the background
%
\resizebox{4.5in}{5.875in}{\tcboxfit[blank,width=4.5in,fit height from=5in to 5.875in,fit basedim=20pt,fit fontsize macros]%
{\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....}}
%
}% just for the background
\end{document}

insira a descrição da imagem aqui

informação relacionada