I've already found solutions here that work over \rowfont{} but not automatically adjust by even and odd number of lines.

I think about a case function it would work well for the first lines and then for the next. Unfortunately I don't understand the syntax and possibilities in LaTeX. Could someone please give me a solution for the problem

\usepackage{array}% http://ctan.org/pkg/array
\g@addto@macro{\endtabular}{\rowfont{}}% Clear row font
\newcommand{\rowfonttype}{}% Current row font
\newcommand{\rowfont}{% Set current row font


        \textbf{Hello}& \textbf{World} \\
        \textcolor{Black}{Foo} & \textcolor{Black}{Bar} \\ 
        Hello & World

I think you can achieve your needs easily with a TikZ matrix.

The options every odd row and every even row allow you to set a style for even and odd rows without complicated code.


   \matrix [
        matrix of nodes, 
        nodes in empty cells,
        column sep=-\pgflinewidth,% if you don't want a visible separation between columns
        column 1/.style={
            nodes={text width=3em},%put the width you prefer here
        column 2/.style={
            nodes={text width=4em},%put the width you prefer here
        every odd row/.style={
            nodes={fill=blue, text=white},
        every even row/.style={
        every node/.style={
            text height=1.75ex,
            text depth=.25ex,
        ] {
        Hello & World \\
        Foo & Bar \\ 
        Hello & World\\

enter image description here

  • TikZ allows us to do a lot of crazy things - thank you for share every odd/even row!! – manooooh Jan 27 at 9:55

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.