使用浮点数创建定义列表,但在文档中看不到标题?

使用浮点数创建定义列表,但在文档中看不到标题?

我正在编写一份包含大量示例、定义、图表等的文档(范畴论,你可能已经猜到了),我想提供列出所有这些内容的索引——我已经制作了类似以下内容:

\documentclass[a4paper]{report}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{stix}
\usepackage{mathtools}
\usepackage[document]{ragged2e}
\usepackage{wasysym}
\usepackage{booktabs}
\usepackage{enumitem}
\usepackage{pgfplots}
\usepackage{tikz}
\usepackage{float}

\usetikzlibrary{arrows,bending,calc,patterns}

\newcommand\irregularcircle[2]{% radius, irregularity
    \pgfextra {\pgfmathsetmacro\len{(#1)+rand*(#2)}}
    +(0:\len pt)
    \foreach \a in {10,20,...,350}{
        \pgfextra {\pgfmathsetmacro\len{(#1)+rand*(#2)}}
        -- +(\a:\len pt)
    } -- cycle
}
\theoremstyle{definition}
\newtheorem{mydef}{Definition}[section]
\newtheorem{ex}{Example}[section]
\newtheorem{thm}{Theorem}[section]

\floatstyle{plain}
\newfloat{defn}{thp}{def}[section]
\floatname{defn}{Definition}
\newfloat{exmp}{thp}{ex}[section]
\floatname{exmp}{Example}
\newfloat{diag}{htbp}{dia}[section]
\floatname{diag}{Diagram}
\newfloat{tab}{thp}{tab}[section]
\floatname{tab}{Table}
\newfloat{thrm}{thp}{thm}[section]
\floatname{thrm}{Theorem}

\makeatletter
\everymath{\if@display\else\thickmuskip=2mu plus 2mu\fi}
\renewcommand*{\listof}[2]{%
    \@ifundefined{ext@#1}{\float@error{#1}}{%
        \@namedef{l@#1}{\@dottedtocline{1}{1.5em}{3em}}% <-------  replaced 2.3em with 3em here
        \float@listhead{#2}%
        \begingroup\setlength{\parskip}{\z@}%
            \@starttoc{\@nameuse{ext@#1}}%
        \endgroup}}
\makeatother

\title{Notes to Topoi - the categorial analysis of logic\\by Robert Goldblatt}
\author{Jan Andersen}

\begin{document}
    \listof{defn}{Definitions}
    \chapter{Mathematics = Set Theory?}
    \section{Set Theory}
    \begin{defn}[H]
        \begin{mydef}
%           \setbox0=\vbox{\caption{Principle of Comprehension}}
            \caption{Principle of Comprehension}
            \label{def:PrincipleofComprehension}
            \textbf{Principle of Comprehension}\\
            If $\phi(x)$ is a property or condition pertaining to objects $x$, then there exists a set whose elements are precisely the objects that have the property $\phi(x)$
        \end{mydef}
    \end{defn}
\end{document}

这给了我列表,但我也得到了我不想要的标题:

在此处输入图片描述

我怎样才能隐藏字幕的显示?我尝试了这个答案,但它对我来说不起作用 - 条目从我的索引中消失,但标题保留下来。

答案1

为了完整起见,并感谢 David Carlisle 和 leandriis 的评论,以下是我的工作内容:

\documentclass{article}
\usepackage[english]{babel}
\usepackage[margin=2cm]{geometry}% just for the example
\usepackage{xcolor}
\usepackage{amsthm}
\usepackage{thmtools}
\usepackage{mdframed}
\usepackage{etoolbox}

\makeatletter
\patchcmd\thmt@mklistcmd
  {\thmt@thmname}
  {\check@optarg{\thmt@thmname}}
  {}{}
\patchcmd\thmt@mklistcmd
  {\thmt@thmname\ifx}
  {\check@optarg{\thmt@thmname}\ifx}
  {}{}
\protected\def\check@optarg#1{%
  \@ifnextchar\thmtformatoptarg\@secondoftwo{#1}%
}
\makeatother

\declaretheoremstyle[
  spaceabove=6pt, spacebelow=6pt,
  headfont=\normalfont\bfseries,
  postheadspace=1em,
  notefont=\bfseries,
  notebraces={(}{)},
  bodyfont=\itshape,
  shaded={bgcolor=yellow!20}
]{thmstyle}

\declaretheorem[style=thmstyle,name=Theorem]{theorem}
\declaretheorem[style=thmstyle,name=Example]{example}

\begin{document}

\begin{theorem}[Somebody]
...
\end{theorem}

\begin{theorem}
...
\end{theorem}

\begin{example}[First example]
    ...
\end{example}

\begin{example}[Next example]
    ...
\end{example}

\begin{example}[Final example]
    ...
\end{example}

\renewcommand{\listtheoremname}{List of Theorems}
\addcontentsline{toc}{section}{\listtheoremname}
\listoftheorems[ignoreall,show=theorem]
\renewcommand{\listtheoremname}{List of Examples}
\addcontentsline{toc}{section}{\listtheoremname}
\listoftheorems[ignoreall,show=example]

\end{document}

相关内容