mdframed 环境的标题框中的定理陈述?

mdframed 环境的标题框中的定理陈述?

我已经使用包定义了一个定理环境mdframed。但是,我希望将陈述包含在与包含证明的框不同的框中。

理想情况下,这应该是标题框。但是,如果我尝试在其中放置多行文本,文本只会水平放置,甚至忽略\\

我在软件包文档和网上搜索了示例,但没有找到符合我要求的示例。有人知道是否可以做这样的事情吗?

我在这里提供了我当前环境的最小工作示例:

结果图片

\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}

答案1

大多数tcolorbox请求都可以立即完成。minipage boxed title=0.8\linewidth例如,最重要的是。

\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}

在此处输入图片描述

相关内容