1

I am writing LaTeX code to generate a long table using longtable package and I want the first column color to be gray

Here is my code:

\documentclass[a4paper,11pt,english]{report}

\usepackage{longtable}
 \usepackage{multirow}
 \usepackage{graphicx}
 \usepackage[table,xcdraw]{xcolor}
\usepackage{lipsum} % just for dummy text- not needed for a longtable

\begin{document}
\lipsum[1]
\lipsum[1]
\lipsum[1]

\definecolor{lightgray}{HTML}{EFEFEF}

\begin{longtable}[H]{|
>{\columncolor{lightgray}}p{0.2\linewidth} | p{0.175\linewidth} |}
\hline
foo & bar \\ \hline 
foo & bar \\ \hline
foo & bar \\ \hline
foo & bar \\ \hline
foo & bar \\ \hline
foo & bar \\ \hline
foo & bar \\ \hline
foo & bar \\ \hline
foo & bar \\ \hline
foo & bar \\ \hline
foo & bar \\ \hline
\caption{Your caption here} % needs to go inside longtable environment
\label{tab:myfirstlongtable}
\end{longtable} 

Table \ref{tab:myfirstlongtable} shows my first longtable.
\end{document}

The problem with the produced table is that horizontal lines doesn't appear in the colored area. Here is my output: enter image description here

Any help?

Nour
  • 147
  • 2

0 Answers0