Graphics, Figures & TablesInaccurate vertical Table Line

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
TesTT
Posts: 12
Joined: Wed Aug 15, 2012 6:52 pm

Inaccurate vertical Table Line

Post by TesTT »

Hey,

I have the following code

Code: Select all

\documentclass[11pt]{article}
\usepackage[T1]{fontenc}

\begin{document}
  The quick brown fox jumps over the lazy dog.

  \begin{tabular}{
    >{\centering\arraybackslash}p{1.2cm}
    >{\centering\arraybackslash}p{1.4cm}|
    >{\centering\arraybackslash}p{2.0cm}
    >{\centering\arraybackslash}p{2.0cm}|
    >{\centering\arraybackslash}p{2.0cm}
    >{\centering\arraybackslash}p{2.0cm}
  }\hline
    & & \multicolumn{2}{c}{Time} & \multicolumn{2}{c}{Iterations} \\
    A & B & C1 & C2 & D1 & D2 \\ \hline
    1 & 45 & 0.051 & 0.075 & 4 & 18 \\
    2 & 300 & 0.052 & 0.099 & 7	& 47 \\
    3 & 530 & 0.063 & 0.131 & 7	& 73 \\
  \end{tabular}
\end{document}
The thing is that the 2nd vertical line doesnt cover the entire height of the table. In the first line there is a piece missing. What has happened? :(

I tried to use

Code: Select all

\multicolumn{2}{|c}{Iterations}
so that the entire height is covered, but it looks just a little bit crooked to me. :/

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

Stefan Kottwitz
Site Admin
Posts: 10340
Joined: Mon Mar 10, 2008 9:44 pm

Inaccurate vertical Table Line

Post by Stefan Kottwitz »

It's caused by the format change by \multicolumn. You can change it by adding a | in the \multicolumn argument too, similar to what you tried, but at the right of the Time cell:

Code: Select all

\multicolumn{2}{c|}{Time}
Tables with vertical lines are harder to read row by row. That's why good books often don't use vertical lines, but a few horizontal lines to structure a table, i.e. top line and bottom line, and separating a head row, possibly grouping related entries.

A quick design example from Creating tables in LaTeX:
table.png
table.png (37.4 KiB) Viewed 2799 times
Stefan
LaTeX.org admin
TesTT
Posts: 12
Joined: Wed Aug 15, 2012 6:52 pm

Inaccurate vertical Table Line

Post by TesTT »

As I said in my first post, if I do what you suggest then my table looks crooked (see attachment).

:/

Edit:
Oh, my bad, you were right, of course. it all looks terrific now. Thanks. :)
Attachments
tabular-vertical-line.jpg
tabular-vertical-line.jpg (8.94 KiB) Viewed 2716 times
Post Reply