
特定の場所の特定のサイズの「ボックス」にテキストを収めたいのですが、次のような 2 つの問題が発生しています。
この長い文字列は 4.5 インチの制限に達すると折り返されるはずですが、そうではありません。
\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}
これは一定のままですが、テキストを拡大してボックスに収まるようにし、4.5 インチ x 5.875 インチのボックス全体に強制的に収まるようにしたいと思います。
\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}
助けてくれてありがとう。
答え1
これは、フィットボックスパッケージのオプションtcolorbox
。コメントされているように、最初のテキストにはハイフネーションが必要です。ただし、2 番目のテキストは次のコードを使用してサイズを変更できます。4.5 インチ x 5.875 インチのボックスを表示するために黄色の背景を追加しました。
lmodern
フォントスケーリングメカニズムを有効にするために、スケーラブルフォントパッケージ ( ) を含めたことに注意してください。
\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}
最初のコードは、指定されたボックス内のテキストに合わせてフォントを調整します。それでも、ボックスの上部と下部には非常に小さな空白領域が 2 つ残ります。これらを削除することが重要である場合は、次のコードを使用して最終的な伸縮を追加できます。外側のボックスは、例の色付けのみを目的としていることに注意してください。
\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}