thmtools - 对齐定理标题

thmtools - 对齐定理标题

如何使用 thmtools 定理防止 LaTeX 在定理标题内创建拉伸空间?

在这个例子中,我想要“定理1。”与之对齐“定理2。”

\documentclass[12pt, a4paper]{article}
\usepackage[utf8]{inputenc}

\usepackage{amsthm}
\usepackage{thmtools}

\declaretheoremstyle[
            headfont=\bfseries,
            notefont=\bfseries,
            notebraces={(}{)},
            bodyfont=\itshape,
            qed=,
            headpunct = .
            ]{custom}

\declaretheorem[style = custom, name = Theorem]{thm}

\begin{document}
    \begin{thm}
        This is a small theorem.
    \end{thm}
    \begin{thm}
        This is a theorem which is a little bit larger and that ends withareallybigword.
    \end{thm}
\end{document}

答案1

为了防止拉伸,您可以将头部放在 中,例如。可以使用中的键\mbox更改定理头部的格式。headformat\declaretheoremstyle

这是一个基于您的示例构建的完整示例。

\documentclass[12pt, a4paper]{article}
\usepackage[utf8]{inputenc}

\usepackage{amsthm}
\usepackage{thmtools}

\declaretheoremstyle[
            headfont=\bfseries,
            notefont=\bfseries,
            notebraces={(}{)},
            bodyfont=\itshape,
            qed=,
            headpunct=.,
            headformat={\mbox{\NAME{} \NUMBER\NOTE}}
            ]{custom}

\declaretheorem[style=custom, name=Theorem]{thm}

\begin{document}
    \begin{thm}
        This is a small theorem.
    \end{thm}
    \begin{thm}
        This is a theorem which is a little bit larger and that ends withareallybigword.
    \end{thm}
\end{document}

相关内容