I would like my mdframed
boxes from MyEnvironment
to have a minimum total (title+body) height. The height can be greater (if the content warrants it), but not smaller than a certain size.
I can probably hack up a solution by
- Typesetting the
mdframed
into a\savebox
, - Measuring it, and
- Re-typsetting it with an appropriate
\vspace
inserted,
but wondering if there is a less hackish way to accomplish this.
The MWE produces the following, but the desired output would have blank space after the content body so that the height is the value set in \MinimumHeight
.
Since the last box height is already greater than \MinimumHeight
is should not be changed.
Notes:
- The minimum height is a fixed constant known before compile time.
References:
- This seems related: Fix the height/length of a minipage, but not quite what I desire.
Code:
\documentclass{article}
\usepackage{xcolor}
\usepackage{environ}
\usepackage{mdframed}
\usepackage{lipsum}
\newcommand*{\MinimumHeight}{5.0cm}%
\NewEnviron{MyEnvironment}[1][]{%
\begin{mdframed}[
frametitlebackgroundcolor=brown!25,
frametitlerulecolor=blue,
frametitlerulewidth=1.0pt,
backgroundcolor=yellow!25,
#1
]
\BODY
\end{mdframed}
}
\begin{document}
\begin{MyEnvironment}[frametitle={Short Title}]
Some text for first paragraph.
Some more text for other paragraphs.
\end{MyEnvironment}
\begin{MyEnvironment}[frametitle={Some much longer title that takes up more than one line in the title frame}]
Some text for first paragraph.
\end{MyEnvironment}
\begin{MyEnvironment}[frametitle={Title of frame with much text}]
\lipsum[1]
\end{MyEnvironment}
\end{document}
Best Answer
REVISED to account for height of title, and space from
\fboxsep
like things.While not relevant to the solution presented, but only to your MWE, the use of the newly created
\singlelipsum
command is to avoid the\par
that otherwise accompanies the end of a\lipsum
.