左邊有數字的定理環境

左邊有數字的定理環境

我正在嘗試建立一個大致如下所示的定理環境:

1.1   Theorem   Statement of the theorem. Here is some extra text so you can see how the
      theorem body text should be indented (aligned with theorem head). 

定理的標題應該是粗體,後面沒有標點符號。thmnumber和之間的間距thmname應該是可調的。正文正常。

我也希望能夠使用環境進行定義(不會編號),因此應該可以刪除編號而不影響定理頭的對齊。例子:

      Definition   Statement of the definition. It should be aligned the same way as a 
      theorem. 

Here is some body text in the document. Note that the theorem numbers are not in the
margin. 

1.1   Theorem   Statement of the theorem. Here is some extra text so you can see how the
      theorem body text should be indented (aligned with theorem head). 

答案1

這是一種方法;這也將符合enumerate聲明中的列表,而哪些解決方案則\hangindent不會。

\documentclass{article}
\usepackage{showframe} % just for the example
\usepackage{amsthm}
\usepackage{enumitem}
\usepackage{xparse}

\usepackage{lipsum}

\newtheoremstyle{fctaylor}% name
  {\topsep}%      Space above
  {\topsep}%      Space below
  {\normalfont}%         Body font
  {}%         Indent amount (empty = no indent, \parindent = para indent)
  {\bfseries}% Thm head font
  {}%        Punctuation after thm head
  {0pt}%     Space after thm head: " " = normal interword space;
  {\makethmhead{#1}{#2}{#3}}

\newlength\fctaylortheoremindent
\AtBeginDocument{\setlength\fctaylortheoremindent{3em}} % <- customize here
\newlength\fctaylorlabelsep
\AtBeginDocument{\setlength\fctaylorlabelsep{1em}} % <- customize here

\makeatletter
\newcommand{\makethmhead}[3]{%
  \gdef\thisthmhead{%
    \makebox[\fctaylortheoremindent][l]{\bfseries#2}%
    {\bfseries#1}%
    \@ifnotempty{#3}{ (#3)}%
    \hspace{\fctaylorlabelsep}%
  }%
}
\makeatother

\newenvironment{fctayloritemize}
 {\list{}{%
    \leftmargin=\fctaylortheoremindent
    \labelwidth=\dimexpr\fctaylortheoremindent-\labelsep\relax
    \itemindent=0pt
  }}
 {\endlist}

\NewDocumentCommand{\newfctaylortheorem}{smomo}{%
  \IfBooleanTF{#1}
   {\newtheorem*{fctaylor@#2}{#4}}
   {\IfNoValueTF{#3}
     {\IfNoValueTF{#5}
       {\newtheorem{fctaylor@#2}{#4}}
       {\newtheorem{fctaylor@#2}{#4}[#5]}}
     {\newtheorem{fctaylor@#2}[fctaylor@#3]{#4}}}%
  \NewDocumentEnvironment{#2}{o}
   {\IfNoValueTF{##1}{\begin{fctaylor@#2}}{\begin{fctaylor@#2}[##1]}%
    \begin{fctayloritemize}\item[\thisthmhead\hfill]}
   {\end{fctayloritemize}\end{fctaylor@#2}}%
}

\theoremstyle{fctaylor}
\newfctaylortheorem{thm}{Theorem}[section]
\newfctaylortheorem*{defn}{Definition}

\begin{document}
\section{One}

\begin{defn}
\lipsum*[2]
\end{defn}

\begin{thm}\label{A}
\lipsum*[2]
\end{thm}

\begin{thm}[Somebody]\label{B}
Something that should show how the text is split across line boundaries
and is correctly indented. And some equivalent conditions:
\begin{enumerate}[label=\upshape(\alph*),ref=(\alph*)]
\item a condition
\item another
\item and another
\end{enumerate}
which show the point made.
\end{thm}

\ref{A} and \ref{B}

\end{document}

在此輸入影像描述

答案2

這是使用的可能性thmtools作為前端amsthm:

在此輸入影像描述

程式碼(根據您的需求調整設定;特別是,進行更改\thmindent以獲得類似定理結構所需的懸掛縮排):

\documentclass{article}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{thmtools}
\usepackage{lipsum}

\newlength\thmindent
\setlength\thmindent{2.5em}

\declaretheoremstyle[
  spaceabove=6pt, 
  spacebelow=6pt,
  headfont=\normalfont\bfseries,
  notefont=\normalfont\bfseries, 
  notebraces={(}{)},
  bodyfont=\normalfont,
  postheadspace=0.5em,
  numberwithin=section,
  headformat={\makebox[\thmindent]{\NUMBER\hfill}\NAME\NOTE},
  postheadhook=\hangindent=\thmindent
]{nuswapindented}
\declaretheoremstyle[
  spaceabove=6pt, 
  spacebelow=6pt,
  headfont=\normalfont\bfseries,
  notefont=\normalfont\bfseries, 
  notebraces={(}{)},
  bodyfont=\normalfont,
  postheadspace=0.5em,
  numbered=no,
  headformat={\makebox[\thmindent]{\mbox{}\hfill}\NAME\NOTE},
  postheadhook=\hangindent=\thmindent
]{unnuswapindented}
\declaretheorem[style=nuswapindented,name=Theorem]{theo}
\declaretheorem[style=unnuswapindented,name=Definition]{defi}

\begin{document}

\section{Test section}

\lipsum[4]
\begin{defi}
\lipsum[4]
\end{defi}
\lipsum[4]
\begin{theo}
\lipsum[4]
\end{theo}

\end{document}

答案3

ntheorem它可以透過包及其定理樣式來完成change。定理名稱和定理編號之間的間距可以調整,以修補更改定理樣式:我引入了一個新的維度,thlabelsep它預設為0.5em並且可以在序言中更改:

\documentclass{article}
\usepackage[utf8]{inputenc}

 \usepackage{amsmath}
\usepackage[thmmarks, amsmath, thref]{ntheorem}
\usepackage{cleveref}

\newdimen\thlabelsep
\global\thlabelsep0.5em
\makeatletter
\renewtheoremstyle{change}%
{\item[\hskip\labelsep \theorem@headerfont ##2\hskip\thlabelsep##1\theorem@separator]}%
{\item[\hskip\labelsep \theorem@headerfont ##2\hskip\thlabelsep##1\ (##3)\theorem@separator]}
\makeatother
\theoremstyle{change}
\thlabelsep1.5em
\theoremheaderfont{\bfseries\upshape}
\theoremseparator{}
\theorembodyfont{\upshape}
\newtheorem{thm}{Theorem}[section]

\theoremstyle{nonumberplain}
\newtheorem{defn}{Definition}
\begin{document}

\section{Two Conjectures}

\begin{defn}
  A Sophie Germain prime is a prime number $ p $ such that $ 2p + 1$ is also prime.
\end{defn}

\begin{thm}
There is an infinity of twin primes. Related: There is an infinity of Sophie Germain primes. 
\end{thm}

\end{document} 

在此輸入影像描述

相關內容