将模板从 amsthm 重写为 thmtools

将模板从 amsthm 重写为 thmtools

我一直在使用Legrand 橙皮书模板我和朋友及同事一起开发了一个项目。此模板使用amsthmmdframed格式化了一堆环境,我正在重写它们以thmtools代替使用。以下是他们正在做的事情的示例:

\definecolor{ocre}{RGB}{243,102,25}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% theorem
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newtheoremstyle{ocrenumbox}% % Theorem style name
{0pt}% Space above
{0pt}% Space below
{\normalfont}% % Body font
{}% Indent amount
{\small\bf\sffamily\color{ocre}}% % Theorem head font
{\;}% Punctuation after theorem head
{0.25em}% Space after theorem head
{\small\sffamily\color{ocre}\thmname{#1}\nobreakspace\thmnumber{\@ifnotempty{#1}{}\@upn{#2}}% Theorem text (e.g. Theorem 2.1)
\thmnote{\nobreakspace\the\thm@notefont\sffamily\bfseries\color{black}---\nobreakspace#3.}} % Optional theorem note
\renewcommand{\qedsymbol}{$\blacksquare$}% Optional qed square

\newcounter{dummy} 
\numberwithin{dummy}{section}
\theoremstyle{ocrenumbox}
\newtheorem{theoremeT}[dummy]{Theorem}

% Theorem box
\newmdenv[skipabove=7pt,
skipbelow=7pt,
backgroundcolor=black!5,
linecolor=ocre,
innerleftmargin=5pt,
innerrightmargin=5pt,
innertopmargin=5pt,
leftmargin=0cm,
rightmargin=0cm,
innerbottommargin=5pt]{tBox}

\newenvironment{theorem}{\begin{tBox}\begin{theoremeT}}{\end{theoremeT}\end{tBox}}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% example
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    \newtheoremstyle{blacknumex}% Theorem style name
    {5pt}% Space above
    {5pt}% Space below
    {\normalfont}% Body font
    {} % Indent amount
    {\small\bf\sffamily}% Theorem head font
    {\;}% Punctuation after theorem head
    {0.25em}% Space after theorem head
    {\small\sffamily{\tiny\ensuremath{\blacksquare}}\nobreakspace\thmname{#1}\nobreakspace\thmnumber{\@ifnotempty{#1}{}\@upn{#2}}% Theorem text (e.g. Theorem 2.1)
    \thmnote{\nobreakspace\the\thm@notefont\sffamily\bfseries---\nobreakspace#3.}}% Optional theorem note

\theoremstyle{blacknumex}
\newtheorem{exampleT}{Example}[chapter]

\newenvironment{example}{\begin{exampleT}}{\hfill{\tiny\ensuremath{\blacksquare}}\end{exampleT}}

以下是我尝试重写它们的方法:

\definecolor{bookcolor}{RGB}{243,102,25}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% theorem
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\declaretheoremstyle[
    headfont=\small\bf\sffamily\color{bookcolor},
    notebraces={[}{]},
    bodyfont=\normalfont\itshape,
    headpunct={\;},
    postheadspace=0.25em,
    spacebelow=0pt,
    spaceabove=0pt,
    mdframed={
        backgroundcolor=black!5, 
        skipabove=7pt,
        skipbelow=7pt,
        innerleftmargin=5pt,
        innerrightmargin=5pt,
        innertopmargin=5pt,
        leftmargin=0cm,
        rightmargin=0cm,
        innerbottommargin=5pt
        linecolor=bookcolor}   
]{Tstyle}

\declaretheorem[
    style=Tstyle,
    name=Theorem,
    numberwithin=section
]{theorem}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% example
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\declaretheoremstyle[
    headfont=\small\bf\sffamily,
    notebraces={[}{]},                                                                                                                                                 
    bodyfont=\normalfont,
    headpunct={\;},
    postheadspace=0.25em,
    spacebelow=5pt,
    spaceabove=5pt,
    postfoothook=\hfill{\tiny\ensuremath{\blacksquare}}
]{Estyle}

\declaretheorem[
    style=Estyle,
    name=Example,
    numberwithin=chapter
]{example}

我的问题是:如何在命令的最后一个框中实现格式化\newtheoremstyle?例如

{\small\sffamily\color{ocre}\thmname{#1}\nobreakspace\thmnumber{\@ifnotempty{#1}{}\@upn{#2}}% Theorem text (e.g. Theorem 2.1)
\thmnote{\nobreakspace\the\thm@notefont\sffamily\bfseries\color{black}---\nobreakspace#3.}}

据我所知,这似乎是headformat关键,但它似乎强烈反对在这里传递#1和#2,如果我只复制这一newtheoremstylehttp://mirrors.ibiblio.org/CTAN/macros/latex/exptl/thmtools/thmtools.pdf

restatable我更喜欢使用 thmtools 的解决方案,因为我对使用其他功能(例如定理)感兴趣。

答案1

如上所述,thmtools.pdfheadformat键有三个命令\NAME \NUMBER\NOTE。还有一些命令可以设置字体,这样您就不需要在格式中声明字体了。最后,notebraces可以使用该键在任何命名定理周围生成 --()。这是declaretheoremstyle我修复这些问题的:

\declaretheoremstyle[
    headfont=\small\bf\sffamily\color{bookcolor},
    bodyfont=\normalfont,
    headpunct={\;},
    postheadspace=0.25em,
    spacebelow=0pt,
    spaceabove=0pt,
    notefont=\small\bf\sffamily\color{black},
    notebraces={---(}{)},
    headformat=\NAME\NUMBER\NOTE.,
    mdframed={
            backgroundcolor=black!5, 
            skipabove=7pt,
            skipbelow=7pt,
            innerleftmargin=5pt,
            innerrightmargin=5pt,
            innertopmargin=5pt,
            leftmargin=0cm,
            rightmargin=0cm,
            innerbottommargin=5pt
            linecolor=bookcolor}   
]{Tstyle}

相关内容