是否可以重现此问题愉快的定理环境使用amsthm
和thmtools
?
答案1
您还可以使用包mdframed
来绘制框架。 定理的设置可以用您最喜欢的包来完成。 设置定理环境后,您可以用 包围环境\surroundwithmdframed
。 对于您需要的样式,您可以使用以下定义,其中短线的长度为 0.25 厘米。 当然,这可以做得更优雅。
为了简化代码,我使用了calc
TikZ 库
\usepackage[framemethod=TikZ]{mdframed}
\usetikzlibrary{calc}
\makeatletter
\newrobustcmd*\mdf@tikzbox@tfl@spare[1]{%three or four borders
\clip(0,0)rectangle(\mdfboundingboxwidth,\mdfboundingboxheight);%
\begin{scope}[mdfcorners]%
\clip[preaction=mdfouterline]%
[postaction=mdfbackground]%
[postaction=mdfinnerline]#1;%
\end{scope}%
\path[mdfmiddleline,mdfcorners]($(O|-P)-(0,0.25cm)$)--(O|-P)--(P)--($(P)-(0,0.25cm)$);
\path[mdfmiddleline,mdfcorners]($(P|-O)+(0,0.25cm)$)--(P|-O)--(O)--($(O)+(0,0.25cm)$);
}%
\newrobustcmd*\changelinestyle{\let\mdf@tikzbox@tfl\mdf@tikzbox@tfl@spare}
\makeatother
\surroundwithmdframed[settings=\changelinestyle]{theorem}
通过这个定义,所有的选项mdframed
都是允许的。
\documentclass{article}
\usepackage{amsmath,amsthm}
\usepackage{thmtools}
\declaretheorem[]{theorem}
\usepackage[framemethod=TikZ]{mdframed}
\usetikzlibrary{calc}
\makeatletter
\newrobustcmd*\mdf@tikzbox@tfl@spare[1]{%three or four borders
\clip(0,0)rectangle(\mdfboundingboxwidth,\mdfboundingboxheight);%
\begin{scope}[mdfcorners]%
\clip[preaction=mdfouterline]%
[postaction=mdfbackground]%
[postaction=mdfinnerline]#1;%
\end{scope}%
\path[mdfmiddleline,mdfcorners]($(O|-P)-(0,0.25cm)$)--(O|-P)--(P)--($(P)-(0,0.25cm)$);
\path[mdfmiddleline,mdfcorners]($(P|-O)+(0,0.25cm)$)--(P|-O)--(O)--($(O)+(0,0.25cm)$);
}%
\newrobustcmd*\changelinestyle{\let\mdf@tikzbox@tfl\mdf@tikzbox@tfl@spare}
\makeatother
\surroundwithmdframed[settings=\changelinestyle,middlelinecolor=blue,roundcorner=3pt,middlelinewidth=1.2pt]{theorem}
\usepackage{lipsum}
\begin{document}
\lipsum[2]
\begin{theorem}%
If~$G$ is a connected graph of order $n\geq 3$ and size~$m$, then
\[
g(G)\geq \frac{m}{6}-\frac{n}{2}+1.%
\]
\end{theorem}%
\lipsum[2]
\end{document}