3

I did some search on the topic without success. Most of the time people want to remove spaces, or have problems with last column, etc. In my case I want the spaces to be there and between columns.

I have manage to do so using a colored rule but that doesn't look good (the code I mean) and feels like kind of a workaround.

The main issue here is that my table will be printed and filled by hand, so the vertical separation must be clear and even/odd coloring is necessary to avoid confusion.

Edit: As stated by Zarko my question was not clear enough, so I'm rephrasing.

Is there a best/more elegant way of adding space between columns with alternating colored rows?

I've used rowcolors for alternating color (SpringGreen/gray) rows but other solutions might be suitable too. The space between rows isn't much important to me, as the coloring does define were each rows starts/ends.

enter image description here

\documentclass[landscape]{memoir}
\usepackage[table,dvipsnames]{xcolor}
\usepackage{booktabs}
\usepackage{multirow}
\newcolumntype{L}[1]{>{\raggedright\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\newcolumntype{C}[1]{>{\centering\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}

\begin{document}
\arrayrulecolor{white}
\setlength{\arrayrulewidth}{3pt}
\begin{table}[ht]
\rowcolors{3}{SpringGreen}{gray!20!white}
{\large 
\centering
\label{my-label}
\begin{tabular}{>{\kern-\tabcolsep}C{2cm}|L{2cm}|L{2cm}|L{2cm}|L{2cm}|L{2cm}|L{2cm}<{\kern-\tabcolsep}}
\arrayrulecolor{black} 
\toprule
Part &  \multicolumn{5}{c}{\multirow{2}{*}{Calibration date}} \\
Number & \multicolumn{5}{c}{}   \\
\midrule
 &  &  &  &  &  &  \\ 
 &  &  &  &  &  &  \\
 &  &  &  &  &  &  \\
 &  &  &  &  &  &  \\
 &  &  &  &  &  &  \\
 &  &  &  &  &  &  \\
 &  &  &  &  &  &  \\
  &  &  &  &  &  &  \\
  &  &  &  &  &  &  \\
  &  &  &  &  &  &  \\
  &  &  &  &  &  &  \\  
  &  &  &  &  &  &  \\
  &  &  &  &  &  &  \\
  &  &  &  &  &  &  \\
  &  &  &  &  &  &  \\ 
  &  &  &  &  &  &  \\
  &  &  &  &  &  &  \\
  &  &  &  &  &  &  \\
  &  &  &  &  &  &  \\
  &  &  &  &  &  &  \\  
  &  &  &  &  &  &  \\ 
\arrayrulecolor{black} 
\bottomrule
\end{tabular}
}
\end{table}
\end{document}
2

The easiest is probably to simply insert some space between the columns:

\documentclass[landscape]{memoir}
\usepackage[table,dvipsnames]{xcolor}
\usepackage{booktabs}
\usepackage{multirow}
\newcolumntype{L}[1]{>{\raggedright\let\newline\\\arraybackslash\hspace{0pt}}m{#1}!{\hspace{3pt}}}
\newcolumntype{C}[1]{>{\centering\let\newline\\\arraybackslash\hspace{0pt}}m{#1}!{\hspace{3pt}}}

\begin{document}
\begin{table}[ht]
\rowcolors[]{3}{SpringGreen}{gray!20!white}

\begin{tabular}{C{2cm}L{2cm}L{2cm}L{2cm}L{2cm}L{2cm}L{2cm}}
\toprule
Part &  \multicolumn{5}{c}{\multirow{2}{*}{Calibration date}} \\
Number & \multicolumn{5}{c}{}   \\
\midrule
adk\hfill blbl &  &  &  &  &  &  \\
 &  &  &  &  &  &  \\
 &  &  &  &  &  &  \\ 
\bottomrule
\end{tabular}

\end{table}
\end{document}

enter image description here

  • wow, that's really simple! However i'm struggling to remove that tiny extra space after the last column without defining a new columntype. – G. Bay Jul 18 '16 at 17:01
2

I guess that you like to obtain something like this:

enter image description here

To code is added makecell package for use of macro \thead{...} in column headings. Coloring of cells is moved to definition of new column type C, all rules has standard width and color. With this I estimate that code is more concise and simple:

\documentclass[landscape]{memoir}
\usepackage[table]{xcolor}
\usepackage{booktabs,makecell}
\renewcommand\theadfont{\bfseries\large}
\newcolumntype{C}{>{\color{white}\columncolor{gray!30}[.5\tabcolsep]%
                    \centering\arraybackslash}p{20mm}}
\newcommand\mc[2]{\multicolumn{#1}{c}{\thead{#2}}}

\begin{document}
\begin{table}[ht]
    \centering
    \begin{tabular}{@{$\;$} *{7}{C} @{\rule{0pt}{5ex}$\;$} }
    \toprule
\mc{1}{Part\\ Number} &  \mc{6}{Calibration date} \\
    \midrule
 &  &  &  &  &  &  \\   \addlinespace[8pt]% if you like bigger vertical space
 &  &  &  &  &  &  \\   \addlinespace
 &  &  &  &  &  &  \\   \addlinespace
 &  &  &  &  &  &  \\   \addlinespace
 &  &  &  &  &  &  \\   \addlinespace
 &  &  &  &  &  &  \\   \addlinespace
 &  &  &  &  &  &  \\
    \bottomrule
\end{tabular}
    \end{table}
\end{document}

Addendum: Instead two alternating rows' color see if increasing vertical space at each second second row. In this case the table looks as follows:

enter image description here

Code:

\documentclass[landscape]{memoir}
\usepackage[table]{xcolor}
\usepackage{booktabs,makecell}
\renewcommand\theadfont{\bfseries\large}
\newcolumntype{C}{>{\color{white}\columncolor{gray!30}[.5\tabcolsep]%
                    \centering\arraybackslash}p{20mm}}
\newcommand\mc[2]{\multicolumn{#1}{c}{\thead{#2}}}

\begin{document}
\begin{table}[ht]
    \centering
    \begin{tabular}{@{$\;$} C @{\qquad} *{6}{C} @{\rule{0pt}{5ex}$\;$} }
    \toprule
\mc{1}{Part\\ Number} &  \mc{6}{Calibration date} \\
    \midrule
 &  &  &  &  &  &  \\   \addlinespace
 &  &  &  &  &  &  \\   \addlinespace[12pt]
 &  &  &  &  &  &  \\   \addlinespace
 &  &  &  &  &  &  \\   \addlinespace[12pt]
 &  &  &  &  &  &  \\   \addlinespace
 &  &  &  &  &  &  \\   \addlinespace[12pt]
 &  &  &  &  &  &  \\   \addlinespace
 &  &  &  &  &  &  \\
    \bottomrule
\end{tabular}
    \end{table}
\end{document}
  • I actually need even/odd coloring, thats why I used rowcolorS and not rowcolor. Your approach is interesting. – G. Bay Jul 15 '16 at 15:06
  • This is not mentioned in your question. – Zarko Jul 15 '16 at 15:39
  • Edited. Even/odd coloring is necessary. – G. Bay Jul 16 '16 at 15:49
  • Well, than my answer is not of big help for you. Even your MWE haven't two color rows (white is not visible) ... as solution, you need to change rows' colors from white to something else. Considering my MWE maybe is solution to add midrule each second row or each second row increase vertical space between rows. – Zarko Jul 16 '16 at 16:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.