# List of theorem dots overlapping with theorem name

Here is my MWE:

\documentclass[a4paper]{report}
\usepackage{amsmath,amsfonts,amssymb,amsthm,thmtools,tikz,xparse,lipsum}
\usepackage{newtxtext,newtxmath}
\usepackage{hyperref}
\makeatletter
\def\th@plain{%
\itshape % body font
}
\def\th@definition{%
\normalfont % body font
}
\declaretheorem[style=mystyle]{@thmattr}
\NewDocumentEnvironment{teorspec}{O{Teorema}mo}
{\IfValueTF{#3}
{\begin{@thmattr}[name=#1\ #2,label=#3]}
{\begin{@thmattr}[name=#1\ #2]}
}
{\end{@thmattr}}
\newcommand\mw@mklistcmd{%
\@xa\protected@edef\csname l@\thmt@envname\endcsname{% CHECK: why p@edef?
\@nx\@dottedtocline{1}{1.5em}{\@nx\thmt@listnumwidth}%
}%
\ifthmt@isstarred
\@xa\def\csname ll@\thmt@envname\endcsname{%
\protect\numberline{\protect\let\protect\autodot\protect\@empty}%
\ifx\@empty\thmt@shortoptarg\else\protect\thmtformatoptarg{\thmt@shortoptarg}\fi
}%
\else
\@xa\def\csname ll@\thmt@envname\endcsname{%
\protect\numberline{\thmt@thmname\ \csname the\thmt@envname\endcsname\punct@list}%
\ifx\@empty\thmt@shortoptarg\else\protect\thmtformatoptarg{\thmt@shortoptarg}\fi
}%
\fi
\@xa\gdef\csname thmt@contentsline@\thmt@envname\endcsname{%
\thmt@contentslineShow% default:show
}%
}
\renewcommand{\thmt@listnumwidth}{8em}
\renewcommand\l@@thmattr{\edef\mw@tempdima{\widthof{\thmt@shortoptarg}}\@dottedtocline{1}{2.5em}{\@nx\mw@tempdima}}
\newcommand{\punct@list}{.}
\renewcommand{\ll@@thmattr}{\protect\numberline{\thmt@shortoptarg}}
\let\thmt@mklistcmd\mw@mklistcmd
\makeatother

\begin{document}
\begin{teorspec}{della palla pelosa}[pallapelosa]
Non esiste un campo conitnuo tangente ad una sfera $S^2$ che non si annulli in nessun punto.
\end{teorspec}
\begin{teorspec}{del differenziale totale}[thm:difftot]
Bla bla bla differenziale eccetera.
\end{teorspec}
\listoftheorems
\end{document}
%13 minimalizing and 1 comment. 10 making compile and 2 comment. 4 minimalizing and 2 comment.


Here is its output:

Since this is supposed to be minimal, I didn't change the language of the title of the list, nor did I include non-teorspec theorems which really motivate the value 8 for \thmt@listnumwidth. Anyway the problem is evident: the dots of the list are going over the name of the two teorspec theorems. Seeing this, I tried having a look at the code behind the list. I found out \csname l@<first argument of \contentsline>\endcsname is executed inside \contentsline, which I found in the loe. So I redefined it as you can see, with no effect whatsoever. So how do I stop those dots from overlapping with theorem names?

You are printing the titles where the numbers are meant to be. You can just remove the \numberline in \ll@thmattr.

\documentclass[a4paper]{report}
\usepackage{amsmath,amsfonts,amssymb,amsthm,thmtools,tikz,xparse,lipsum}
\usepackage{newtxtext,newtxmath}
\usepackage{hyperref}
\makeatletter
\def\th@plain{%
\itshape % body font
}
\def\th@definition{%
\normalfont % body font
}
\declaretheorem[style=mystyle]{@thmattr}
\NewDocumentEnvironment{teorspec}{O{Teorema}mo}
{\IfValueTF{#3}
{\begin{@thmattr}[name=#1\ #2,label=#3]}
{\begin{@thmattr}[name=#1\ #2]}
}
{\end{@thmattr}}
\newcommand\mw@mklistcmd{%
\@xa\protected@edef\csname l@\thmt@envname\endcsname{% CHECK: why p@edef?
\@nx\@dottedtocline{1}{1.5em}{\@nx\thmt@listnumwidth}%
}%
\ifthmt@isstarred
\@xa\def\csname ll@\thmt@envname\endcsname{%
\protect\numberline{\protect\let\protect\autodot\protect\@empty}%
\ifx\@empty\thmt@shortoptarg\else\protect\thmtformatoptarg{\thmt@shortoptarg}\fi
}%
\else
\@xa\def\csname ll@\thmt@envname\endcsname{%
\protect\numberline{\thmt@thmname\ \csname the\thmt@envname\endcsname\punct@list}%
\ifx\@empty\thmt@shortoptarg\else\protect\thmtformatoptarg{\thmt@shortoptarg}\fi
}%
\fi
\@xa\gdef\csname thmt@contentsline@\thmt@envname\endcsname{%
\thmt@contentslineShow% default:show
}%
}
\renewcommand{\thmt@listnumwidth}{0em}
\renewcommand\l@@thmattr{\edef\mw@tempdima{\widthof{\thmt@shortoptarg}}\@dottedtocline{1}{2.5em}{\@nx\mw@tempdima}}
\newcommand{\punct@list}{.}
\renewcommand{\ll@@thmattr}{\thmt@shortoptarg}
\let\thmt@mklistcmd\mw@mklistcmd
\makeatother

\begin{document}
\begin{teorspec}{della palla pelosa}[pallapelosa]
Non esiste un campo conitnuo tangente ad una sfera $S^2$ che non si annulli in nessun punto.
\end{teorspec}
\begin{teorspec}{del differenziale totale}[thm:difftot]
Bla bla bla differenziale eccetera.
\end{teorspec}
\listoftheorems
\end{document}
%13 minimalizing and 1 comment. 10 making compile and 2 comment. 4 minimalizing and 2 comment.

• Now I see! The \numberline was the problem. Instead of \l@@thmattr, I should have worked on \@tempdima if I wanted to keep \numberline. Btw, your original proposal (adding empty argument to \numberline) gave me a huge space before the title. Accepting answer. Feb 26 '15 at 17:25
• \numberline puts its contents flushleft in a box of width \@tempdima, so yes my first version had that space still present. Feb 26 '15 at 17:27

LaTeX warns you:

Overfull \hbox (43.50002pt too wide) detected at line 2
\T1/ntxtlf/m/n/10 Teorema del differenziale totale


and increasing the width by 44pt solves the over printing, change line 44 to

\renewcommand{\thmt@listnumwidth}{\dimexpr 8em + 44pt\relax}


Note that this width is designed for section numbers, the section title normally goes in the following argument if you compare with table of contents markup but I did not address that here.

• Why does the redefinition of \l@@thmattr do that? After all, it alters what should be taken as arguments and puts something else instead of \thmt@listnumwidth Feb 26 '15 at 17:01
• @MickG I see Andrew has just answered that. Feb 26 '15 at 17:09
• How did you achieve the red boxes? Feb 26 '15 at 17:42