\noindent
我目前在文档中每个定理、证明等的第一段前放置了一个memoir
。有没有办法memoir
自动执行此操作?
例如,有没有什么办法可以让这个 MWE 更加简洁?
\documentclass{memoir}
\usepackage{amsthm}
\newtheorem{thm}{Theorem}[chapter]
\begin{document}
\noindent This is my introduction.
This is the next paragraph of the introduction, which should be indented.
\begin{thm} (Theorem Name)
\noindent This is my theorem.
Note that I do want the ``(Theorem Name)'' to appear on the same line as where it says \textbf{Theorem 0.1}.
This is the next paragraph of the theorem, which should be indented.
\end{thm}
\noindent Here is a note about the theorem.
\begin{proof}
\noindent This proof has no name.
This is the next paragraph of the proof, which should be indented.
\end{proof}
\noindent This is my conclusion.
The end.
\end{document}
答案1
要排版某个定理的名称,请使用该定理环境的可选参数,例如\begin{thm}[Theorem Name]
。在我的示例中,我使用thmtools
包来方便地定义新样式。
为了抑制定理后第一段的缩进,可以修补命令\@endtheorem
和\endproof
(使用etoolbox
包),然后%
在正文中使用(注释符号)。(编辑:有关amsthm
定理实现的详细信息,请参阅我的答案到如何防止定理环境后的段落中断?)
如果\noindent
示例第一段中的 前面有分段命令(如\chapter
或 ) ,那么 将是多余的\section
。
\documentclass{memoir}
\usepackage{amsthm}
\usepackage{etoolbox}
\makeatletter
\patchcmd{\@endtheorem}{\@endpefalse}{}{}{}
\patchcmd{\endproof}{\@endpefalse}{}{}{}
\makeatother
\usepackage{thmtools}
\declaretheoremstyle[within=chapter,spaceabove=\topsep,notefont=\normalfont\itshape,
bodyfont=\itshape,postheadspace=\newline]{mystyle}
\declaretheorem[style=mystyle,name=Theorem]{thm}
\begin{document}
\noindent This is my introduction.
This is the next paragraph of the introduction, which should be indented.
\begin{thm}[Theorem Name]
This is my theorem. Note that I do want the ``(Theorem Name)'' to appear on the same
line as where it says \textbf{Theorem 0.1}.
This is the next paragraph of the theorem, which should be indented.
\end{thm}
% <-- Supresses indentation of following paragraph
Here is a note about the theorem.
\begin{proof}
This proof has no name.
This is the next paragraph of the proof, which should be indented.
\end{proof}
% <-- Supresses indentation of following paragraph
This is my conclusion.
The end.
\end{document}
答案2
您必须为此定义一个定理样式:
\usepackage{amsthm}
\newtheoremstyle{break}% name
{9pt}% Space above, empty = `usual value'
{9pt}% Space below
{\itshape}% Body font
{}% Indent amount (empty = no indent, \parindent = para indent)
{\bfseries}% Thm head font
{.}% Punctuation after thm head
{\newline}% Space after thm head: \newline = linebreak
{}% Thm head spec
\theoremstyle{break}
\newtheorem{thm}{Theorem}[chapter]
然后输入
\begin{thm}[Theorem Name]
This is my theorem.
Note that I do want the ``(Theorem Name)'' to appear on the
same line as where it says \textbf{Theorem 0.1}.
This is the next paragraph of the theorem, which should be indented.
\end{thm}
将会做你想做的事。
为了获得一行中的“证明”,你可以修补proof
环境
\usepackage{xpatch}
\xpatchcmd{\proof}{\ignorespaces}{\mbox{}\\\ignorespaces}{}{}
如果你没有xpatch
包裹,那么更复杂的
\usepackage{etoolbox}
\expandafter\patchcmd\csname\string\proof\endcsname
{\ignorespaces}{\mbox{}\\\ignorespaces}{}{}
是需要的。
对于定理或证明之后的文本,您需要一个\noindent
,但我认为这是不好的风格;将“证明”单独留在一行也是不好的风格。