With tcolorbox
most of the requests can be done out of the box. Most important is minipage boxed title=0.8\linewidth
, for example.
\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][]{%
\refstepcounter{theo}%
%\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
\usepackage[most]{tcolorbox}
\usepackage{blindtext}
\newtcbtheorem[auto counter,number within=chapter]{teoremaother}{Teorema}{%
boxrule=2pt,
enhanced,
colback=Violet!5,
colframe=Violet!50,
colbacktitle=Violet!20,
coltitle=black,
fonttitle={\bfseries},
minipage boxed title=0.8\linewidth,
attach boxed title to top left={xshift=10pt,yshift*={-\tcboxedtitleheight/2}},
boxed title style={parbox,boxrule=2pt},
after upper={\qed},
}{th}
\begin{document}
\chapter{Sample Chapter}
\begin{teorema}[The theorem's statement which is a very long, long, long, long text]
Its proof
\end{teorema}
\begin{teoremaother}{The theorem's statement which is a very long, long, long, long text}{}
Its proof
\end{teoremaother}
\begin{teoremaother}{\blindtext}{}
Its proof
\end{teoremaother}
\end{document}
Best Answer
Load the
ntheorem
package in addition tomdframed
and issue\theoremstyle{nonumberplain}
before\newmdtheoremenv
.