再次使用悬挂缩进的定理环境

再次使用悬挂缩进的定理环境

我希望定理环境(并且只有这个环境)有缩进格式,就像这样

在此处输入图片描述

这与具有悬挂缩进的定理环境

amsart那里的解决方案在我正在处理的文档类中不能很好地发挥作用。

我有一个简单的解决方案

\documentclass{amsart}

\makeatletter
\def\th@fancyindent{
    \itshape
    \addtolength{\leftskip}{2.5em} %indentation here
}
\makeatother

\newtheorem{defi}{Definition}
\theoremstyle{fancyindent}
\newtheorem{thm}{Theorem}

\begin{document}
Text body. Text body. Text body.
\begin{thm}[Pythagoras]
    Let $a,b,c$ the sides of a rectangular triangle.
    Without loss of generality, we assume that  $a<b<c$ .
    Then, the following equality holds:
          \[a^2 + b^2 = c^2\]
\end{thm}
More text. And even more text.
\begin{defi}  
Everything is normal here, no indentation whatsoever. Everything is normal here, no indentation whatsoever. 
\end{defi}
\end{document}

但这并不是我想要的,因为它也缩进了 Theorem 这个词。我怎样才能实现我想要的缩进格式,从 Theorem 开始,不缩进?

答案1

简单修改https://tex.stackexchange.com/a/106582/4427

\documentclass[a4paper]{scrartcl}
\usepackage{amsthm,thmtools}
\usepackage{etoolbox}
\usepackage{lipsum}
\usepackage{showframe}

\declaretheoremstyle[
  headfont=\kern-2.5em\bfseries,
  bodyfont=\itshape,
  headindent=0pt,
  headpunct=\newline,
]{INDENTthm}
\declaretheoremstyle[
  headfont=\bfseries,
  bodyfont=\itshape,
  headindent=0pt,
  headpunct={},
]{NOINDENTthm}

\declaretheorem[
  within=section,
  style=INDENTthm,
  name=Theorem
]{theorem}

\makeatletter
\AtBeginEnvironment{theorem}{%
  \patchcmd\@thm
    {\trivlist}
    {\list{}{\leftmargin2.5em\itemindent-15em}}
    {}{}%
}
\makeatother

\declaretheorem[
  style=NOINDENTthm,
  name=Definition
]{definition}

\begin{document}

Text body. Text body. Text body.
\begin{theorem}[Pythagoras]
    Let $a,b,c$ the sides of a rectangular triangle.
    Without loss of generality, we assume that  $a<b<c$ .
    Then, the following equality holds:
          \[a^2 + b^2 = c^2\]
\end{theorem}
More text. And even more text.
\begin{definition}
Everything is normal here, no indentation whatsoever. Everything is 
normal here, no indentation whatsoever. 
\end{definition}

\end{document}

H

答案2

我发布这个答案以供将来参考(因为我不是高级 LaTeX 用户并且amsthm之前不知道这个包的存在)。

此解决方案使用amsthm包,并且在切换到其他标准文档类时也能很好地工作amsart。它适应缩进的全局规则,并且不会破坏现有的定理样式。

\documentclass{amsart}
\usepackage{amsthm}

\newtheoremstyle{fancyindent}               % name of theoremstyle
{.5\baselineskip±.2\baselineskip}           % Space above, these are standard values for AMS class document
{.5\baselineskip±.2\baselineskip}           % Space below
{\itshape\addtolength{\leftskip}{15mm}\setlength{\parindent}{0em}}      % Body font +indent added +no indent between paragraphs
{-15mm}                                     % Indent of header amount
{\bfseries}                                 % Theorem head font
{\newline}                                  % Punctuation after theorem head and start at new line
{.5em}                                      % Space after theorem head
{\thmname{#1}\thmnumber{ #2}. \thmnote{[#3]}}% Theorem head spec (can be left empty, meaning ‘normal’)

\newtheoremstyle{fancyindentwithindents}    % name of theoremstyle
{.5\baselineskip±.2\baselineskip}           % Space above, these are standard values for AMS class document
{.5\baselineskip±.2\baselineskip}           % Space below
{\itshape\addtolength{\leftskip}{15mm}}     % Body font +indent added
{-15mm}                                     % Indent of header amount
{\bfseries}                                 % Theorem head font
{}                                          % Punctuation after theorem head
{.5em}                                      % Space after theorem head
{\thmname{#1}\thmnumber{ #2}. \thmnote{[#3]}}% Theorem head spec (can be left empty, meaning ‘normal’)

\newtheorem{defi}{Definition}

\theoremstyle{fancyindent}
\newtheorem{thm}{Theorem}

\theoremstyle{fancyindentwithindents}
\newtheorem{thmind}{Theorem}

%\setlength{\parindent}{0em}

现在在文档正文中你将产生以下结果: 在此处输入图片描述

详细信息可以在这里找到:http://www.ams.org/arc/tex/amscls/amsthdoc.pdf

缺点是它确实不能很好地与枚举配合使用,要解决这个问题,需要遵循这里的建议:使用 amsthm 进行完整缩进的 theoremstyle例如 Philippe Goutet 的解决方案与缩进枚举配合得很好

\makeatletter
\newtheoremstyle{indentedenumerate} % name of theoremstyle
{.5\baselineskip±.2\baselineskip}           % Space above, these are standard values for AMS class document
{.5\baselineskip±.2\baselineskip}           % Space below
{\itshape\addtolength{\@totalleftmargin}{15mm}
   \addtolength{\linewidth}{-15mm}
   \parshape 1 15mm \linewidth}             % Body font +indent added +will work well with enumerate! (you need to add makeatletter)
{-15mm}                                     % Indent of header amount
{\bfseries}                                 % Theorem head font
{}                                          % Punctuation after theorem head
{.5em}                                      % Space after theorem head
{\thmname{#1}\thmnumber{ #2}. \thmnote{[#3]}}% Theorem head spec (can be left empty, meaning ‘normal’)
\makeatother

amsart无法缩进方程式(原文如此!)。

相关内容