In my document I want to emphasize some key points by placing them in a box with rounded corners. This I do using the following code:
\documentclass{report}
\usepackage{fancybox}
\begin{document}
\ovalbox{
\begin{minipage}[c][.35\textwidth]{.5\textwidth} % [text in box][height][width]
\begin{center}
\begin{minipage}[c]{.9\textwidth}
This text might be too large to fit into the (.35x.50)$\cdot$textwidth box,
in which case the font size should be decreased to make it fit.
\end{minipage}
\end{center}
\end{minipage}
}
\end{document}
The dimensions of the box I would like to have fixed. When the text now becomes too big for the box, can I let LateX notice that and have it adjust the font size such that it does fit?
I was made aware of this fit-text-into-given-box-by-adjusting-the-fontsize question, but have not been able to transform the answer it into a workable solution for me (i.e. getting an \ovalbox
around it).
Further have I noticed that paragraphs in the proposed solutions are not indented anymore, how can that be avoided?
Best Answer
Here are some explanations. First of all, the
\NewEnviron
-defined environment gathers its contents. This contents is typeset in a "private" box and if it fits the size requirements it's passed for final typesetting; otherwise we try at a size half a point less and redo until the requirements are respected. One can redefine\WARNING
as wished; it will be come into action when the recursion is started and the font is already at 5pt size.