vtammy
vtammy

Reputation: 125

Latex Table Syntax

\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}

The table doesnt fit to the page. Can someone help me in making it in a page. The table has 4 columns and 5 rows.

Upvotes: 2

Views: 3500

Answers (2)

Werner
Werner

Reputation: 15065

I'd suggest writing the table in a more elegant way using booktabs, as there seems to be some superfluous information the headers:

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}

Upvotes: 1

MattAllegro
MattAllegro

Reputation: 7345

First of all, your code is missing some &s, in lines 11, 13 and 15: try

\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}

In a second instance, I advise you to see if you prefer something like

\begin{tabular}{|p{.3\textwidth}|p{.2\textwidth}|p{.2\textwidth}|p{.2\textwidth}|}

instead of just

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

In this case, you can use \par to get a linebreak inside a cell (for example: Name of the\par Dataset File).

Upvotes: 0

Related Questions