答案1
您可以重新定义 mem@listoftables,例如使用 pdffilesize 来测试 \jobname.lot 是否为空,请参阅回答“检查文件是否为空?”。注释掉表格后你也会看到表格列表消失。
\documentclass[12pt]{memoir}
\def\firstoftwo#1#2{#1}
\def\secondoftwo#1#2{#2}
\def\iffileexist#1{%
\expandafter\ifx\expandafter&\pdffilesize{#1}&%
\expandafter\secondoftwo
\else
\expandafter\firstoftwo
\fi
}
\def\iffileempty#1{%
\ifnum0\pdffilesize{#1}>0
\expandafter\secondoftwo
\else
\expandafter\firstoftwo
\fi
}
\makeatletter
\@namedef{mem@listoftables}#1{%
\ensureonecol
\par
\begingroup
\iffileempty{\jobname.lot}{\relax}{%
\@nameuse{@lotmaketitle}
\if#1
\ifmem@em@starred@listof\else
\phantomsection
\addcontentsline{toc}{chapter}{List of Tables}
\fi
\fi
\parskip\cftparskip
\@nameuse{cftlotbeforelisthook}%
\@input{\jobname.lot}%
}
\if@filesw
\AtEndDocument{%
\expandafter\ifx\csname tf@lot\endcsname\relax
\expandafter\newwrite\csname tf@lot\endcsname
\immediate\openout \csname tf@lot\endcsname \jobname.lot\relax
\fi
}%
\fi
\@nobreakfalse
\@nameuse{cftlotafterlisthook}%
\endgroup
\restorefromonecol}
\makeatother
\begin{document}
\listoftables*
Contents.
\begin{table}
\caption{test tabel caption}
test table
\end{table}
\end{document}