2

I am trying to adjust exact height of the row in my table, but the output is not good:

\documentclass[a4paper]{article}

\usepackage{array}
\usepackage{color, colortbl}

\definecolor{mColor1}{rgb}{0.9,0.9,0.9}
\newcolumntype{O}{>{\columncolor{mColor1}}}
\newcolumntype{D}[1]{>{\raggedright\arraybackslash}m{#1}}
\newcolumntype{E}[1]{>{\centering\arraybackslash}m{#1}}

\begin{document}

\begin{table}[h]
\scriptsize
\caption{Summary}
\centering
\begin{tabular}{| OD{2.2cm} | E{1.1cm} | E{3cm} | E{3cm} | @{}m{0pt}@{} | }
\hline
\rowcolor{mColor1}
Author(s) & App. & Algorithm / Technique & Camera Type & \\  [0.6cm]
\hline
Author(s) & App. & Algorithm / Technique & Camera Type & \\ [0.6cm]
\hline
Author(s) & App. & Algorithm / Technique & Camera Type & \\ [0.6cm]
\hline
\end{tabular}
\end{table}

\end{document} 

The output table is like this which has some issues at the right side of the table including overlap of the color and also one extra vertical line:

enter image description here

How can I solve the issues? Thanks

4

You have to use

@{}>{\columncolor{white}[0pt][0pt]}m{0pt}@{}

instead of

@{}m{0pt}@{} |

so the hidden column is not considered when coloring the row.

MWE

\documentclass[a4paper]{article}

\usepackage{array}
\usepackage{color, colortbl}

\definecolor{mColor1}{rgb}{0.9,0.9,0.9}
\newcolumntype{O}{>{\columncolor{mColor1}}}
\newcolumntype{D}[1]{>{\raggedright\arraybackslash}m{#1}}
\newcolumntype{E}[1]{>{\centering\arraybackslash}m{#1}}
\newcolumntype{N}{@{}>{\columncolor{white}[0pt][0pt]}m{0pt}@{}}

\begin{document}

\begin{table}[h]
\scriptsize
\caption{Summary}
\centering
\begin{tabular}{| OD{2.2cm} | E{1.1cm} | E{3cm} | E{3cm} | N }
\hline
\rowcolor{mColor1}
Author(s) & App. & Algorithm / Technique & Camera Type &\\[0.6cm]
\hline
Author(s) & App. & Algorithm / Technique & Camera Type &\\[0.6cm]
\hline
Author(s) & App. & Algorithm / Technique & Camera Type &\\[0.6cm]
\hline
\end{tabular}
\end{table}

\end{document} 

Output

enter image description here

  • Perfect, thank you. could you please also show me how I can define a new command for @{}>{\columncolor{white}[0pt][0pt]}m{0pt}@{} so that I don't need to include it all long in the table? – NESHOM Jan 17 '15 at 16:33
  • @NESHOM Of course. See the edited answer. I've called it N. – karlkoeller Jan 17 '15 at 16:37
2

You can control the height of cells in columns of a type prefixed with the letter S, if you use the cellspace package. You don't have to use an empty column either, but should load the caption package to have a correct vertical spacing between caption and table:

\documentclass[a4paper]{article}

\usepackage{array}
\usepackage{color, colortbl}
\usepackage{caption}
\captionsetup{font = footnotesize}
\definecolor{mColor1}{rgb}{0.9,0.9,0.9}
\newcolumntype{O}{>{\columncolor{mColor1}}}
\newcolumntype{D}[1]{>{\raggedright\arraybackslash}m{#1}}
\newcolumntype{E}[1]{>{\centering\arraybackslash}m{#1}}
\usepackage{cellspace}
\setlength\cellspacetoplimit{8pt}
\setlength\cellspacebottomlimit{8pt}

\begin{document}

\begin{table}[h]
\scriptsize
\caption{Summary}
\centering
\begin{tabular}{| OD{2.2cm} | E{1.1cm} | S{E{3cm}} | E{3cm} | }
\hline
\rowcolor{mColor1}
Author(s) & App. & Algorithm / Technique & Camera Type \tabularnewline
\hline
Author(s) & App. & Algorithm / Technique & Camera Type \\
\hline
Author(s) & App. & Algorithm / Technique & Camera Type \\
\hline
\end{tabular}
\end{table}

\end{document} 

enter image description here

  • Thank you for your answer. It, I think, can not adjust height of the rows individually. Also it is more complicated and need more package compared to karlkoeller's answer. So if you don't mind I am going to mark his as the answer. Thank you very much again, I appreciate it. – NESHOM Jan 17 '15 at 16:31
  • 1
    Actually the difference with karlkoeller's answer is loading cellspace instead of array (which is useful for a lot of other things). It adjusts row heights individually in this very sense; it ensures a minimal vertical white space at the top and the bottom of cells; the rest of the cell has its natural height. On another hand, the caption package should be used even with his solution: basic latex forgets to swap the values of \abovecaptionskip and \belowcaptionskip when the caption is put above the table. – Bernard Jan 17 '15 at 17:49

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.