下面是我从网上下载的代码:定理的普通环境。
\documentclass{ctexart}
\usepackage{xcolor}
\usepackage[framemethod=tikz]{mdframed}
\usepackage{amsthm}
%%%%%%%% Theorem %%%%%%%%
\newcounter{theo}[section] \setcounter{theo}{0}
\renewcommand{\thetheo}{\arabic{section}.\arabic{theo}}
\newenvironment{theo}[2][]{%
\refstepcounter{theo}%
\ifstrempty{#1}%
{\mdfsetup{%
frametitle={%
\tikz[baseline=(current bounding box.east),outer sep=0pt]
\node[anchor=east,rectangle,fill=blue!20]
{\strut Theorem~\thetheo};}}
}%
{\mdfsetup{%
frametitle={%
\tikz[baseline=(current bounding box.east),outer sep=0pt]
\node[anchor=east,rectangle,fill=blue!20]
{\strut Theorem~\thetheo:~#1};}}%
}%
\mdfsetup{innertopmargin=10pt,linecolor=blue!20,%
linewidth=2pt,topline=true,%
%skipabove=1\baselineskip,
%skipbelow=1\baselineskip,
frametitleaboveskip=\dimexpr-\ht\strutbox\relax
}
\begin{mdframed}[]\relax%
\label{#2}}{\end{mdframed}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
Hello World!
\begin{theo}[Pythagoras' theorem]{thm:pythagoras}
In a right triangle, the square of the hypotenuse is equal to the sum of
the squares of the catheti.
$$a^2+b^2=c^2$$
\end{theo}
Hello World!
\begin{theo}[Pythagoras' theorem]{thm:pythagoras}
In a right triangle, the square of the hypotenuse is equal to the sum of the squares of the catheti.
$$a^2+b^2=c^2$$
\end{theo}
\end{document}
为了使问题突出,我故意将相同的定理放在一起。如你所见,除非我添加代码,否则标题的一半会消失,段落之间的上下文差距不会像示例中那样令人满意
skipabove=1\baselineskip,
skipbelow=1\baselineskip,
并且线宽也与参数不匹配。我在 texlive 2015 和 2017 上用各种编辑器(例如 Texstudio、TexWork 等)编译了它,但都失败了。我的代码有什么问题?请帮助我,谢谢。:D
PS:我也试过mdframed包简介里的代码,但是失败了。Σ(゚д゚lll)