1

thank you all. All horizontal and vertical lines appear, but when you color a row or cell, the top horizontal line disappears. here are the code of this work:

\documentclass[a4paper,11pt,twoside]{book}
\usepackage{array,multirow}
\usepackage[table]{xcolor}
\setlength{\tabcolsep}{10pt}
\setlength{\extrarowheight}{2mm}
\setlength{\arrayrulewidth}{0.2mm}
\begin{document}

   
   
\begin{tabular}{|l|*{5}{c|}}
\hline \multirow{2}{*}{Name}& \multicolumn{4}{c|}{\cellcolor{black!10} Subjects}&
\multirow{2}{*}{Total}\\
\cline{2-5} &Math & Phy & Chem & English & \\
\hline
\rowcolor{red!50}[0.98\tabcolsep] Robin & 80 & 68 & 60 & 57 & 265\\
\hline Julie & 72 & 62 & 66 & 63 & 263\\
\hline Robert & 75 & 70 & 71 & 69 & 285\\
\hline
\end{tabular}
\end{document}

here is the image of The output pdf.

enter image description here

2 Answers 2

1

Your horizontal line disappear in some PDF readers (eg Adobe Reader) at some levels of zoom.

The package nicematrix has tools designed to avoid that problem.

\documentclass[a4paper,11pt,twoside]{book}
\usepackage{xcolor}
\usepackage{nicematrix}
\setlength{\tabcolsep}{10pt}
\setlength{\extrarowheight}{2mm}
\setlength{\arrayrulewidth}{0.2mm}
\begin{document}
   
\begin{NiceTabular}{l*{5}{c}}[color-inside,hvlines]
\Block{2-1}{Name}& \Block[fill=black!10]{1-4}{Subjects} &&&&
\Block{2-1}{Total}\\
&Math & Phy & Chem & English & \\
\rowcolor{red!50} Robin & 80 & 68 & 60 & 57 & 265\\
Julie & 72 & 62 & 66 & 63 & 263\\
Robert & 75 & 70 & 71 & 69 & 285\\
\end{NiceTabular}
\end{document}

You need several compilations (because nicematrix uses PGF/TikZ nodes under the hood.

Output of the above code

0

enter image description here

\documentclass[a4paper,11pt,twoside]{book}
\usepackage{array,multirow}
\usepackage[table]{xcolor}
\setlength{\tabcolsep}{10pt}
\setlength{\extrarowheight}{2mm}
\setlength{\arrayrulewidth}{0.2mm}

\begin{document}
\begin{tabular}{|l|*{5}{c|}}
\hline 
\multirow{2}{*}{Name} & \multicolumn{4}{c|}{\cellcolor{black!10} Subjects} & \multirow{2}{*}{Total} \\
\cline{2-5} 
& Math & Phy & Chem & English & \\
\hline
\rowcolor{red!50}[0.98\tabcolsep]
Robin & 80 & 68 & 60 & 57 & 265 \\
\hline
Julie & 72 & 62 & 66 & 63 & 263 \\
\hline
Robert & 75 & 70 & 71 & 69 & 285 \\
\hline
\end{tabular}
\end{document}

You must log in to answer this question.

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