在没有浮动(表格)的 LaTex 中添加标题?

发布于 2024-09-18 21:51:12 字数 283 浏览 1 评论 0原文

我有一些表不够长,无法保证使用 \longtable,但它们总是从下一页开始,这会破坏整个流程并尝试使用 [!h] 来强制它桌子没有帮助。所以我停止使用 \tables ,现在只有 \tabular 标签,这似乎已经修复了布局,因为没有浮动。

但现在的问题是我无法获得表格的自动标题 - 有什么想法可以做到这一点并获得自动编号,以便当我使用 \addcontentsline 时它可以显示在目录中吗?

I have a few tables which are not long enough to warrant the use of \longtable, but they always start on the next page which breaks the whole flow and trying to force it with a [!h] in the table did not help. So I stopped using \tables and just have \tabular tag now which seems to have fixed the layout as there are no floats.

But the problem now is I can't get automatic captions for the Tables - any ideas how I can do this and also get auto numbering so when I use \addcontentsline it can show up in the TOC?

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

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

发布评论

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

评论(2

薔薇婲 2024-09-25 21:51:12

要在浮动环境之外使用标题,需要使用 \captionof,它是包 的一部分标题

示例

\documentclass{article}
\usepackage{caption}

\begin{document}                                                                                         
\begin{center}
  \begin{tabular}{rl}
    right & left \\
    right & left \\
  \end{tabular}
  \captionof{table}{Your caption here}
\end{center}
\end{document}

还有一个 capt -of 包,如果您只是对使用命令 \captionof 感兴趣。

To use a caption outside a float environment, one needs to use \captionof which is part of package caption.

Example

\documentclass{article}
\usepackage{caption}

\begin{document}                                                                                         
\begin{center}
  \begin{tabular}{rl}
    right & left \\
    right & left \\
  \end{tabular}
  \captionof{table}{Your caption here}
\end{center}
\end{document}

There is also a capt-of package if you are just interested in using the command \captionof.

说不完的你爱 2024-09-25 21:51:12

简短回答;您需要一个 \table 作为标题。仅使用 \tabular + 标题是行不通的。

长一点

可能会有令人讨厌的解决方法,因为人们倾向于为所有事情创建解决方法,但是我对大多数解决方法的基本规则是:“如果Latex 本身不提供它,请勿尝试这样做”。大多数时候,这些“修复”无论如何都会带来更多的文本流问题。

现在,如果您确实希望它位于文本下方,只需在表格之前执行 \clearpage 并放置表格即可。比正文的其余部分。这可能会解决这个问题,尽管它当然会在“上一页”的其余部分留下一个空白空间。

Short answer; you need a \table for the caption. Only using \tabular + captioning is not gonna work.

bit longer

There may be a nasty work-around as people tend to create work-arounds for everything, but my base rule for most of those work-arounds is: "if latex does not provide it by itself, do not try to do it". Most of time those "fixes" will give even more text-flow problems anyway.

Now if you really want it right below the text just do a \clearpage before the table and place the table. Than the rest of the text. This will probably solve it, although it will give an empty space on the rest of your 'previous' page of course.

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