# Spacing for \listtheorems in ntheorem

Q: How do I get my theorem number and name to not overlap each other in my list of theorems?

This is basically the same question as "Spacing control for listtheorems". But the solutions mentioned there still don't work for me. I've tried the following:

• egreg's \makeatletter solution
• minimizing package conflicts by eliminating some and re-ordering declarations
• a global search/replace of 2.3em with 5.0em in C:\Program Files\MiKTeX 2.8\tex\latex\ntheorem\ntheorem.sty

\documentclass{book}

% Original set-up
\usepackage[amsthm,thmmarks,hyperref]{ntheorem}
\usepackage{amsmath,amsfonts}
\usepackage[bookmarks=true,bookmarksnumbered=true]{hyperref}

%% More minimal set-up (still doesn't work)
%\usepackage[amsthm,thmmarks]{ntheorem}
%\usepackage{amsmath}

%% egreg's fix (doesn't work in my case)
%\makeatletter
%\def\thm@@thmline#1#2#3#4{%
%  \@dottedtocline{-2}{0em}{5em}{\protect\numberline{#2}#3}{#4}}
%\makeatother

\newtheorem{theorem}{Theorem}[section]
\newtheorem{model}[theorem]{Model}
\setcounter{theorem}{100}
\numberwithin{equation}{section}

\begin{document}
\theoremlisttype{allname}
\listtheorems{theorem,model}
\begin{theorem}[My Theorem title]
My theorem text
\end{theorem}
\begin{model}[My Model title]
My model text
\end{model}
Lorem ipsum dolor sit amet.
\end{document}

-

With hyperref loaded, quite a few instances of "2.3em" have to be replaced by a larger value. For convenience, I use the etoolbox package to do so.

\documentclass{book}

\usepackage[amsthm,thmmarks,hyperref]{ntheorem}
\usepackage{amsmath,amsfonts}
\usepackage[bookmarks=true,bookmarksnumbered=true]{hyperref}

\usepackage{etoolbox}

\makeatletter
\patchcmd{\thm@@thmline@noname}{2.3em}{5em}{}{}
\patchcmd{\thm@@thmline@noname}{2.3em}{5em}{}{}
\patchcmd{\thm@@thmline@noname}{2.3em}{5em}{}{}
\patchcmd{\thm@@thmline@name}{2.3em}{5em}{}{}
\patchcmd{\thm@@thmline@name}{2.3em}{5em}{}{}
\patchcmd{\thm@@thmline@name}{2.3em}{5em}{}{}
\makeatother

\newtheorem{theorem}{Theorem}[section]
\newtheorem{model}[theorem]{Model}
\setcounter{theorem}{100}
\numberwithin{equation}{section}

\begin{document}
\theoremlisttype{allname}
\listtheorems{theorem,model}
\begin{theorem}[My Theorem title]
My theorem text
\end{theorem}
\begin{model}[My Model title]
My model text
\end{model}
Lorem ipsum dolor sit amet.
\end{document}


-
This does work on my larger example. Not the nicest looking since there's more space between theorems 1-9 and their titles than there is for theorems 10-99. I'll poke around in the ntheorem to see if I can get, e.g., theorem 1 to be numbered as 0.0.01. –  lowndrul Apr 25 '12 at 22:48

There's this very example in the documentation of the new package regexpatch; as lockstep says, more patches are necessary because the string 2.3em appears three times in each macro to patch. All patches can be done in one swoop with

\usepackage{regexpatch}
\makeatletter
%\xpatchcmd*{\thm@@thmline}{2.3em}{5em}{}{} % not really needed
\xpatchcmd*{\thm@@thmline@name}{2.3em}{5em}{}{}
\xpatchcmd*{\thm@@thmline@noname}{2.3em}{5em}{}{}
\makeatother


because the *-version of \xpatchcmd does a "replace all". This has also the advantage that it works also when hyperref is not loaded.

-
I used this code in place of @lockstep's and it did not compile. It didn't matter if I uncommented that one line of code either. The end of the message I received went as follows: ("C:\Program Files\MikTeX 2.8\tex\latex\exp13\13file.sty")) ! undefined control sequence. <argument> \ExplFileName 1.30 ...e}{\ExplFileVersion}{\ExplFileDescription} –  lowndrul Apr 26 '12 at 0:36
@brianjd You have to update your TeX distribution. The version of expl3 present in MiKTeX 2.8 is too old. –  egreg Apr 26 '12 at 8:12
:) You were right. (I'm in the middle of a large project and been hesitant about updating anything for fear of breaking stuff). What I did that fixed the problem: 1. uninstall expl3; 2. install l3experimental, l3kernel and l3packages; 3. uninstall xpackages. –  lowndrul Apr 26 '12 at 17:51
With a patched newtheoremstyle I need exactly the opposite -- uncomment the first line, while the two others doesn't make any difference -- and the one gets then right spacning. –  Adobe Feb 18 '13 at 12:50