这是我的 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.
以下是其输出:
由于这应该是最小的,我没有改变列表标题的语言,也没有包括teorspec
真正激发 值 8 的非定理\thmt@listnumwidth
。无论如何,问题很明显:列表中的点覆盖了两个teorspec
定理的名称。看到这一点,我试着看看列表背后的代码。我发现\csname l@<first argument of \contentsline>\endcsname
在 内部执行\contentsline
,我在 loe 中找到它。所以我重新定义了它,如您所见,没有任何效果。那么我如何阻止这些点与定理名称重叠?
答案1
您正在打印数字所在的标题。您只需删除 in\numberline
即可\ll@thmattr
。
\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.
答案2
LaTeX 警告您:
Overfull \hbox (43.50002pt too wide) detected at line 2
\T1/ntxtlf/m/n/10 Teorema del differenziale totale
将宽度增加 44pt 可以解决打印过度的问题,将第 44 行改为
\renewcommand{\thmt@listnumwidth}{\dimexpr 8em + 44pt\relax}
请注意,此宽度是为章节编号设计的,如果与目录标记进行比较,章节标题通常会出现在以下参数中,但我在这里没有提到这一点。