I am new to Latex and need help drawing tables. Here is what I have right now:
and here is the code for it:
\begin{center}
\begin{tabular}{|c|c|c|c|}
\hline
Topology & Average Delay(s) & Average Bandwidth(kbps) & Hosts \\
\hline
Low & 0.0994 & 2441.85 & \multirow{2}{*}{64} \\
High & 0.1424 & 2515.77 \\
\hline
Low & 0.2522 & 1798.60 & \multirow{2}{*}{128} \\
High & 0.1113 & 2123.17 \\
\hline
\caption{This table shows}
\label{eval_table}
\end{tabular}
\end{center}
Here is is what I want to do:
1) Shrink the table width so that it matches the column width
2) Fix the last vertical line
3) Set up the caption properly
I have spent hours on this and I don't know how to fix it.
Best Answer
I'm afraid that because you've provided only a code snippet rather than a full MWE (minimum working example), some vital information -- the width of the text block of your document -- is not available. I've thus had to make some (possibly incorrect) assumptions: A4 paper size, 1-inch margins, two-column mode.
Below is a succession of tables that address various issues you raise. I've deliberately not centered the tables to make it easier to compare the widths of the tables. (In a real document, you should of course encase each
tabular
environment inside\begin{table} \caption{...} \label{...} \centering
[tabular stuff]\end{table}
statements.) First, there's a horizontal rule indicating the width of the text block. In the first table, the missing vertical lines are restored by adding a couple of&
symbols. Obviously, the table is (much) too wide and won't fit in the available space.In the second table, the widths of columns 2 and 3 are reduced significantly by moving the unit designations to separate lines. (This should also help reduce any confusion over whether the
(s)
afterDelay
is a unit designation or the plural-s to Delay.) In the third table, the width is reduced further, succeeding in making the table fit in the text block. Importantly, all vertical lines are eliminated, allowing some more (horizontal) space saving; in addition, the look of the horizontal lines and the spacing above and below the horizontal lines is improved by replacing the basic LaTeX\hline
macro with\toprule
,\midrule
, and\bottomrule
macros.