Latex:使 \listoffigures 看起来像 \listoftables 或 \lstlistoflistings

发布于 2024-09-05 14:30:59 字数 144 浏览 3 评论 0原文

在我的文档末尾,我在表格列表和数字列表之后有一个列表。真正让我恼火的是,它们看起来相同,只是列表列表没有在章节之间留下行间隙。

我用谷歌搜索了一下,有人问了同样的问题,但似乎没有任何回应。

他们有什么理由让它们看起来不一样并且看起来很简洁吗?

I've got a list of listings at the end of my document following my list of tables and my list of figures. The thing that is really annoying me is that they look the same except the list of listings doesn't leave a line gap between chapters.

I've had a good google around and people have asked the same question but don't seem to have had any response.

Is their any reason why they don't look the same and it be made to look concise?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

避讳 2024-09-12 14:30:59

其原因是图列表(lof)和表列表(lot)中的章节之间的垂直间距是由 \chapter 命令添加的,而对于清单列表(笑)。

如何解决这个问题在一定程度上取决于您所使用的文档类。如果您使用优秀的 memoir 类,则已经提供了用于此目的的挂钩:

\renewcommand{\memchapinfo}[4]{%
  \addtocontents{lol}{\protect\addvspace{10pt}}}

如果您的列表出现在附录中,您将挂钩 \memappchapinfo 而不是 \memchapinfo。 (有关可用挂钩列表,请参阅回忆录手册第 18.25 节。)

如果您不使用 memoir,则通常需要挂钩您的班级的\@chapter 命令。例如,这可能看起来像:

\makeatletter
\let\my@chapter\@chapter
\renewcommand*{\@chapter}{%
  \addtocontents{lol}{\protect\addvspace{10pt}}%
  \my@chapter}
\makeatother

您可以通过检查与您的文档相对应的 .lol 文件来轻松检查用于生成 lol 的内容。例如,如果您的文档是 base.tex,请查看 base.lol。您应该看到类似以下内容:

\contentsline {lstlisting}{...}{...}
\contentsline {lstlisting}{...}{...}
\addvspace {10pt}
\contentsline {lstlisting}{...}{...}

注意 \addvspace 将内容行与不同章节分开。

由于用于在章节之间插入间距的实际代码也取决于文档类,因此请调整实际的 \addvspace 命令,使其与 .lof中的命令相同.lot 文件。

The reason for this is that the vertical spacing between chapters in the list of figures (lof) and list of tables (lot) is added by the \chapter command, and there simply is no such provision for the list of listings (lol).

How to fix this depends a bit on the document class you are using. If you are using the excellent memoir class, hooks for this purpose are already provided:

\renewcommand{\memchapinfo}[4]{%
  \addtocontents{lol}{\protect\addvspace{10pt}}}

If your listings are appearing in the appendices, you'll hook \memappchapinfo instead of \memchapinfo. (Consult section 18.25 of the memoir manual for a list of hooks available.)

If you're not using memoir, you'll typically need to hook your class' \@chapter command. This could look like, for example:

\makeatletter
\let\my@chapter\@chapter
\renewcommand*{\@chapter}{%
  \addtocontents{lol}{\protect\addvspace{10pt}}%
  \my@chapter}
\makeatother

You can easily check what is used for generating the lol by checking the .lol file corresponding to your document. If your document is, for example, base.tex, look into base.lol. You should see something like:

\contentsline {lstlisting}{...}{...}
\contentsline {lstlisting}{...}{...}
\addvspace {10pt}
\contentsline {lstlisting}{...}{...}

Note the \addvspace separating the content lines from different chapters.

As the actual code used to insert spacing between chapters also depends on the document class, adapt the actual \addvspace command to be the same as in your .lof or .lot files.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文