1

I need space between rows and remove white lines between the columns. All the answers I found only referenced array stretch and \tabcolsep, which I use and like, however, these only change the cell-padding, not the spacing.

My Table

There are little white lines everywhere. I need to get rid of the ones between the columns and make them wider between the rows.

(Also since im already here. How can i vertically center the stuff in my cells? Seems row 1 is a little weird, while the others are vcentered?

\begin{table}[h]
\centering
\caption{My caption}
\vspace{10pt}
\label{my-label}

\def\arraystretch{2}
\setlength\tabcolsep{20pt}

\begin{tabular}{ L{5cm} c c }

 & \color{THIblue} {\bf something} 
 & \color{THIblue} {\bf anotherThing} \\

\rowcolor{THIlight}
Feature 1
 & \checkmark
 & \checkmark \\

\rowcolor{THIlight}
Feature 2
 & \checkmark
 & \checkmark \\

\rowcolor{THIlight}
Feature 3
 & \checkmark
 & \checkmark \\

\rowcolor{THIlight}
Feature 4
 &
 & \checkmark \\

\rowcolor{THIlight}
Feature 5
 & 
 & \checkmark \\

\rowcolor{THIlight}
Feature 6
 & 
 & \checkmark \\

\end{tabular}

\end{table}

EDIT: I defined my L Table column like this:

\newcolumntype{L}[1]{>{\raggedright\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}

Because I wanted a left-aligned cell that is a certain size. What do I need to add to make that vertically centered?

  • Not using \arraystretch in the first place: its action is asymmetric. And howis defned your THIlight colour? – Bernard Jun 21 '15 at 23:00
  • Welcome! Please give us code we can compile starting with \documentclass and ending with \end{document}. Much easier to help if you do that ;). And please don't use \bf in LaTeX documents where children might see it. It is long deprecated and acts strangely. Use \bfseries or \textbf{} which are somewhat better behaved! – cfr Jun 21 '15 at 23:31
2

enter image description here

Here is what I did:

  • To center the text vertically within the cell, I used the cellspace package as Bernard did because it is the simplest. You could use any other method like \newcolumntype or \raisebox (See this question for example), but this is easy and accurate
  • To make the horizontal lines thicker, I used \setlength\arrayrulewidth{1.5pt}, besides using \arrayrulecolor{white} to make it white instead of the default black
  • I picked the colors from the css code of the page and used it to color rows and text after defining the colors in HTML by \definecolor{THIblue}{HTML}{C3CFF4} or in RGB by \definecolor{THIblue}{RGB}{195,207,244}

Finally, here is the full code

\documentclass[12pt,a4paper]{article}
\usepackage{amssymb,array,cellspace}
\usepackage[table]{xcolor}
\setlength\cellspacetoplimit{10pt}
\setlength\cellspacebottomlimit{10pt}
\definecolor{THIblue}{HTML}{C3CFF4} %{RGB}{195,207,244}
\definecolor{blueHD}{HTML}{000B6C}  %{RGB}{0,11,108}

\newcolumntype{L}[1]{>{\raggedright\arraybackslash}p{#1}}
\arrayrulecolor{white}
\setlength\arrayrulewidth{1.5pt}

\begin{document}
\begin{table}[h] \sffamily
\centering
\caption{My caption}
\vspace{10pt}
\label{my-label}
\setlength\tabcolsep{20pt}
\rowcolors{2}{THIblue}{THIblue}
\begin{tabular}{L{5cm} Sc Sc}
   &\color{blueHD}\textbf{Something}&\color{blueHD}\textbf{Another thing}\\ 
   \textbf{Feature 1} & \checkmark & \checkmark \\ \hline
   \textbf{Feature 2} & \checkmark & \checkmark \\ \hline
   \textbf{Feature 3} & \checkmark & \checkmark \\ \hline 
   \textbf{Feature 4} &            & \checkmark \\ \hline
   \textbf{Feature 5} &            & \checkmark \\ \hline
   \textbf{Feature 6} &            & \checkmark \\ \hline
\end{tabular}
\end{table}
\end{document}

Edit:

Using a \newcolumntype would be more beneficial if the cell content is longer than one line. To achieve this, we define \newcolumntype{B}{>{\begin{minipage}{5cm}\raggedright\vspace{10pt}}c<{\vspace{10pt}\end{minipage}}} instead of cellspace. The values 5cm and 10pt should be adjusted as needed. Take care though not to leave a cell in the first column empty. Use \phantom{Word} to get the right calculation of cell height.

enter image description here

\documentclass[12pt,a4paper]{article}
\usepackage{amssymb,array}
\usepackage[table]{xcolor}
\definecolor{THIblue}{HTML}{C3CFF4} %{RGB}{195,207,244}
\definecolor{blueHD}{HTML}{000B6C}  %{RGB}{0,11,108}

\newcolumntype{B}{>{\begin{minipage}{5cm}\raggedright\vspace{10pt}}c<{\vspace{10pt}\end{minipage}}}
\arrayrulecolor{white}
\setlength\arrayrulewidth{1.5pt}

\begin{document}
\begin{table}[h]\sffamily
\centering
\caption{My caption}
\vspace{10pt}
\label{my-label}
\setlength\tabcolsep{20pt}
\rowcolors{2}{THIblue}{THIblue}
\begin{tabular}{Bcc}\hline
   \phantom{F}&\color{blueHD}\textbf{Something}&\color{blueHD}\textbf{Another thing}\\ \hline
   \textbf{Feature 1 Feature 1 Feature 1 Feature 1 Feature 1 Feature 1 Feature 1 Feature 1} 
    & \checkmark & \checkmark \\ \hline
   \textbf{Feature 2} & \checkmark & \checkmark \\ \hline
   \textbf{Feature 3} & \checkmark & \checkmark \\ \hline 
   \textbf{Feature 4} &            & \checkmark \\ \hline
   \textbf{Feature 5} &            & \checkmark \\ \hline
   \textbf{Feature 6} &            & \checkmark \\ \hline
\end{tabular}
\end{table}
\end{document}
  • Thank you very much! This does exactly want i intended to do with it. =) You are awesome! – JohnRW Jun 22 '15 at 5:48
  • Just noticed: When the cells are multicolumn (Longer than the 5cm) the bottom limit seems to be ignored. :-( Is there a way around that aswell? (Lets say: Instead of "Feature 1" we have "Feature 1 Feature 1 Feature 1 Feature 1 Feature 1 Feature 1 Feature 1 Feature 1 Feature 1 ") – JohnRW Jun 22 '15 at 6:13
  • @JohnRW Yes, there is a workaround. See my updated answer. – AboAmmar Jun 22 '15 at 11:56
3

Here is a solution: I used \columncolor rather than \rowcolor because I can specify a value for the optional parameter overhang, which enables to get rid of the thin vertical white line between columns.

Last, I replaced changing the value of \arraystretch with the cellspacepackage, which allows for vertical padding if rows, symmetrically at the top and the bottom of cells.

\documentclass{article}
\usepackage{amssymb, amsfonts}
\usepackage[x11names, table]{xcolor}
\usepackage{array, tabularx, caption, boldline}
\captionsetup{font=sf}
\usepackage{cellspace}
\setlength\cellspacetoplimit{6pt}
\setlength\cellspacebottomlimit{6pt}
\newcolumntype{L}[1]{>{\raggedright\arraybackslash}m{#1}}
\colorlet{THIlight}{LightSteelBlue3!60!}
\colorlet{THIblue}{SteelBlue4}
\usepackage{etoolbox}
\patchcmd{\hlineB}{\hrule}{\color{THIblue}\hrule}{}{}

\begin{document}

\begin{table}[h]
  \caption{My caption}\label{my-label}
  \sffamily\setlength\arrayrulewidth{0.8pt}\arrayrulecolor{THIblue}
  \setlength\tabcolsep{20pt}
  \begin{tabular}{>{\columncolor{THIlight}[20pt][21pt]}L{5cm}>{\columncolor{THIlight}[21pt]}Sc >{\columncolor{THIlight}[21pt][20pt]}Sc }
    & \color{THIblue} {\bfseries something}
    & \color{THIblue} {\bfseries anotherThing} \\
    \hlineB{2}
    Feature 1 & \checkmark & \checkmark \\\arrayrulecolor{white}
    \hline
    Feature 2 & \checkmark & \checkmark \\
    \hline
    Feature 3 & \checkmark & \checkmark \\
    \hline
    Feature 4 & & \checkmark \\
    \hline
    Feature 5 & & \checkmark \\
    \hline
    Feature 6 & & \checkmark \\
  \end{tabular}
\end{table}

\end{document} 

enter image description here

  • Hey Bernard. I selected Abo's answer as the right one since he added the whitespaces between the rows. Still you did a wonderful job! I wish i could select two answers as the right ones. :) Thank you very much for taking your time to help me out! – JohnRW Jun 22 '15 at 5:51
  • Oh! I understood (wrongly) you wanted to completely get rid of all lines. What's funny is it took me a certain time to find out how to do it. I'll correct my answer in a moment anyway. – Bernard Jun 22 '15 at 8:13
1

enter image description here

Above picture is generated width:

\documentclass[border=2mm]{standalone}
    \usepackage{mathtools,amssymb}
    \usepackage[dvipsnames,svgnames,table]{xcolor}
    \usepackage{array,booktabs}

\begin{document}
%    \centering
%    \def\arraystretch{2}
%    \setlength\tabcolsep{20pt}
\renewcommand{\arraystretch}{1.3}
\newcolumntype{L}[1]{>{\raggedright\let\newline\\%
                       \arraybackslash\hspace{0pt}}m{#1}}
\arrayrulecolor{white}
\begin{tabular}{ L{5cm} |>{$}c<{$}|>{$}c<{$} }
            & \color{cyan}\textbf{something}
            & \color{cyan}\textbf{anotherthing} \\ 
\rowcolor{cyan!50}
Feature 1   &   \checkmark
            &   \checkmark \\   \addlinespace[0.8pt]
\rowcolor{cyan!50}
Feature 2   &   \checkmark
            &   \checkmark \\   \addlinespace[0.8pt]

\rowcolor{cyan!50}
Feature 3   &   \checkmark
            &   \checkmark \\   \addlinespace[0.8pt]

\rowcolor{cyan!50}
Feature 4   &
            &   \checkmark \\   \addlinespace[0.8pt]
\rowcolor{cyan!50}
Feature 5   &
            &   \checkmark \\   \addlinespace[0.8pt]
\rowcolor{cyan!50}
Feature 6   &
            &   \checkmark \\
    \end{tabular}
\end{document}

Since you not provide minimal working example (MWE) I construct own, where I select predefined color. Horizontal lines I obtain with addlinespace[0.8pt], and vertical on standard way, however I define with \arrayrulecolor{white} that they are white. Is this what you like to have?

I do not bother with table environment and caption. For caption let use caption package. It will give appropriate spacing between caption and table.

  • Thank you very much and sorry i didn't provide a MWE, I thought you guys would just look at my code and say do x! I will be smarter next time. You code still has the lines between the columns, which i wanted to get out of the way. You said you got them the "standard" way. That default is whats bothering me. :) Still thank you very much for taking your time to answer – JohnRW Jun 22 '15 at 5:50
  • I understand opposite. For table without (vertical) lines you already have answers, so "case is solved" :-). – Zarko Jun 22 '15 at 7:27

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.