回忆录如何打印内容页的标题?

回忆录如何打印内容页的标题?

关于这个问题如何动态计算空列表的高度?,我了解到我需要知道我的班级如何计算其内容页面标题,以便使答案有效。我试过\large\contentsname\vskip\baselineskip\vskip\afterchapskip,但这还不够,因为List of Tables是空的(没有表格)并且不应该显示:

This is pdfTeX, Version 3.14159265-2.6-1.40.18 (MiKTeX 2.9.6400)
entering extended mode
(test3.tex
LaTeX2e <2017-04-15>
Babel <3.12> and hyphenation patterns for 76 language(s) loaded.
(D:\User\Documents\latex\texmfs\install\tex\latex\memoir\memoir.cls
Document Class: memoir 2016/05/16 v3.7f configurable book, report, article docu
ment class
(D:\User\Documents\latex\texmfs\install\tex\generic\oberdiek\ifpdf.sty)
(D:\User\Documents\latex\texmfs\install\tex\latex\ifetex\ifetex.sty
(D:\User\Documents\latex\texmfs\install\tex\plain\ifetex\ifetex.tex))
(D:\User\Documents\latex\texmfs\install\tex\generic\ifxetex\ifxetex.sty)
(D:\User\Documents\latex\texmfs\install\tex\generic\oberdiek\ifluatex.sty)
(D:\User\Documents\latex\texmfs\install\tex\latex\memoir\mem12.clo)) (test3.aux
) (test3.toc) (test3.lof)
The height of the list 'List of Figures' is '131.77776pt' from '67.84pt'
(test3.lot)
The height of the list 'List of Tables' is '117.27776pt' from '67.84pt'
[1{D:/User/Documents/latex/texmfs/data/pdftex/config/pdftex.map}] [2] [3]
(test3.aux) )<D:/User/Documents/latex/texmfs/install/fonts/type1/public/amsfont
s/cm/cmbx12.pfb><D:/User/Documents/latex/texmfs/install/fonts/type1/public/amsf
onts/cm/cmr12.pfb>
Output written on test3.pdf (3 pages, 23659 bytes).
Transcript written on test3.log.

我如何设置\boxBforwhenlistisnotempty回忆录标题页?

\documentclass[12pt,a4paper]{memoir}

\newbox\boxAforwhenlistisnotempty
\newbox\boxBforwhenlistisnotempty

\newcommand{\whenlistisnotempty}[2]{%
  \setbox\boxAforwhenlistisnotempty\vbox{#2}%
  \setbox\boxBforwhenlistisnotempty\vbox{%
    \large\contentsname\vskip\baselineskip\vskip\afterchapskip%
  }%
  \typeout{The height of the list '#1'
      is '\the\ht\boxAforwhenlistisnotempty'
      from '\the\ht\boxBforwhenlistisnotempty'}%
  \ifdim\ht\boxAforwhenlistisnotempty>\ht\boxBforwhenlistisnotempty%
    \unvbox\boxAforwhenlistisnotempty%
  \fi%
}

\begin{document}
\tableofcontents

\whenlistisnotempty{\listfigurename}{
\listoffigures
}

\whenlistisnotempty{\listtablename}{
\listoftables
}

\chapter{First section}

\begin{figure}
    \centering
    Figure
    \caption{Caption}
\end{figure}

\end{document}

参考

  1. 如何停止 \newsavebox 向我提供坏盒子警告或如何使用 \setbox 来获得更好的名称?

答案1

虽然这不是答案,但这可能会有所帮助。

如果您调用,\listoftables.lot文件将被创建。\chapter命令将添加

\addvspace{10pt}

到文件和表格标题将添加类似

\contentsline{table}{\numberline}{1.1}{\ignorespaces A table}}{3}%

到文件。

如果没有表格,则.lot文件将仅包含\addvspace{10pt}

在查看了您之前关于这个主题的问题(和答案)后,在...的帮助下(https://tex.stackechange.com/questions.com/questions/51575/How-to-dynamically-calculate-the-height-of-an-empty-list-of-things? 想出一个解决方案来解决你没有显示的问题表格列表当没有桌子的时候。

% tocprob21.tex  SE 515811  No LoT if no tables?

\documentclass{memoir}
\usepackage{comment}

\newsavebox{\testbox}
\newsavebox{\testboxB}
\def\wheninteresting#1{%
\savebox{\testbox}{\vbox{#1}}%
\savebox{\testboxB}{\vbox{\chapter*{\contentsname}}}
\ifdim\ht\testbox>\ht\testboxB
\usebox{\testbox}
\fi}

\begin{document}

\wheninteresting{
\listoftables
}

\chapter{One}

Some text

\begin{figure}
\centering
FIGURE
\caption{A figure}
\end{figure}

\begin{comment}
\begin{table}
\centering
TABLE
\caption{A table}
\end{table}
\end{comment}

\end{document}

相关内容