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
.
\documentclass{article}
\usepackage{xcolor}
\usepackage{environ}
\usepackage{mdframed}
\usepackage{lipsum}
\usepackage{calc}
\makeatletter
\newcommand\singlelipsum[1]{%
\begingroup\let\lips@par\relax\csname lipsum@\@roman{#1}\endcsname
\endgroup }
\makeatother
\newcommand*{\MinimumHeight}{3cm}%
\def\dH{18pt}
\newcommand\headerheight[1]{\heightof{\parbox[b]{\textwidth}{\strut#1\strut}}}
\NewEnviron{MyEnvironment}[1][]{%
\begin{mdframed}[
frametitlebackgroundcolor=brown!25,
frametitlerulecolor=blue,
frametitlerulewidth=1.0pt,
backgroundcolor=yellow!25,
#1
]
\tabcolsep=0pt\relax
\begin{tabular}{cp{\textwidth}}\mystrut{#1}&
\BODY
\end{tabular}
\end{mdframed}
}
\def\mystrut#1{\rule[\heightof{\strutbox}-\MinimumHeight+\headerheight{#1}+\dH]{0ex}
{\MinimumHeight-\headerheight{#1}-\dH}}
\begin{document}
\noindent\rule{\MinimumHeight}{.1ex} This is the MinimumHeight (sideways)
\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}]
\singlelipsum{1}
\end{MyEnvironment}
\end{document}
To supplement the answer of Harish Kumar, the packages empheq
and tcolorbox
can by used in symbiosis. empheq
allows to specify any box to mark the given equations. For the box you may insert any tcolorbox
which behaves like fbox
. Typically, such boxes are based on the \tcbox
macro (like \tcbhighmath
in the answer of Harish Kumar).
I think, the following example demonstrates what you can do. The singleline equation is boxed with \tcbhighmath
directly, the multiline equations (align
) are boxed using empheq
in conjunction with \tcbhighmath
and some other \tcbox
-based examples.
\documentclass{article}
\usepackage[svgnames,hyperref]{xcolor}
\usepackage{empheq}
\usepackage[many]{tcolorbox}
\tcbset{highlight math style={enhanced,
colframe=red!60!black,colback=yellow!50!white,arc=4pt,boxrule=1pt,
drop fuzzy shadow}}
\newtcbox{\otherbox}[1][]{nobeforeafter,math upper,tcbox raise base,
enhanced,frame hidden,boxrule=0pt,interior style={top color=green!10!white,
bottom color=green!10!white,middle color=green!50!yellow},
fuzzy halo=1pt with green,#1}
\newtcbox{\picturebox}[1][]{nobeforeafter,math upper,tcbox raise base,
enhanced,watermark graphics=example-grid-100x100bp.jpg,% from package mwe
colback=white,frame hidden,boxrule=0pt,arc=10pt,
watermark stretch=1.00,watermark opacity=0.4,#1}
\begin{document}
\begin{equation}
\tcbhighmath{E = mc^2}
\end{equation}
\begin{empheq}[box=\tcbhighmath]{align}
a&=b\\
E&=mc^2 + \int_a^a x\, dx
\end{empheq}
\begin{empheq}[box={\tcbhighmath[colback=blue!20!white]}]{align}
a&=b\\
E&=mc^2 + \int_a^a x\, dx
\end{empheq}
\begin{empheq}[box={\tcbhighmath[watermark text=?!,watermark color=yellow!90!red]}]{align}
a&=b\\
E&=mc^2 + \int_a^a x\, dx
\end{empheq}
\begin{empheq}[box=\otherbox]{align}
a&=b\\
E&=mc^2 + \int_a^a x\, dx
\end{empheq}
\begin{empheq}[box=\picturebox]{align}
a&=b\\
E&=mc^2 + \int_a^a x\, dx
\end{empheq}
\end{document}
Best Answer
You can use the
mdframed
optionsalign=center,userdefinedwidth=...
.