我想知道如何使用\listoffigures
才能在列表中显示(子)部分的标题。结果将如下所示:
Section 1
Subsection 1.1
Figure 1 .......... p1
Figure 2 .......... p1
Subsection 1.2
Figure 3 .......... p2
etc...
编辑:一个简短的例子:
\documentclass[11pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{graphicx}
\begin{document}
\tableofcontents
\newpage
\listoffigures
\newpage
\section{First section}
\subsection{First subsection of first section}
\subsection{Second subsection of first section}
\begin{figure}[htb!]
\centering
\includegraphics[]{Figure_1.pdf}
\caption[Short caption of Figure 1]{Caption of Figure 1}
\label{fig:Figure_1}
\end{figure}
\section{Second section}
\subsection{First subsection of second section}
\begin{figure}[htb!]
\centering
\includegraphics[]{Figure_2.pdf}
\caption[Short caption of Figure 2]{Caption of Figure 2}
\label{fig:Figure_2}
\end{figure}
\end{document}
第一页是目录。第二页是图表列表。我想要的是两者的混合,在本例中为:
1 First section
1.1 First subsection of first section
1.2 Second subsection of first section
1 Short caption of Figure 1 ..................... 3
2 Second section
2.1 First subsection of second section
2 Short caption of Figure 1 ..................... 3
提前感谢你的帮助,
Pierrot
答案1
如果我理解正确的话,这里有一个解决方案
\documentclass{article}
\usepackage{etoolbox}
\makeatletter
\patchcmd{\@sect}{\addcontentsline}%
{\ifnum #2>\c@secnumdepth \else
\addtocontents{lof}{%
\protect\contentsline{#1}{\protect\numberline{\csname the#1\endcsname}%
#7}{}}
\fi%
\addcontentsline}%
{}{}
\preto\listoffigures{%
\renewcommand*\l@subsection[2]{%
\ifnum \c@tocdepth >\z@
\addpenalty\@secpenalty
\setlength\@tempdima{2.3em}%
\begingroup
\parindent \z@ \rightskip \@pnumwidth
\parfillskip -\@pnumwidth
\leavevmode %\bfseries
\advance\leftskip\@tempdima
\hskip -.8em
#1\nobreak\hfil \nobreak\hb@xt@\@pnumwidth{\hss #2}\par
\endgroup
\fi}}
\renewcommand*\l@figure{\@dottedtocline{1}{3.8em}{3.2em}}
\makeatother
\begin{document}
\tableofcontents
\newpage
\listoffigures
\newpage
\section{First section}
\subsection{First subsection of first section}
\subsection{Second subsection of first section}
\begin{figure}[htb!]
\rule{5cm}{1cm}
\caption{Foo1}
\end{figure}
\section{Second section}
\subsection{First subsection of second section}
\begin{figure}[htb!]
\rule{5cm}{1cm}
\caption{Foo4}
\end{figure}
\end{document}
答案2
我认为这不是一个好主意。图没有明确的子子节级别。但如果你想要它:使用 koma 类会更容易:
\documentclass[11pt,a4paper]{scrartcl}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage[demo]{graphicx}
\makeatletter
\renewcommand\addtocentrydefault[3]{%
\tocbasic@addxcontentsline {toc}{#1}{#2}{#3}%
\tocbasic@addxcontentsline {lof}{#1}{#2}{#3}}
\renewcommand\l@figure{\@dottedtocline{1}{3.8em}{1.5em}}
\makeatother
\begin{document}
\tableofcontents
\newpage
\listoffigures
\newpage
\section{First section}
\subsection{First subsection of first section}
\subsection{Second subsection of first section}\subsubsection{blalb}
\begin{figure}[htb!]
\centering
\includegraphics[]{Figure_1.pdf}
\caption[Short caption of Figure 1]{Caption of Figure 1}
\label{fig:Figure_1}
\end{figure}
\section{Second section}
\subsection{First subsection of second section}
\begin{figure}[htb!]
\centering
\includegraphics[]{Figure_2.pdf}
\caption[Short caption of Figure 2]{Caption of Figure 2}
\label{fig:Figure_2}
\end{figure}
\end{document}