0

I am using longtable package as most of the tables that I use tend to go on for multiple pages. What I want is now that the header row should be filled with blue colour and white text. The remainder rows should be black text with background fill changing between dark gray and white. This is the code I have but the output as you can see is not desirable.

     \documentclass[portrait]{report}
\usepackage{longtable}
\usepackage{colortbl}
\usepackage[dvipsnames,table]{xcolor}
\definecolor{light-gray}{HTML}{E5E4E2}
\definecolor{light-cyan}{HTML}{E0FFFF}
\definecolor{vblue_new}{rgb}{0.433, 0.601, 0.750}  

\begin{document}
\begingroup
\small
\renewcommand{\arraystretch}{2}
\setlength{\arrayrulewidth}{1pt}
\rowcolors{1}{light-cyan}{light-gray}
\begin{longtable}{|p{\dimexpr0.3\textwidth-2\tabcolsep}|p{\dimexpr0.5\textwidth-2\tabcolsep}|p{\dimexpr0.2\textwidth-2\tabcolsep}|}
\hline\rowcolor{vblue_new}
\textcolor{white}{Lorem&Ipsum &Number}
\endhead  \hline  \endfoot

Lorem&Ipsum&86\\
Lorem&Ipsum&86\\
Lorem&Ipsum&86\\
Lorem&Ipsum&86\\
Lorem&Ipsum&86\\
Lorem&Ipsum&86\\
Lorem&Ipsum&86\\
Lorem&Ipsum&86\\


\end{longtable}\endgroup

\end{document}

Output of above code

enter image description here

  • 1
    Use \textcolor{white}{Lorem} & \textcolor{white}{Ipsum} & \textcolor{white}{Number} instead of \textcolor{white}{Lorem & Ipsum & Number} which causes an error (! Missing } inserted. <inserted text> }). For an alternative see here: How to color the font of a single row in a table? – leandriis Feb 14 '19 at 16:28
  • 2
    The output of your document is ! Missing } inserted. after a tex error it is usually best not even to look at the pdf, and if asking a question about the error, show the error message not the pdf. TeX makes no attempt to make sensible output after an error it just recovers enough to try to syntax check the rest of the document – David Carlisle Feb 14 '19 at 20:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.