答案1
一些人建议使用thmtools
评论中的软件包。如果你想自己动手,这里有一个现有环境的包装器。它支持可选参数,但不能跨页。因此它只适用于短定理。
\documentclass{article}
\usepackage{amsmath, amsthm} % For \newtheorem*.
\usepackage{unicode-math} % Or your math package of choice.
\usepackage{xparse} % For \NewDocumentEnvironment.
\usepackage{settobox} % For \settoboxtotalheight.
\usepackage{microtype} % For font expansion.
\usepackage{lipsum} % For \lipsum.
%% This is the font actually used within the example you gave:
%\setmainfont{Cambria}
%\setmathfont{Cambria Math}
\newtheorem*{thm*}{Theorem}
\newsavebox{\decothmbox}
\newlength{\decowidth}
\newlength{\decoheight}
\newlength{\decorulewidth}
\setlength{\decorulewidth}{1.5em}
\NewDocumentEnvironment{decothm}{mo}%
{%
\bigskip\par\noindent%
\setlength{\decowidth}{\hsize}%
\addtolength{\decowidth}{-1.0\decorulewidth}%
\begin{lrbox}{\decothmbox}%
\begin{minipage}[b]{\decowidth}%
\begin{#1}[#2]}%
{%
\end{#1}%
\end{minipage}%
\end{lrbox}%
\settoboxtotalheight{\decoheight}{\decothmbox}%
\makebox[\decorulewidth]{%
\hspace{0.6em}%
\rule{0.1em}{\decoheight}%
\hspace{0.1em}%
\rule{0.05em}{\decoheight}%
\hspace{0.65em}}%
\usebox{\decothmbox}%
\bigskip\par}
\begin{document}
This is a theorem.
\begin{decothm}{thm*}[4L.9]\label{thm:example}
Suppose \(H^\ast (X ; \mathbb{Z}_p)\) is the polynomial algebra
\(\mathbb{Z}_p[\alpha]\) on a generator \(\alpha\) of dimension \(n\),
possibly truncated by the relation \(\alpha^m = 0\) for \(m > p\). Then if
\(p = 2\), \(n\) must be a power of \(2\), and if \(p\) is an odd prime, \(n\)
must be of the form \(p^k \ell\), where \(\ell\) is an even divisor of
\(2(p-1)\).
\end{decothm}
\lipsum[1]
\end{document}
本质上,这会将定理文本排版在minipage
减去左侧规则宽度的行内。我们不会立即使用它,而是将其保存在一个框中,以便测量其高度。这样我们就可以先将规则布置在左侧。
代码使用xparse
使得可以使用代码中的参数来关闭环境,settobox
作为添加定理的高度和深度的便捷方式,并且包含在amsmath
之前amsthm
,因为否则,另一个包会在之后加载它,这可能会导致更复杂的文档中出现错误。