并排放置乳胶表

时间:2018-12-17 17:04:13

标签: latex

乳胶中有两个并排的桌子,但是,我不能分别标记它们以供ref标签使用。有什么方法可以使用ref标签在我的文字中引用他们的名字吗?例如,我需要在表1 ...和表2 .....

中说

有何评论?

\begin{table}[ht]
\parbox{.45\linewidth}{
\centering
\begin{tabular}{|l|l|l|}
    \hline
        person id & seq id & feature vector$_1$  \\\hline
        1 & 1 & 1 \\
        1 & 2 & 1 \\ \hline
        1 & 1 & 1 \\ \hline
        1 & 1 & 1 \\ \hline

    \end{tabular}
\caption{HRV Dataset}
    }
\hfill
\parbox{.45\linewidth}{
\centering
\begin{tabular}{|l|l|l|l|}
\hline
person id & seq id & feature vector$_1$ & feature vector$_2$ \\\hline

1 & 1 &1 \\
1 & 2 & 1 \\ \hline
1 & 1 &1\\ \hline
1 & 1 & 1 \\ \hline
% \begin{tabular}{|l|l|l|l|}


% \end{tabular}
\end{tabular}
\caption{BAC Dataset}}
\end{table}

2 个答案:

答案 0 :(得分:1)

您可以在标题中包括标签,这将使您可以稍后在文档中分别\ref每个表。

\documentclass{article} 

\begin{document}

\begin{table}[ht]
    \parbox{.40\linewidth}{
        \centering
        \begin{tabular}{|l|l|l|}
            \hline
            person id & seq id & feature vector$_1$  \\\hline
            1 & 1 & 1 \\
            1 & 2 & 1 \\ \hline
            1 & 1 & 1 \\ \hline
            1 & 1 & 1 \\ \hline

        \end{tabular}
        \caption{HRV Dataset \label{HRVtable}}
    }
    \hfill
    \parbox{.45\linewidth}{
        \centering
        \begin{tabular}{|l|l|l|l|}
            \hline
            person id & seq id & feature vector$_1$ & feature vector$_2$ \\\hline

            1 & 1 &1 &1  \\
            1 & 2 & 1&1 \\ \hline
            1 & 1 &1 &1\\ \hline
            1 & 1 & 1 &1 \\ \hline
        \end{tabular}
        \caption{BAC Dataset \label{BACtable}}}
\end{table}

HRV data in Table \ref{HRVtable} and BAC data in Table \ref{BACtable}.

\end{document}

enter image description here

答案 1 :(得分:1)

在相同结构中的\label内或之后添加\caption应该没有问题(例如\parboxminipage-见下文) 。我还添加了一些booktabs比萨...

enter image description here

\documentclass{article}

\usepackage{booktabs,makecell}

\begin{document}

\begin{table}
  \begin{minipage}{.5\linewidth}
    \centering
    \begin{tabular}{ *{3}{c} }
      \toprule
      \makecell{person \\ id} & \makecell{seq \\ id} & \makecell{feature \\ vector$_1$} \\
      \midrule
      1 & 1 & 1 \\
      1 & 2 & 1 \\
      1 & 1 & 1 \\
      1 & 1 & 1 \\
      \bottomrule
    \end{tabular}
    \caption{HRV Dataset}\label{tab:first}
  \end{minipage}%
  \begin{minipage}{.5\linewidth}
    \centering
    \begin{tabular}{ *{4}{c} }
      \toprule
      \makecell{person \\ id} & \makecell{seq \\ id} & \makecell{feature \\ vector$_1$} & \makecell{feature \\ vector$_2$} \\
      \midrule
      1 & 1 & 1 & 4 \\
      1 & 2 & 1 & 3 \\
      1 & 1 & 1 & 2 \\
      1 & 1 & 1 & 1 \\
      \bottomrule
    \end{tabular}
    \caption{BAC Dataset}\label{tab:second}
  \end{minipage}
\end{table}

See Table~\ref{tab:first} and Table~\ref{tab:second}\ldots

\end{document}