当定理的样式由用户自定义时,如何缩进定理中正文的第一行?

当定理的样式由用户自定义时,如何缩进定理中正文的第一行?

我已经使用包定义了一种新的定理样式amsthm,并且我注意到\parindent我在样式的定义中包含了带有注释的代码行,indentation amount定理的标题而不是定理的正文,这是更理想的。我还注意到,如果我使用预定义的默认样式,它amsthm会在定理的正文中添加缩进,而不是我想要的标题。为了明确我的愿望:我希望定理的标题带有缩进和定理正文缩进。我做错了什么,如何在新定理样式的定义中控制定理正文的缩进?查看了文档,amsthm package我没有找到任何可以帮助我的东西。

代码:

\documentclass[12pt]{article}
\usepackage[a4paper, total={180mm,257mm},left=15mm,top=20mm]{geometry}
\usepackage[T1]{fontenc}
\usepackage{amsthm}
\newtheorem{thm}{Theorem}[section]
\newtheoremstyle{mythm}%⟨name⟩
{3pt}%⟨Space above⟩
{3pt}%⟨Space below⟩
{}%⟨Body font⟩
{\parindent}%⟨Indent amount)
{\bfseries\slshape}% ⟨Theorem head font⟩
{:}%⟨Punctuation after theorem head⟩
{\newline}%⟨Space after theorem head⟩
{}%⟨Theorem head spec (can be left empty, meaning ‘normal’)⟩
\theoremstyle{mythm}
\newtheorem{pytha}{Theorem of Pythagoras}[section]
\begin{document}
\section{First Section}

\begin{pytha}   
Let $ABC$ right triangle with $\angle A=90^{\circ}$. Then for the sides of the triangle $AB, AC$ and $BC$ is true that:
    \begin{equation}
        (BC)^{2}=(AB)^2+(AC)^{2}
    \end{equation}
\end{pytha}

\begin{thm}(Theorem of Pythagoras)
    
    Let $ABC$ right triangle with $\angle A=90^{\circ}$. Then for the sides of the triangle $AB, AC$ and $BC$ is true that:
    \begin{equation}
        (BC)^{2}=(AB)^2+(AC)^{2}
    \end{equation}
\end{thm}
\end{document}

答案1

您可以将changepage包添加到您的序言中并使用该adjustwidth环境。更改<indent param>字段以满足您的需求。

\begin{thm}(Theorem of Pythagoras)
\begin{adjustwidth}{<indent param>}{}
    Let $ABC$ right triangle with $\angle A=90^{\circ}$. Then for the sides of the triangle $AB, AC$ and $BC$ is true that:
    \begin{equation}
        (BC)^{2}=(AB)^2+(AC)^{2}
    \end{equation}
\end{adjustwidth}
\end{thm}

编辑

您可以创建自定义环境:

\newenvironment{indented}[1]{
    \begin{thm}[#1]\phantom\newline\vspace{-\baselineskip}\begin{adjustwidth}{<indent space>}{}}
    {\end{adjustwidth}\end{thm}}

像这样使用它:

\begin{indented}{Pythagoras}
    Let $ABC$ right triangle with $\angle A=90^{\circ}$. Then for the sides of the triangle $AB, AC$ and $BC$ is true that:
    \begin{equation}
        (BC)^{2}=(AB)^2+(AC)^{2}
    \end{equation}
\end{indented}

针对您下方的评论的其他解决方案

\newenvironment{indented}[1]{
    \setlength\parindent{<change it to set indent amount>}
    \begin{thm}[#1]\phantom\newline\vspace{-\baselineskip}\begin{adjustwidth}{0cm}{}\hspace{\parindent}}
    {\end{adjustwidth}\end{thm}}

相关内容