1

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}

1

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}

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.