两边带边距的定理样式

两边带边距的定理样式

我对定理包thmtools及其功能感到困惑。我已使用\declaretheoremstyle和声明了几种定理样式\declaretheorem

如何在左侧添加相对于定理类型长度的悬挂段落边距,并在右侧添加绝对边距?如图所示,包含定理标题的第一行应与文档的其余部分一样缩进。但是,定理的实际内容左侧的边距应与定理类型“示例”一样宽。右侧的边距应由绝对值定义。虽然我已经找到了缩进左边距的解决方案(例如这里),我没有发现任何具有定理类型的精确长度的东西,也没有发现右边的绝对边距的东西。

(1)的插图

上述定理样式实际应用的一个最小示例:

\documentclass[]{article}

\usepackage{amsthm}
\usepackage{thmtools}
\usepackage{lipsum}

\declaretheoremstyle[
    spaceabove=\topsep, 
    spacebelow=\topsep,
    headfont=\normalfont\bfseries,
    notefont=\normalfont, 
    notebraces={$\lbrack$}{$\rbrack$},
    bodyfont=\normalfont\itshape,
    postheadspace=\newline
]{examplebreak}

\declaretheorem[style=examplebreak,name=Example]{example}

\begin{document}

\begin{example}[First Example]
    \lipsum[2]
\end{example}

\end{document}

我很感激任何帮助!

答案1

您可以使用以下方式轻松完成此操作ntheorem

\documentclass[]{article}
\usepackage[showframe, nomarginpar]{geometry}
\usepackage{ntheorem}
\usepackage{thmtools}
\usepackage{lipsum}

%\declaretheoremstyle[
% spaceabove=\topsep,
% spacebelow=\topsep,
% headfont=\normalfont\bfseries,
% notefont=\normalfont\mdseries,
%% notebraces={$\lbrack$}{$\rbrack$},
% bodyfont=\normalfont\itshape,
% % postheadspace=\newline
%]{examplebreak}

\newlength\exampleindent
\settowidth{\exampleindent}{\bfseries Example}
\makeatletter
\newtheoremstyle{examplebreak}%
  {\item[\rlap{\vbox{\hbox{\hskip\labelsep \theorem@headerfont
          \llap{##1}\ ##2\theorem@separator}\hbox{\strut\vspace{1pt}}}}]}%
  {\item[\rlap{\vbox{\hbox{\hskip\labelsep \theorem@headerfont
          \llap{##1}\ ##2\ \normalfont\mdseries[##3]\theorem@separator}\hbox{\strut\vspace{1pt}}}}]}
\makeatother
\theoremstyle{examplebreak}
\theoremheaderfont{\normalfont\bfseries}
\theorembodyfont{\normalfont\itshape}
\theoremindent\exampleindent
\theoremrightindent 1.5cm
\newtheorem{example}{Example}

\begin{document}

\begin{example}[First Example]
    \lipsum[2-3]
\end{example}

\begin{example}%[First Example]
    \lipsum[4]
\end{example}
\end{document} 

在此处输入图片描述

相关内容