0

I am trying to color the rows in a document. The code I am using is as below

\documentclass[11pt,a4paper, twoside]{scrbook}

\usepackage{longtable,tabu}
\usepackage[table]{xcolor}
\definecolor{grey1}{gray}{0.6}
\definecolor{grey2}{gray}{0.9}

\begin{document}

\taburowcolors[2] 2 {grey2..grey2}
\begin{longtabu}[H]{XXl}
    \caption{Chemicals and Reagents}\\[2mm]
    \rowcolor{grey1}
    \textbf{Product} & \textbf{Manufacturer} & \textbf{Reference}\\
    Whatever & from whomever & 123456789\\
    Whatever & from whomever & 123456789\\
    Whatever & from whomever & 123456789\\
\end{longtabu}

\end{document}

When running this on overleaf everything is fine but using TeXstudio and MikTex2.9 with the latest updates doesn't perform the coloring of rows. Here is my log file. I'd greatly appreciate it if you could help.

  • 1
    tabu package is broken. don't use it if you don't have to – user188289 May 6 at 11:14
  • I see. Thank you – Al_Fh May 6 at 11:15
  • What can I use instead of tabu? – Al_Fh May 6 at 11:15
  • 1
    instead of tabu, I'd use a normal tabular – user188289 May 6 at 11:16
1

using tabularx instead of the broken tabu package:

\documentclass[11pt,a4paper, twoside]{scrbook}

\usepackage{longtable,tabu}
\usepackage[table]{xcolor}
\definecolor{grey1}{gray}{0.6}
\definecolor{grey2}{gray}{0.9}
\usepackage{tabularx}

\rowcolors{2}{red}{blue}

\begin{document}


\begin{table}[htbp]
    \caption{Chemicals and Reagents}
\begin{tabularx}{\linewidth}{XXl}
    \rowcolor{grey1}
    \textbf{Product} & \textbf{Manufacturer} & \textbf{Reference}\\
    Whatever & from whomever & 123456789\\
    Whatever & from whomever & 123456789\\
    Whatever & from whomever & 123456789\\
\end{tabularx}
\end{table}

\end{document}

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.