我正在写一篇论文,附录中有超过一百个图表。但我不希望它们出现在图表列表/表格列表中。 - 但我希望附录和章节出现在目录中。
\documentclass[a4paper,12pt,icelandic]{report}
\usepackage[toc,page]{appendix}
\begin{document}
\tableofcontents
\listoffigures
\addcontentsline{toc}{chapter}{List of Figures}
\listoftables
\addcontentsline{toc}{chapter}{List of tables}
\chapter{Chapter 1}
\section{Section 1, chapter 1}
\section{Section 2, chapter 1}
\appendix
\addcontentsline{toc}{chapter}{Appendices}
\chapter{First appendix}
\section{Section 1}
\begin{figure} % DON'T WANT THIS TO APPEAR IN LIST OF FIGURES
\centering
\includegraphics[width=1\linewidth]{figure.png}
\caption{Caption of figure}
\label{Label of figure}
\end{figure}
\begin{table} % DON'T WANT THIS TO APPEAR IN LIST OF TABLES
\begin{tabular}{|c|c|}
\hline One & Two \\
\hline Three & Four \\
\hline
\end{tabular}
\caption{Caption of table}
\label{Label of table}
\end{table}
\end{document}
答案1
在附录之前,我重新定义了\addcontentsline
拦截{figure}
和{table}
调用并删除它们,如下所示(需要ifthen
包):
\let\svaddcontentsline\addcontentsline
\renewcommand\addcontentsline[3]{%
\ifthenelse{\equal{#1}{lof}}{}%
{\ifthenelse{\equal{#1}{lot}}{}{\svaddcontentsline{#1}{#2}{#3}}}}
这是我的 MWE(注意:我添加了正文图和表格来展示从附录中辨别报告正文的能力)
\documentclass[a4paper,12pt,icelandic]{report}
\usepackage[toc,page]{appendix}
\usepackage{graphicx,ifthen}
\begin{document}
\tableofcontents
\listoffigures
\addcontentsline{toc}{chapter}{List of Figures}
\listoftables
\addcontentsline{toc}{chapter}{List of tables}
\chapter{Chapter 1}
\section{Section 1, chapter 1}
\begin{figure} % DO WANT THIS TO APPEAR IN LIST OF FIGURES
\centering
\includegraphics[width=1\linewidth]{example-image}
\caption{Body figure}
\end{figure}
\begin{table} % DO WANT THIS TO APPEAR IN LIST OF TABLES
\begin{tabular}{|c|c|}
\hline One & Two \\
\hline Three & Four \\
\hline
\end{tabular}
\caption{Body table}
\end{table}
\section{Section 2, chapter 1}
\let\svaddcontentsline\addcontentsline
\renewcommand\addcontentsline[3]{%
\ifthenelse{\equal{#1}{lof}}{}%
{\ifthenelse{\equal{#1}{lot}}{}{\svaddcontentsline{#1}{#2}{#3}}}}
\appendix
\addcontentsline{toc}{chapter}{Appendices}
\chapter{First appendix}
\section{Section 1}
\begin{figure} % DON'T WANT THIS TO APPEAR IN LIST OF FIGURES
\centering
\includegraphics[width=1\linewidth]{example-image}
\caption{Caption of figure}
\label{Label of figure}
\end{figure}
\begin{table} % DON'T WANT THIS TO APPEAR IN LIST OF TABLES
\begin{tabular}{|c|c|}
\hline One & Two \\
\hline Three & Four \\
\hline
\end{tabular}
\caption{Caption of table}
\label{Label of table}
\end{table}
\end{document}
附录
不需要ifthen
包的重新定义的版本:
\let\svaddcontentsline\addcontentsline
\renewcommand\addcontentsline[3]{%
\edef\qtest{#1}%
\def\qmatch{lof}%
\ifx\qmatch\qtest\else%
\def\qmatch{lot}%
\ifx\qmatch\qtest\else%
\svaddcontentsline{#1}{#2}{#3}%
\fi\fi%
}
答案2
加载caption
包并使用\caption*
:
\documentclass[a4paper,12pt,icelandic]{report}
\usepackage[toc,page]{appendix}
\usepackage{caption}
\usepackage[demo]{graphicx}
\begin{document}
\tableofcontents
\listoffigures
\addcontentsline{toc}{chapter}{List of Figures}
\listoftables
\addcontentsline{toc}{chapter}{List of tables}
\chapter{Chapter 1}
\section{Section 1, chapter 1}
\section{Section 2, chapter 1}
\appendix
\addcontentsline{toc}{chapter}{Appendices}
\chapter{First appendix}
\section{Section 1}
\begin{figure} % DON'T WANT THIS TO APPEAR IN LIST OF FIGURES
\centering
\includegraphics[width=1\linewidth]{figure.png}
\caption*{Caption of figure}
\label{Label of figure}
\end{figure}
\begin{table} % DON'T WANT THIS TO APPEAR IN LIST OF TABLES
\begin{tabular}{|c|c|}
\hline One & Two \\
\hline Three & Four \\
\hline
\end{tabular}
\caption*{Caption of table}
\label{Label of table}
\end{table}
\end{document}
答案3
有一种比使用“caption”环境更简单的方法。这是博客我从哪里复制了代码。
标题包可以帮你解决这个问题:
\usepackage{标题}
然后使用
\captionsetup[图]{list=no}
从那时起从 LOF 中排除数字。显然可以使用以下方法重新打开它:
\captionsetup[figure]{list=yes}
类似地,您可以使用以下命令排除/包含表:
\captionsetup[table]{list=no} 和 \captionsetup[table]{list=yes}