更改 \listoftheorems 的内容并超链接到文本

更改 \listoftheorems 的内容并超链接到文本

这是我的 MWE:

\documentclass{report}
\usepackage{amsthm}
\usepackage{libertine} % allows bf sc fonts http://tex.stackexchange.com/a/98581/104449
\usepackage{thmtools}

\declaretheoremstyle[
  spaceabove=\topsep, spacebelow=\topsep,
  headfont=\libertine\bfseries\scshape,
  notefont=\libertine\bfseries\scshape,
  headindent=-1em,
  headpunct=\newline,
  numberwithin=chapter,
  notebraces={- }{}
]{mythmstyle}
\declaretheorem[style=mythmstyle]{thm}
\declaretheorem[style=mythmstyle, title=Defn]{defn}

\begin{document}
\pagenumbering{roman}

\listoftheorems[ignoreall, show={thm}]
\begingroup               % Temporarily disable \clearpage to show both lists on one page
  \let\clearpage\relax    % http://tex.stackexchange.com/a/14511/104449
  \renewcommand{\listtheoremname}{List of Definitions}
  \listoftheorems[ignoreall, show={defn}]
\endgroup


\newpage
\pagenumbering{arabic}
\chapter{}
\begin{thm}[My first theorem]
\end{thm}

\begin{defn}[My first definition]
\end{defn}

\chapter{}
\begin{thm}[My second theorem]
\end{thm}

\begin{defn}[My second definition]
\end{defn}

\end{document}

其输出结果如下:

在此处输入图片描述

我想删除定理列表和定义列表中每个条目的 Thm/Defn 前缀和括号。例如,我希望第一个条目如下所示:

1.1 My first theorem ...................................... 1

我还希望列表中的条目超链接到所引用定理/定义的页面(最好是确切位置)。

有人知道怎么做吗?或者有关于应该阅读哪些文档的提示吗?我看了thm工具文档,\listotheorems但我无法弄清楚如何更改每一行条目的内容。

提前致谢。

答案1

name={...}命令中的定义选项默认\declaretheoremstyle为定理名称,或者可以说name={}删除定理列表中的前缀,但这也会影响正文显示。(这不是最好的解决方案)

\thmtformatoptarg可以通过重新定义为来删除括号

\renewcommand{\thmtformatoptarg}[1]{#1}

作为最后一个包加载hyperref提供了正确的链接。

\documentclass{report}
\usepackage{amsthm}
\usepackage{libertine} % allows bf sc fonts http://tex.stackexchange.com/a/98581/104449
\usepackage{thmtools}

\declaretheoremstyle[
  spaceabove=\topsep, spacebelow=\topsep,
  headfont=\libertine\bfseries\scshape,
  notefont=\libertine\bfseries\scshape,
  headindent=-1em,
  headpunct=\newline,
  numberwithin=chapter,
  notebraces={- }{}
]{mythmstyle}
\declaretheorem[style=mythmstyle,name={}]{thm}
\declaretheorem[style=mythmstyle, title=Defn,name={}]{defn}

\renewcommand{\thmtformatoptarg}[1]{#1}%

\usepackage{hyperref}

\begin{document}
\pagenumbering{roman}

\listoftheorems[ignoreall, show={thm}]
\begingroup               % Temporarily disable \clearpage to show both lists on one page
  \let\clearpage\relax    % http://tex.stackexchange.com/a/14511/104449
  \renewcommand{\listtheoremname}{List of Definitions}
  \listoftheorems[ignoreall, show={defn}]
\endgroup


\newpage
\pagenumbering{arabic}
\chapter{}
\begin{thm}[My first theorem]
\end{thm}

\begin{defn}[My first definition]
\end{defn}

\chapter{}
\begin{thm}[My second theorem]
\end{thm}

\begin{defn}[My second definition]
\end{defn}

\end{document}

更新

\thmt@thmname里面的仅在定义\thmt@mklistcmd期间调用一次theorem。如果未请求名称,则应将其删除。修补\thmt@mklistcmd或重新定义它:

\documentclass{report}
\usepackage{amsthm}
\usepackage{libertine} % allows bf sc fonts http://tex.stackexchange.com/a/98581/104449
\usepackage{thmtools}


\newif\ifusethmname

\makeatletter

\renewcommand\thmt@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}%
      \ifusethmname
      \thmt@thmname
      \fi
      \ifx\@empty\thmt@shortoptarg\else\protect\thmtformatoptarg{\thmt@shortoptarg}\fi
    }%
  \else
    \@xa\def\csname ll@\thmt@envname\endcsname{%
      \protect\numberline{\csname the\thmt@envname\endcsname}%
      \ifusethmname
      \thmt@thmname
      \fi
      \ifx\@empty\thmt@shortoptarg\else\protect\thmtformatoptarg{\thmt@shortoptarg}\fi
    }%
  \fi
  \@xa\gdef\csname thmt@contentsline@\thmt@envname\endcsname{%
    \thmt@contentslineShow% default:show
  }%
}


\declaretheoremstyle[
  spaceabove=\topsep, spacebelow=\topsep,
  headfont=\libertine\bfseries\scshape,
  notefont=\libertine\bfseries\scshape,
  headindent=-1em,
  headpunct=\newline,
  numberwithin=chapter,
  notebraces={- }{}
]{mythmstyle}
\declaretheorem[style=mythmstyle, ]{thm}
\declaretheorem[style=mythmstyle, title=Defn]{defn}

\usepackage{xpatch}


\renewcommand{\thmtformatoptarg}[1]{#1}%

\usepackage{hyperref}

\begin{document}
\pagenumbering{roman}

\makeatletter

\makeatother
\listoftheorems[ignoreall, show={thm}]
\begingroup               % Temporarily disable \clearpage to show both lists on one page
  \let\clearpage\relax    % http://tex.stackexchange.com/a/14511/104449
  \renewcommand{\listtheoremname}{List of Definitions}
  \listoftheorems[ignoreall, show={defn}]
\endgroup


\newpage
\pagenumbering{arabic}
\chapter{}
\begin{thm}[My first theorem]
\end{thm}

\begin{defn}[My first definition]
\end{defn}

\chapter{}
\begin{thm}[My second theorem]
\end{thm}

\begin{defn}[My second definition]
\end{defn}

\end{document}

在此处输入图片描述

相关内容