[Tex/LaTex] How to put white line separator for cell/column

tables

How can I separate columns and cells with white lines. I googled and found we can put \hline and | in table definition but that produces black line.

 \documentclass{article}
 \usepackage{array,multirow}
 \begin{document}
 \begin{tabular}{|c|cc|}\hline
 \multirow{4}{*}{Foo} & 1 & 2 \\
   & 1 & 2 \\\cline{2-3}
   & 1 & 2 \\
   & 1 & 2 \\\hline
  \multirow{4}{*}{Bar} & 1 & 2 \\
     & 1 & 2 \\\cline{2-3}
     & 1 & 2 \\
     & 1 & 2 \\\hline
   \end{tabular}
\end{document}

How can I change them to white line?

Best Answer

Use colortbl. I have used blue just to demonstrate as here background is white. You may change blue to white (\arrayrulecolor{white}) in your actual case.

 \documentclass{article}
 \usepackage{array,multirow,colortbl}
 \begin{document}
 \arrayrulecolor{blue}         %% change blue to white in your case
 \begin{tabular}{|c|cc|}\hline
 \multirow{4}{*}{Foo} & 1 & 2 \\
   & 1 & 2 \\\cline{2-3}
   & 1 & 2 \\
   & 1 & 2 \\\hline
  \multirow{4}{*}{Bar} & 1 & 2 \\
     & 1 & 2 \\\cline{2-3}
     & 1 & 2 \\
     & 1 & 2 \\\hline
   \end{tabular}
\end{document}

enter image description here

For details Refer to documentation of colortble page 5 and 6 sections 7 and 8. To get documentation run texdoc colortbl from command prompt or visit texdoc.net

Another option is to use xcolor package with [table] option:

\documentclass{article}
 \usepackage{array,multirow}
 \usepackage[table]{xcolor}
 \begin{document}
 \pagecolor{blue!40} %% just to demonstrate - remove in your file
 \arrayrulecolor{white}
 \begin{tabular}{|c|cc|}\hline
 \multirow{4}{*}{Foo} & 1 & 2 \\
   & 1 & 2 \\\cline{2-3}
   & 1 & 2 \\
   & 1 & 2 \\\hline
  \multirow{4}{*}{Bar} & 1 & 2 \\
     & 1 & 2 \\\cline{2-3}
     & 1 & 2 \\
     & 1 & 2 \\\hline
   \end{tabular}
\end{document}

enter image description here

Edit:

It works for long tables also:

\documentclass{article}
 \usepackage{array,multirow,longtable}
 % \usepackage{colortbl}
 \usepackage[table]{xcolor}
 \usepackage[textheight=10cm]{geometry} %% onlly for testing
 \begin{document}
 \pagecolor{blue} %% just to demonstrate - remove in your file
 \arrayrulecolor{white}
 \begin{tabular}{|c|cc|}\hline
 \multirow{4}{*}{Foo} & 1 & 2 \\
   & 1 & 2 \\\cline{2-3}
   & 1 & 2 \\
   & 1 & 2 \\\hline
  \multirow{4}{*}{Bar} & 1 & 2 \\
     & 1 & 2 \\\cline{2-3}
     & 1 & 2 \\
     & 1 & 2 \\\hline
   \end{tabular}
   
  
\begin{longtable}{|>{\bf\centering\arraybackslash}p{1in}| p{2in}|}
\hline
\large{Name} & \large{\textbf{Definition}}\\ \hline
\endfirsthead
\hline
\large{Name} & \large{\textbf{Definition}}\\ \hline
\endhead
\hline
\multicolumn{2}{r}{continued \ldots}
\endfoot
\hline
\endlastfoot

  Newton's first law & An object will \\ \hline
  Newton's second law & The net force \\\hline
  Newton's third law & When two bodies \\ \hline
  Linear momentum & The product of an object's \\ \hline
  Net force on a body & Is said to be equal \\ \hline
  Impulse of a force & The product of \\\hline
  Principle of conservation of momentum & In a closed system, \\
    \hline
  Perfectly elastic collision & A collision is \\ \hline
  Inelastic collision & A collision is \\ \hline
  Radian & $\pi$ radians = $180^\circ$\\ \hline
  Gravitational field strength & The gravitational force
    \\\hline
  Newton's law of gravitation & Any two point masses\\\hline
\end{longtable}
\end{document}

enter image description here

Edit:

For a query in the comment below:

You may use some thing like

\newcolumntype{M}[1]{>{\centering\arraybackslash}p{#1}} %% this needs array package
\begin{longtable}{|M{1.4cm}|M{1cm}|M{1cm}|M{3.7cm}|M{1.8cm}|M{1.8cm}|}