I've defined a theorem environment using the package mdframed
. However, I'd like the statement to be contained within a different box from the one which contains the proof.
Ideally, this would be the title frame. However, if I try to put more than one line of text inside it, the text just goes on horizontally, ignoring even \\
.
I've searched for examples both in the documentation of the package and online and I haven't found any that match what I want. Anyone knows if something like this can be done?
I provide here a minimal working example of my current environment:
\documentclass[11pt]{book}
\usepackage{amsthm}
\usepackage[utf8]{inputenc}
\usepackage[usenames,dvipsnames,table]{xcolor}
\usepackage{tikz}
\usepackage[framemethod=TikZ]{mdframed}
\mdfsetup{skipabove=\topskip,skipbelow=\topskip}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Definition of the theorem environment %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcounter{theo}[chapter]\setcounter{theo}{0}
\renewcommand{\thetheo}{\arabic{chapter}.\arabic{theo}}
\makeatletter
\newenvironment{teorema}[1][]{%
\stepcounter{theo}\protected@edef\@currentlabel{\thetheo}%
\ifstrempty{#1}%
{\mdfsetup{%
frametitle={%
\tikz[baseline=(current bounding box.east),outer sep=0pt]
\node[anchor=east,rectangle,rounded corners,fill=Violet!20,draw= Violet!50, double= Violet!50]
{\strut Teorema~\thetheo};}}
}%
{\mdfsetup{%
frametitle={%
\tikz[baseline=(current bounding box.east),outer sep=0pt]
\node[anchor=east,rectangle,rounded corners,fill=Violet!20,draw= Violet!50, double=Violet!50]
{\strut Teorema~\thetheo:~#1};}}%
}%
\mdfsetup{innertopmargin=10pt,linecolor=Violet!50,backgroundcolor=Violet!5,%
linewidth=2pt,topline=true,
frametitleaboveskip=\dimexpr-\ht\strutbox\relax,roundcorner=10pt}
\begin{mdframed}[]\relax%
\vspace{-0.25cm}}{\qed\end{mdframed}}
\makeatother
\begin{document}
\chapter{Sample Chapter}
\begin{teorema}[The theorem's statement]
Its proof
\end{teorema}
\end{document}
Best Answer
With
tcolorbox
most of the requests can be done out of the box. Most important isminipage boxed title=0.8\linewidth
, for example.