(a) puts a header with optional argument on a colored background and
(b) frames the content.
Code: Select all
\listfiles
\documentclass{article}
\usepackage{amsmath}
\usepackage{tikz}
\usepackage{lipsum}
\makeatletter
\newtheorem{theo}{Theorem}[section]
\newsavebox{\header}
\newsavebox{\content}
\newenvironment{theorem}[1][]
{%
\refstepcounter{theo}
% Save the text for the theorem header, with optional argument, in box \header
\begin{lrbox}{\header}
\textbf{Theorem \thetheo} \@ifnotempty{#1}{\textbf{(#1)}}
\end{lrbox}
% Save the text for the theorem body in box \content
\begin{lrbox}{\content}
\begin{minipage}[!h]{0.95\textwidth}
}%
{%
\end{minipage}
\end{lrbox}
\begin{tikzpicture}
\node[draw = blue!20, text = black, very thick, rectangle, inner sep = 10pt, inner ysep = 20pt] (box) {\usebox{\content}};
\node[draw = none, text = black, fill = blue!20, right=0pt] at (box.north west) {\usebox{\header}};
\end{tikzpicture}
}%
\makeatother
\begin{document}
\section{First section}
\begin{theorem}[Nice theorem]
\lipsum[1]
\end{theorem}
\section{Second section}
\begin{theorem}
\lipsum
\end{theorem}
\end{document}
Can I make it do so without a bottom line on the page that contains the first part of the theorem and without a top line on the second?
The mdframed package seems to do this, but I don't see how to include this into my environment.
Mark Voorneveld