我如何获得以下类型的“图形列表”?
图片列表
没错,这个图表列表被设置为表格。我知道这不能通过命令\listoffigures
直接获得,但我们的论文需要这种格式。我可以通过制作一个真正的表格并使用交叉引用来获得这种类型,但我更喜欢使用或其他简单的命令来获得它\listoffigures
。
答案1
你可以试试这个;重要的代码在\makeatletter
和之间\makeatother
\documentclass{book}
\makeatletter
\renewcommand\listoffigures{%
\chapter*{\listfigurename}%
\@mkboth{\MakeUppercase\listfigurename}%
{\MakeUppercase\listfigurename}%
\begingroup\let\addvspace\@gobble
\raggedbottom\offinterlineskip\def\l@figure{\xiao@figure}\parindent\z@
\hrule
\vrule\vrule width \z@ height 1.2\ht\strutbox depth 1.2\dp\strutbox
\makebox[\dimexpr3cm-0.8pt\relax][c]{\bfseries Number}\vrule
\parbox{\dimexpr\textwidth-6cm}{\normalbaselines\centering {\large\strut}\bfseries Caption{\large\strut}}\vrule
\makebox[\dimexpr3cm-0.8pt\relax][c]{\bfseries Page}\vrule
\hrule
\@starttoc{lof}%
\endgroup
}
\def\xiao@figure#1#2{\xiao@figurei#1{#2}}
\long\def\xiao@figurei\numberline#1#2#3{%
\vrule\vrule width \z@ height 1.2\ht\strutbox depth 1.2\dp\strutbox
\makebox[\dimexpr3cm-0.8pt\relax][c]{Fig.\ #1}\vrule
\parbox{\dimexpr\textwidth-6cm}{\normalbaselines\centering {\large\strut}#2{\large\strut}}\vrule
\makebox[\dimexpr3cm-0.8pt\relax][c]{#3}\vrule
\hrule
\hskip-.4pt
\hrule
\nobreak
}
\makeatother
\begin{document}
\frontmatter
\listoffigures
\mainmatter
\chapter{A}
\begin{figure}
\caption{Caption}
\end{figure}
\begin{figure}
\caption{Caption which is very
very very very very very very very very
very very very very very very very very
very very very very very very very very
long}
\end{figure}
\begin{figure}
\caption{Caption}
\end{figure}
\begin{figure}
\caption{Caption}
\end{figure}
\begin{figure}
\caption{Caption which is very
very very very very very very very very
very very very very very very very very
very very very very very very very very
long}
\end{figure}
\begin{figure}
\caption{Caption}
\end{figure}
\begin{figure}
\caption{Caption}
\end{figure}
\clearpage
\begin{figure}
\caption{Caption which is very
very very very very very very very very
very very very very very very very very
very very very very very very very very
long}
\end{figure}
\begin{figure}
\caption{Caption}
\end{figure}
\begin{figure}
\caption{Caption}
\end{figure}
\begin{figure}
\caption{Caption which is very
very very very very very very very very
very very very very very very very very
very very very very very very very very
long}
\end{figure}
\begin{figure}
\caption{Caption}
\end{figure}
\begin{figure}
\caption{Caption}
\end{figure}
\begin{figure}
\caption{Caption which is very
very very very very very very very very
very very very very very very very very
very very very very very very very very
long}
\end{figure}
\begin{figure}
\caption{Caption}
\end{figure}
\begin{figure}
\caption{Caption}
\end{figure}
\begin{figure}
\caption{Caption which is very
very very very very very very very very
very very very very very very very very
very very very very very very very very
long}
\end{figure}
\begin{figure}
\caption{Caption}
\end{figure}
\clearpage
\begin{figure}
\caption{Caption}
\end{figure}
\begin{figure}
\caption{Caption which is very
very very very very very very very very
very very very very very very very very
very very very very very very very very
long}
\end{figure}
\begin{figure}
\caption{Caption}
\end{figure}
\begin{figure}
\caption{Caption}
\end{figure}
\begin{figure}
\caption{Caption which is very
very very very very very very very very
very very very very very very very very
very very very very very very very very
long}
\end{figure}
\clearpage
\begin{figure}
\caption{Caption}
\end{figure}
\begin{figure}
\caption{Caption}
\end{figure}
\begin{figure}
\caption{Caption which is very
very very very very very very very very
very very very very very very very very
very very very very very very very very
long}
\end{figure}
\begin{figure}
\caption{Caption}
\end{figure}
\end{document}
编译后的示例也显示了分页符。这里我只显示了一小部分。
\xiao@figure
关于和 的一些评论\xiao@figurei
。
.lof
文件中第一个图的条目是
\contentsline {figure}{\numberline {1.1}{\ignorespaces Caption}}{1}
根据 的定义,被\contentsline{figure}
首先翻译成。然后,由于我们对 的重新定义,LaTeX 转换为,因此主输入变为\l@figure
\contentsline
\listoffigures
\l@figure
\xiao@figure
\xiao@figure{\numberline {1.1}{\ignorespaces Caption}}{1}
第一个论点\xiao@figure
是
\numberline {1.1}{\ignorespaces Caption}
第二个是1
(去掉参数周围的括号之后)。因此下一个替换是
\xiao@figurei\numberline {1.1}{\ignorespaces Caption}{1}
接下来查看的定义\xiao@figurei
:它后面必须跟着\numberline
(被删除)并且有三个参数
1.1
\ignorespaces Caption
1
现在可以完成主要部分的工作了,因为我们已经正确识别了三个表格单元格的内容。
宏hyperref
定义\contentsline
不同。遗憾的是,支持链接似乎相当困难。
为了获得成功的编译(没有链接),您可以执行以下操作:
\documentclass{book}
\let\latexcontentsline\contentsline
\usepackage{hyperref}
\makeatletter
\renewcommand\listoffigures{%
\chapter*{\listfigurename}%
\@mkboth{\MakeUppercase\listfigurename}%
{\MakeUppercase\listfigurename}%
\begingroup\let\addvspace\@gobble
\raggedbottom\offinterlineskip\def\l@figure{\xiao@figure}\parindent\z@
\let\contentsline\latexcontentsline
\hrule
\vrule\vrule width \z@ height 1.2\ht\strutbox depth 1.2\dp\strutbox
\makebox[\dimexpr3cm-0.8pt\relax][c]{\bfseries Number}\vrule
\parbox{\dimexpr\textwidth-6cm}{\normalbaselines\centering {\large\strut}\bfseries Caption{\large\strut}}\vrule
\makebox[\dimexpr3cm-0.8pt\relax][c]{\bfseries Page}\vrule
\hrule
\@starttoc{lof}%
\endgroup
}
\def\xiao@figure#1{\xiao@figurei#1}
\long\def\xiao@figurei\numberline#1#2#3#4{%
\vrule\vrule width \z@ height 1.2\ht\strutbox depth 1.2\dp\strutbox
\makebox[\dimexpr3cm-0.8pt\relax][c]{Fig.\ #1}\vrule
\parbox{\dimexpr\textwidth-6cm}{\normalbaselines\centering {\large\strut}#2{\large\strut}}\vrule
\makebox[\dimexpr3cm-0.8pt\relax][c]{#3}\vrule
\hrule
\hskip-.4pt
\hrule
\nobreak
}
\makeatother
答案2
我想提供另一种方法。因此,我利用了核心语言的优势expl3
。输出将使用创建longtable
。因此,您可以定义页眉,它允许分页。
首先我要感谢约瑟夫赖特的改进。
\documentclass{report}
\usepackage{array,longtable}
\usepackage{xparse}
\ExplSyntaxOn
\tl_new:N \g_listoffigures_storelines_tl
\DeclareDocumentCommand \mynumberline { m m }
{
\tl_set:Nn \l_tmpa_tl {Figure~#1}
\tl_set:Nn \l_tmpb_tl {#2}
}
\DeclareDocumentCommand \mylatfigure { m m }
{
#1
\tl_gput_right:Nx \g_listoffigures_storelines_tl
{
\exp_not:V \l_tmpa_tl \exp_not:N &
\exp_not:V \l_tmpb_tl \exp_not:N &
\exp_not:n { #2 \\ \hline }
}
}
\DeclareDocumentCommand \UseEntries {}
{
\tl_use:N \g_listoffigures_storelines_tl
}
\ExplSyntaxOff
\makeatletter
\newcolumntype{C}[1]{>{\centering\arraybackslash}p{\dimexpr #1 \relax}}
\renewcommand\listoffigures{%
\if@twocolumn
\@restonecoltrue\onecolumn
\else
\@restonecolfalse
\fi
\chapter*{\listfigurename}%
\@mkboth{\MakeUppercase\listfigurename}%
{\MakeUppercase\listfigurename}%
\begingroup
\let\l@figure\mylatfigure
\let\numberline\mynumberline
\let\addvspace\@gobble
\@starttoc{lof}%
\begin{longtable}{@{}|C{2.5cm}|C{\linewidth-5cm}|C{2.5cm-6\tabcolsep-4\arrayrulewidth}|@{}}\hline
\textbf{Number} & \textbf{Caption} & \textbf{Page} \\\hline\endhead
\UseEntries
\end{longtable}%
\endgroup
\if@restonecol\twocolumn\fi
}
\makeatother
\begin{document}
\listoffigures
\listoftables
\chapter{foo}
Text
\begin{figure}[!ht]
\caption{caption}
\end{figure}
\begin{table}[!ht]
\caption{caption}
\end{table}
\clearpage
\addtocounter{page}{24}
\chapter{foo}
Text
\begin{figure}[!ht]
\caption{The logo of \TeX}
\end{figure}
\clearpage
\chapter{foo}
Text
\begin{figure}[!ht]
\caption{Some figures of \LaTeX}
\end{figure}
\end{document}
当然,你可以将该expl3
部分与重新定义结合起来\listoftables
,但是我不想expl3
与 LaTeX2e-macros 混合。