2

How to prevent LaTeX from creating stretching space inside theorem headers, using a thmtools theorem?

In this example, I want "Theorem 1. " to be aligned with "Theorem 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}

0

1 Answer 1

2

To prevent the stretching, you can place the head in an \mbox, for instance. The formatting of the theorem's head can be changed using the headformat key in \declaretheoremstyle.

Here's a complete example built on yours.

\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}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .