【问题标题】:\table in \enumerate environment in latex乳胶中的 \enumerate 环境中的 \table
【发布时间】:2015-08-20 17:15:52
【问题描述】:

我想在 \enumerate 环境中插入一个 \table,我有这样的东西:

\begin{enumerate}
    \item Item 1.
    \item Item 2.
    \item \begin{table}[htbp]
        \textbf{\caption{Table1 Caption}}
        \centering  
        \begin{tabular}{c c}
        \hline\hline
        Value 1 & Value 2\\
        \hline
        r1c1 & r2c2\\
        r2c1 & r2c2\\
        r3c1 & r3c2\\           
        \hline
        \end{tabular}
        \label{table1}
        \end{table}

    \item \begin{table}[htbp]
        \textbf{\caption{Table 2 Caption}}
        \centering
        \begin{tabular}{ccc}
        \hline\hline
        Value 1 & Value 2 & Value 3\\
        \hline
        r1c1 & r1c2 & r1c3\\
        r2c1 & r2c2 & r2c3\\
        r3c1 & r3c2 & r3c3\\
        \end{tabular}
        \label{table2}
    \end{table}

    \item \ref{table1} and \ref{table2}
\end{enumerate}

但是当我编译乳胶文档时,\enumerate 数字不在桌子附近。此外,当我提到标签“table1”和“table2”时,它分别显示为 3 和 4(有关额外信息,这部分在 3.3 小节中,这是整个文档中仅有的两个表)。

如何将 \table 环境与 \enumerate 环境一起使用。我见过人们只使用 \tabular 和 \enumerate 但我想使用 \table 因为它给了我一个简单的选项来定义 \caption 和 \label。

关于表格标签,我假设它与小节编号有关,但我无法真正弄清楚。

我非常感谢有关此问题的任何帮助。

【问题讨论】:

    标签: latex enumerate


    【解决方案1】:

    table 环境是一个浮点数。它不打算包含在其他环境中。

    您可以像这样使用tabular 环境:

    \documentclass[a4paper, 11pt]{article}
    
    \begin{document}
    
    \begin{enumerate}
        \item Item 1.
        \item Item 2.
        \item  \begin{tabular}[t]{c c}
            Value 1 & Value 2\\
            \hline
            r1c1 & r2c2\\
            r2c1 & r2c2\\
            r3c1 & r3c2\\
            \hline
        \end{tabular}
    
    \item \begin{tabular}[t]{ccc}
            Value 1 & Value 2 & Value 3\\
            \hline
            r1c1 & r1c2 & r1c3\\
            r2c1 & r2c2 & r2c3\\
            r3c1 & r3c2 & r3c3\\
        \end{tabular}
    \end{enumerate}
    
    \end{document}
    

    输出将如下所示:

    请注意,如果您尝试将\hline 放在表格顶部,垂直对齐会看起来很奇怪。

    编辑 1:您几乎可以将\label 放在您喜欢的任何地方,但除非设置了变量,否则它不会将自己称为“表格”。您必须深入研究 LaTeX 的内部结构才能了解它是如何完成的。

    至少有两个包(capt-ofcaption)提供\captionof 命令以在figuretable 环境之外定义标题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-08-11
      • 1970-01-01
      • 2022-01-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多