Question:
How do I align the names of theorems in ntheorem
list of theorems?
Screenshot:
Screenshot: (photoshopped)
Context:
I am using the ntheorem
package to typeset a list of theorems and definitions (\listtheorems
) and have defined several custom theorem environments. The environment names have different word lengths which leads to a non aligned typesetting in the list.
I am writing in German language in which only one environment name is significantly shorter altough noticable minimal meanderings exist between the others as well.
Screenshot:
Related Questions
I have found two related questions but both focus only on spacing.
TeX.SE Question: 53353 Titlespacing for \listtheorems in ntheorem
TeX.SE Question: 43166 Spacing numwidth control for \listtheorems
Minimal Example:
\documentclass{article}
\usepackage{ntheorem}
\theoremlisttype{allname}
\newtheorem{axiom}{Axiom}
\newtheorem{proposition}{Proposition}
\newtheorem{lemma}{Lemma}
\newtheorem{corollary}{Corollary}
\newtheorem{converse}{Converse}
\begin{document}
\listtheorems{axiom,proposition,lemma,corollary,converse}
\begin{axiom}[Theorem 1] \end{axiom}
\begin{proposition}[Theorem 2] \end{proposition}
\begin{lemma}[Theorem 3] \end{lemma}
\begin{corollary}[Theorem 4] \end{corollary}
\begin{converse}[Theorem 5] \end{converse}
\end{document}
Best Answer
To solve this we need to patch
\thm@@thmline
inntheorem
.It's called
\thm@@thmline@noname
or\thm@@thmline@name
depending on the called optionsall
oropt
or, respectivelyallname
oroptname
.There are two versions of these macros in
ntheorem
. Those with four parameters are used in non-hyperref
documents. Those with five parameters are used in documents whenhyperref
is loaded.Therefore you can either patch
\thm@@thmline
directly and forceallname
/optname
behavior like in the first code snippet or you can patch\thm@@thmline@name
as in the second code snippet, which will preserve the ability to useopt
andall
. Both snippets will work with and withouthyperref
.Solution 1
} \settowidth{\widesttheorem}{Proposition 10\quad} } \makeatother \newlength\widesttheorem
Solution 2
In the argument to
\settowidth
you put the longest label, the biggest number and a suitable spacing.