To solve this we need to patch \thm@@thmline
in ntheorem
.
It's called \thm@@thmline@noname
or \thm@@thmline@name
depending on the called options all
or opt
or, respectively allname
or optname
.
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 when hyperref
is loaded.
Therefore you can either patch \thm@@thmline
directly and force allname
/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 use opt
and all
. Both snippets will work with and without hyperref
.
Solution 1
\documentclass{article}
\usepackage{ntheorem}
%\usepackage{hyperref}
%\usepackage[hyperref]{ntheorem}
\makeatletter
\AtBeginDocument{
\@ifpackageloaded{hyperref}
{
% hyperref version of the macro
\renewcommand\thm@@thmline[5]{%
\@dottedtocline {-2}{0em}{2.3em}{\hyper@linkstart{link}{#5}{\makebox[\widesttheorem][l]{#1 \protect \numberline {#2}}#3}\hyper@linkend}{#4}%
}
}
{
% standard, non-hyperref version of the macro
\renewcommand\thm@@thmline[4]{%
\@dottedtocline {-2}{0em}{2.3em}{\makebox[\widesttheorem][l]{#1 \protect \numberline {#2}}#3}{#4}%
}
}
\settowidth{\widesttheorem}{Proposition 10\quad}
}
\makeatother
\newlength\widesttheorem
\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}
Solution 2
\documentclass{article}
\usepackage{ntheorem}
%\usepackage{hyperref}
%\usepackage[hyperref]{ntheorem}
\makeatletter
\def\thm@@thmline@name#1#2#3#4{%
\@dottedtocline{-2}{0em}{2.3em}%
{\makebox[\widesttheorem][l]{#1 \protect\numberline{#2}}#3}%
{#4}}
\@ifpackageloaded{hyperref}{
\def\thm@@thmline@name#1#2#3#4#5{%
\ifx\\#5\\%
\@dottedtocline{-2}{0em}{2.3em}%
{\makebox[\widesttheorem][l]{#1 \protect\numberline{#2}}#3}%
{#4}
\else
\ifHy@linktocpage\relax\relax
\@dottedtocline{-2}{0em}{2.3em}%
{\makebox[\widesttheorem][l]{#1 \protect\numberline{#2}}#3}%
{\hyper@linkstart{link}{#5}{#4}\hyper@linkend}%
\else
\@dottedtocline{-2}{0em}{2.3em}%
{\hyper@linkstart{link}{#5}%
{\makebox[\widesttheorem][l]{#1 \protect\numberline{#2}}#3}\hyper@linkend}%
{#4}%
\fi
\fi}
}
\makeatother
\newlength\widesttheorem
\AtBeginDocument{
\settowidth{\widesttheorem}{Proposition 10\quad}
}
\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}
In the argument to \settowidth
you put the longest label, the biggest number and a suitable spacing.
