ntheorem 中 \listtheorems 的间距

ntheorem 中 \listtheorems 的间距

问:如何使我的定理列表中的定理编号和名称不互相重叠?

这基本上是同一个问题“列表定理的间距控制”。但那里提到的解决方案对我来说仍然不起作用。我尝试了以下方法:

  • egreg 的\makeatletter解决方案
  • 通过消除一些并重新排序声明来最大限度地减少包冲突
  • 全局搜索/2.3em替换5.0emC:\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}

答案1

加载后hyperref,相当多的“2.3em”实例必须用更大的值替换。为了方便起见,我使用etoolbox包来执行此操作。

\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}

在此处输入图片描述

答案2

新软件包的文档中就有这个例子regexpatch; 正如 lockstep 所说,需要更多补丁,因为该字符串2.3em在每个要修补的宏中出现三次。所有补丁都可以一次性完成

\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

因为 *-version\xpatchcmd会“替换全部”。这还有一个优点,就是即使hyperref没有加载,它也能正常工作。

相关内容