答案1
这是一个使用etoc
包的解决方案。
\documentclass{book}
\usepackage{etoc}
\usepackage{etoolbox}
\usepackage{longtable,array}
\makeatletter
\patchcmd\@caption{\csname ext@#1\endcsname}{toc}{}{}
\makeatother
\etocsetlevel{figure}{6}
\etocsetlevel{table}{6}
\newcommand{\listof}[1]{%
\begingroup
\etocglobaldefs
\etocsetlevel{figure}{0}
\etocsetlevel{table}{0}
\etocsetlevel{part}{0}
\etocsetlevel{#1}{-2}
\etocsetstyle{#1}
{}{\\\hline}{\csname #1name\endcsname\space\etocnumber: \etocname &\etocpage }{}
\etocsettocstyle
{\cleardoublepage% or \par
\begingroup
\centering\Large\bfseries\csname list#1name\endcsname
\par\endgroup
\begin{longtable}{|p{8cm}|c|}
\hline
\centering\bfseries\csname #1name\endcsname & \bfseries Page number
}
{\\\hline\end{longtable}}
\etocsetnexttocdepth{-1}
\tableofcontents
\endgroup}
\renewcommand{\listoffigures}{\listof{figure}}
\renewcommand{\listoftables}{\listof{table}}
\begin{document}
\tableofcontents
\listoffigures
\listoftables
\chapter{One}
\section{One one}
\begin{figure}
\centering
\rule{5cm}{1.5cm}
\caption{Foo caption}
\end{figure}
\section{One two}
\begin{table}
\centering
\rule{5cm}{1.5cm}
\caption{Foo table}
\end{table}
\begin{figure}
\centering
\rule{5cm}{1.5cm}
\caption{Foo bar}
\end{figure}
\chapter{Two}
\section{Two one}
\begin{figure}
\centering
\rule{5cm}{1.5cm}
\caption{Foo caption two}
\end{figure}
\section{Two two}
\begin{table}
\centering
\rule{5cm}{1.5cm}
\caption{Foo table two}
\end{table}
\begin{figure}
\centering
\rule{5cm}{1.5cm}
\caption{Foo bar two}
\end{figure}
\end{document}