9

I found that useful command \addlinespace[3pt] to create an extra white border around the rows. See example:

\documentclass[a4paper]{report}

\usepackage{multirow,booktabs}
\usepackage[table]{xcolor}
\begin{document}

\begin{table}
\rowcolors{1}{gray!15}{gray!15}
\begin{tabular}{rrrrr}
\rowcolor{gray!50}
Header & 1     & 2     & 3     & 4 \\ \addlinespace[3pt]
Row1  & a     & b     & c     & d \\
\multicolumn{1}{c}{} & a1    & b1    & c1    & d1 \\ \addlinespace[3pt]
\multicolumn{1}{c}{\multirow{-2}[0]{*}{Multirow1}} & a2    & b2    & c2    & d2 \\
Row2  & aa    & ab    & ac    & ad \\ 
\end{tabular}
\end{table}

\end{document}

I also found commands like:

\setlength\extrarowheight{7pt}
\renewcommand\arraystretch{1.2}

here: vertical align and color in table with multirow

But these two commands seem to just expand the whole row rather than that white border thing. However, you call it ;)

As I have a lot of tables with loads of rows, my question is how to make the command \addlinespace[3pt] globally so that I do not have to add it at the end of each single row for all tables.

1
  • \renewcommand\arraystretch{1.2} increases the whitespace above and below the row. \setlength\extrarowheight{7pt} only above!
    – user2478
    Jan 8, 2013 at 13:18

2 Answers 2

5

I'm not so sure you want this additional space between all rows, particularly those where a \multirow is involved.

However, stating \global\everycr{\addlinespace[3pt]} in the first cell will do; remember to restore \everycr to its empty usual value at the end.

\documentclass[a4paper]{report}

\usepackage{multirow,booktabs}
\usepackage[table]{xcolor}
\begin{document}
\begin{table}
\rowcolors{1}{gray!15}{gray!15}
\begin{tabular}{rrrrr}
\rowcolor{gray!50}
\global\everycr{\addlinespace[3pt]}%
Header & 1     & 2     & 3     & 4 \\
Row1  & a     & b     & c     & d \\
\multicolumn{1}{c}{} & a1    & b1    & c1    & d1 \\\addlinespace[-3pt]
\multicolumn{1}{c}{\multirow{-2}[0]{*}{Multirow1}} & a2    & b2    & c2    & d2 \\
Row2  & aa    & ab    & ac    & ad \\
\end{tabular}
\global\everycr{}
\end{table}

\end{document}

Notice that I put a countermanding \addlinespace between the two rows sharing their label.

enter image description here

0

What you really want is global rowsep setting. So you may try tblr environment from the new LaTeX3 package tabularray:

\documentclass[a4paper]{report}

\usepackage{xcolor}
\usepackage{tabularray}
\SetTblrInner{rowsep=2pt}

\begin{document}

\begin{table}
\centering
\begin{tblr}{
  colspec = {r|[1pt,white]rrrr},
  cell{3}{1} = {r=2}{m}, % multirow
  rows = {gray9},
  hlines = {1pt,white},
}
  Header    & 1     & 2     & 3     & 4  \\
  Row1      & a     & b     & c     & d  \\
  Multirow1 & a1    & b1    & c1    & d1 \\
            & a2    & b2    & c2    & d2 \\
  Row2      & aa    & ab    & ac    & ad \\ 
\end{tblr}
\end{table}

\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .