我使用 amsthm 包,并且不希望定理环境之后的行缩进。我查阅了包的手册,它说要定义一种新的定理样式。我希望以下 MWE 能够完成这项任务。
\documentclass[12pt,a4paper]{scrreprt}
\usepackage{amsthm}
\newtheoremstyle{abcd}% name
{}% Space above, empty = `usual value'
{}% Space below
{\itshape}% Body font
{}% Indent amount (empty = no indent, \parindent = para indent)
{\bfseries}% Thm head font
{.}% Punctuation after thm head
{.5em}% Space after thm head: \newline = linebreak
{}% Thm head spec
\theoremstyle{abcd}
\newtheorem{defn}{Definition}
\begin{document}
\begin{defn}
Some defintion
\end{defn}
This sentence shouldn't be indented.
\end{document}
然而,我最终得到了这个
这正是我所期望的(在定理环境结束后立即使用 noindent 获得)
答案1
\documentclass[12pt,a4paper]{scrreprt}
\usepackage{amsthm}
\usepackage{etoolbox}
\newtheorem{defn}{Definition}
\AfterEndEnvironment{defn}{\noindent\ignorespaces}
\begin{document}
\begin{defn}
Some definition.
\end{defn}
This sentence isn't indented.
\end{document}
然而,这违背直觉;定义(或任何其他类似定理的结构)之后的句子在逻辑上开始一个新段落,因此其第一行应被视为新段落的任何其他第一行。
答案2
您可以通过修补在单个定理类型的基础上修复此问题\end<name>
:
\documentclass{article}
\usepackage{etoolbox}
\usepackage{amsthm}
\newtheoremstyle{abcd}% name
{}% Space above, empty = `usual value'
{}% Space below
{\itshape}% Body font
{}% Indent amount (empty = no indent, \parindent = para indent)
{\bfseries}% Thm head font
{.}% Punctuation after thm head
{.5em}% Space after thm head: \newline = linebreak
{}% Thm head spec
\theoremstyle{abcd}
\newtheorem{defn}{Definition}
\makeatletter
\patchcmd{\enddefn}{\@endpefalse}{}{}{}
\makeatother
\begin{document}
\begin{defn}
Some definition
\end{defn}
This sentence shouldn't be indented.
\begin{defn}
Some definition
\end{defn}
This sentence should be indented.
\end{document}
风格选择没有影响。
为了获得相同的行为全部定理环境,改变的定义\@endtheorem
。
\documentclass{article}
\usepackage{amsthm}
\makeatletter
\def\@endtheorem{\endtrivlist}
\makeatother
\newtheoremstyle{abcd}% name
{}% Space above, empty = `usual value'
{}% Space below
{\itshape}% Body font
{}% Indent amount (empty = no indent, \parindent = para indent)
{\bfseries}% Thm head font
{.}% Punctuation after thm head
{.5em}% Space after thm head: \newline = linebreak
{}% Thm head spec
\theoremstyle{abcd}
\newtheorem{defn}{Definition}
\begin{document}
\begin{defn}
Some definition
\end{defn}
This sentence shouldn't be indented.
\begin{defn}
Some definition
\end{defn}
This sentence should be indented.
\end{document}
另一个例子,表明当两个定理环境相互衔接时不会增加不必要的空间。
\documentclass{scrbook}
\usepackage{amsthm}
\makeatletter
\def\@endtheorem{\endtrivlist}
\makeatother
\theoremstyle{plain}
\newtheorem{thm}{Theorem}[chapter]
\newtheorem*{thm*}{Theorem}
\begin{document}
\chapter{Chapter}
\section{Section}
Some text. Some text. Some text. Some text. Some text. Some text. Some text. Some text. Some text. Some text.
\begin{thm}
Theorem. Theorem. Theorem. Theorem. Theorem. Theorem. Theorem. Theorem. Theorem. Theorem.
\end{thm}
No indentation. Some text. Some text. Some text. Some text. Some text. Some text. Some text. Some text. Some text. Some text.
\begin{thm}
Theorem. Theorem. Theorem. Theorem. Theorem. Theorem. Theorem. Theorem. Theorem. Theorem.
\end{thm}
\begin{thm}
Theorem. Theorem. Theorem. Theorem. Theorem. Theorem. Theorem. Theorem. Theorem. Theorem.
\end{thm}
Indentation. Some text. Some text. Some text. Some text. Some text. Some text. Some text. Some text. Some text. Some text.
\end{document}