定理样式“bodyfont”不受尊重

定理样式“bodyfont”不受尊重

下面两种定理样式虽然bodyfont风格不同,但字体样式相同。有人能帮忙吗?

\documentclass[12pt,a4paper]{report}
\usepackage{amsthm}
\usepackage{thmtools}
\usepackage{amsfonts,color,graphicx,xcolor}
\usepackage[english]{babel}
\declaretheoremstyle[
    headfont=\bfseries,
    notebraces={(}{)},
    bodyfont=\normalfont\scshape,
    headpunct={},
    postheadspace=\newline,
    postheadhook={\textcolor{red}{\rule[2.0ex]{\linewidth}{0.8pt}}\\},
    spacebelow=\parsep,
    spaceabove=\parsep,
    mdframed={
        backgroundcolor=cyan!20,
            linecolor=red!30,
            innertopmargin=6pt,
            roundcorner=5pt,
            innerbottommargin=6pt,
            skipbelow=\parsep,
            skipbelow=\parsep }
]{myexamplestyle}

% example environment - thmtools
\declaretheorem[
    style=myexamplestyle,
    name=EEEEE,
    numberwithin=section
    %qed=$\Box$
]{EE}

\declaretheoremstyle[
    headfont=\bfseries,
    notebraces={(}{)},
    bodyfont=\normalfont\itshape,
    headpunct={},
    postheadspace=\newline,
    postheadhook={\textcolor{cyan}{\rule[2.0ex]{\linewidth}{0.8pt}}\\},
    spacebelow=\parsep,
    spaceabove=\parsep,
    mdframed={
        backgroundcolor=green!20,
            linecolor=magenta!30,
            innertopmargin=6pt,
            roundcorner=5pt,
            innerbottommargin=6pt,
            skipbelow=\parsep,
            skipbelow=\parsep }
]{myexamplestyle}

% example environment - thmtools
\declaretheorem[
    style=myexamplestyle,
    name=DDDDDD,
    numberwithin=chapter
]{DD}
\begin{document}
\begin{EE}
Some text.
\end{EE}

\begin{DD}
The other text
\end{DD}
\end{document} 

答案1

您需要赋予这两种样式不同的名称:

示例输出

\documentclass[12pt,a4paper]{report}
\usepackage{amsthm}
\usepackage{thmtools}
\usepackage{amsfonts,color,graphicx,xcolor}
\usepackage[english]{babel}
\declaretheoremstyle[
    headfont=\bfseries,
    notebraces={(}{)},
    bodyfont=\normalfont\scshape,
    headpunct={},
    postheadspace=\newline,
    postheadhook={\textcolor{red}{\rule[2.0ex]{\linewidth}{0.8pt}}\\},
    spacebelow=\parsep,
    spaceabove=\parsep,
    mdframed={
        backgroundcolor=cyan!20,
            linecolor=red!30,
            innertopmargin=6pt,
            roundcorner=5pt,
            innerbottommargin=6pt,
            skipbelow=\parsep }
]{myexamplestyle}

% example environment - thmtools
\declaretheorem[
    style=myexamplestyle,
    name=EEEEE,
    numberwithin=section
    %qed=$\Box$
]{EE}

\declaretheoremstyle[
    headfont=\bfseries,
    notebraces={(}{)},
    bodyfont=\normalfont\itshape,
    headpunct={},
    postheadspace=\newline,
    postheadhook={\textcolor{cyan}{\rule[2.0ex]{\linewidth}{0.8pt}}\\},
    spacebelow=\parsep,
    spaceabove=\parsep,
    mdframed={
        backgroundcolor=green!20,
            linecolor=magenta!30,
            innertopmargin=6pt,
            roundcorner=5pt,
            innerbottommargin=6pt,
            skipbelow=\parsep }
]{mysecondexamplestyle}

% example environment - thmtools
\declaretheorem[
    style=mysecondexamplestyle,
    name=DDDDDD,
    numberwithin=chapter
]{DD}
\begin{document}
\begin{EE}
Some text.
\end{EE}

\begin{DD}
The other text
\end{DD}
\end{document}

在上面的代码中,第一个theoremstyle被标记myexamplestyle为 ,第二个我已更改为mysecondexamplesytle以避免重叠。这种重命名并非总是必要的,但它是一种很好的做法。测试示例表明,重复声明相同的样式名称的行为相当不可预测。

您的示例代码无法加载mdframed包。将此添加到代码中会删除一些警告。要获得方框角落的圆形效果,您还需要指定tikzframemethod。添加行

\usepackage[framemethod=tikz]{mdframed}

然后产生

样本输出四舍五入

这也许更符合您的预期。

skipbelow我已删除您规范中的重复项mdframed。您可能想将其中一个改为skipabove

相关内容