Latex Table Syntax

时间:2015-10-13 15:22:23

标签: latex

\begin{center}
\begin{table}[h!]
\centering
\begin{tabular}{|l|l|l|l|}

  \hline
Name of the Dataset File & Number of Cases & Number of Records & Primary Key \\
\hline
Detail Interaction & 147,004 & 2400 & Interaction ID \\
\hline
 Detail Incident &    \\
\hline
Detail Change &  \\
\hline
Detail Activity &    \\
\hline
\end{tabular}
\caption{Dataset description of the four datasets provided by Rabobank Group ICT.}
\end{table}
\end{center}

该表格不适合该页面。有人可以帮助我在页面中制作它。该表有4列5行。

2 个答案:

答案 0 :(得分:1)

我建议使用booktabs以更优雅的方式编写表格,因为标题似乎有一些多余的信息:

enter image description here

\documentclass{article}

\usepackage{booktabs,siunitx}

\begin{document}

\noindent
\begin{tabular}{ l r r l }
  \toprule
  Dataset Filename & \multicolumn{1}{c}{Cases} & \multicolumn{1}{c}{Records} & Primary Key \\
  \midrule
  Detail Interaction & \num{147004} & \num{2400} & InteractionID \\
  Detail Incident & \num{12345} & \num{20000} & IncidentID \\
  Detail Change & \num{12} & \num{412} & ChangeID \\
  Detail Activity & \num{7890} & \num{1234567} & ActivityID \\
  \bottomrule
\end{tabular}

\end{document}

答案 1 :(得分:0)

首先,您的代码在第11,13和15行中缺少一些&:尝试

\begin{table}[h!]
        \centering
        \begin{tabular}{|l|l|l|l|}
            \hline
            Name of the Dataset File & Number of Cases & Number of Records & Primary Key \\
            \hline
            Detail Interaction & 147,004 & 2400 & Interaction ID \\
            \hline
            Detail Incident & & &  \\% 2 occurrences of & added here
            \hline
            Detail Change & & & \\% 2 occurrences of & added here
            \hline
            Detail Activity & & &  \\% 2 occurrences of & added here
            \hline
        \end{tabular}
        \caption{Dataset description of the four datasets provided by Rabobank Group ICT.}
    \end{table}

在第二个例子中,我建议你看看你是否喜欢

之类的东西
\begin{tabular}{|p{.3\textwidth}|p{.2\textwidth}|p{.2\textwidth}|p{.2\textwidth}|}

而不仅仅是

\begin{tabular}{|l|l|l|l|}

在这种情况下,您可以使用\par在单元格内部获取换行符(例如:Name of the\par Dataset File)。