Graphics, Figures & TablesTable Lines Spacing and Column Lines

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
workerbee
Posts: 43
Joined: Sat Nov 22, 2008 1:53 am

Table Lines Spacing and Column Lines

Post by workerbee »

Hi Community!

I've searched the forum for any answers to this but haven't found one. Is there a way to add additional space in specific rows without interrupting column lines?

For instance, the attached images that show what I would like (the first attachment using a table in Word with additional space before and after the horizontal lines with continuous column lines) and what I keep getting (the second attachment).

Coding-wise, I'm using this (with booktabs package):

Code: Select all

\begin{tabular}[t]{ l c | c c | c c }
\toprule
& & Not & & & Odds \\
& n & dependent & Dependent & Prop & (Prop$/$(1-Prop)) \\
\midrule
Female & 4573 & 4317 & 256 & 0.056 & 0.059 \\
Male & 4603 & 3904 & 699 & 0.152 & 0.179 \\
\midrule
Total & 9176 & 8221 & 955 \\
\bottomrule
\end{tabular}
Attachments
What I want.
What I want.
table-desired.png (41.98 KiB) Viewed 3464 times
What i got until now.
What i got until now.
table-result.png (53.87 KiB) Viewed 3464 times

Recommended reading 2024:

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

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

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Table Lines Spacing and Column Lines

Post by localghost »

The booktabs package aims to typeset good looking tables without any vertical lines. So it is not the right tool here. Try the quite new tabu package. It offers mechanisms to get the desired result.

Code: Select all

\documentclass[11pt,a4paper]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{tabu,multirow}

\setlength{\extrarowsep}{2pt}

\begin{document}
  \begin{tabu}{lc|cc|cc}\hline
    & \multirow{2}{*}[3pt]{n} & Not & \multirow{2}{*}[3pt]{Dependent} & \multirow{2}{*}[3pt]{Prop} & Odds \\[-6pt]
    & & dependent & & & (Prop$/$(1-Prop)) \\ \hline
    Female & 4573 & 4317 & 256 & 0.056 & 0.059 \\
    Male   & 4603 & 3904 & 699 & 0.152 & 0.179 \\ \hline
    Total  & 9176 & 8221 & 955 \\ \hline
  \end{tabu}
\end{document}
The multirow package helps to align some single row entries with respect to multiple row entries.


Thorsten
Post Reply