左侧带有数字的定理环境

左侧带有数字的定理环境

我正在尝试构建一个大致如下所示的定理环境:

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} 

在此处输入图片描述

相关内容