3

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{%
  \thm@notefont{}% same as heading font
  \itshape % body font
}
\def\th@definition{%
  \thm@notefont{}% same as heading font
  \normalfont % body font
}
\newlength{\mw@mystyleposthead}
\setlength{\mw@mystyleposthead}{.5em}
\newcommand{\growposthead}[1]{\advance\mw@mystyleposthead by #1}
\declaretheoremstyle[spaceabove=\topsep, spacebelow=\topsep, headfont=\normalfont\bfseries, notefont=\bfseries, notebraces={}{}, bodyfont=\normalfont\itshape, postheadspace=\mw@mystyleposthead, name={\ignorespaces}, numbered=no, headpunct=.]{mystyle}
\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:

enter image description here

enter image description here

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?

4

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

Sample output

\documentclass[a4paper]{report}
\usepackage{amsmath,amsfonts,amssymb,amsthm,thmtools,tikz,xparse,lipsum}
\usepackage{newtxtext,newtxmath}
\usepackage{hyperref}
\makeatletter
\def\th@plain{%
  \thm@notefont{}% same as heading font
  \itshape % body font
}
\def\th@definition{%
  \thm@notefont{}% same as heading font
  \normalfont % body font
}
\newlength{\mw@mystyleposthead}
\setlength{\mw@mystyleposthead}{.5em}
\newcommand{\growposthead}[1]{\advance\mw@mystyleposthead by #1}
\declaretheoremstyle[spaceabove=\topsep, spacebelow=\topsep, headfont=\normalfont\bfseries, notefont=\bfseries, notebraces={}{}, bodyfont=\normalfont\itshape, postheadspace=\mw@mystyleposthead, name={\ignorespaces}, numbered=no, headpunct=.]{mystyle}
 \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.
| improve this answer | |
  • 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. – MickG 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. – Andrew Swann Feb 26 '15 at 17:27
1

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}

enter image description here

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.

| improve this answer | |
  • 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 – MickG Feb 26 '15 at 17:01
  • @MickG I see Andrew has just answered that. – David Carlisle Feb 26 '15 at 17:09
  • How did you achieve the red boxes? – MickG Feb 26 '15 at 17:42

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.