amsthm を使用した定理環境の後にインデントなし

amsthm を使用した定理環境の後にインデントなし

私は 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}

もう 1 つの例は、2 つの定理環境が連続する場合に、不要なスペースが追加されないことを示しています。

\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}

ここに画像の説明を入力してください

関連情報