3

After a long fight against \multicolumn and \rowcolor, I am facing a strange glitch with \multicolumn on my yet very simple array. Could somebody help me ?

\taburowcolors[2]{white .. black!10}
\sffamily\footnotesize
\tabulinesep=6pt

\begin{longtabu}{|>{\cellcolor{gray}\color{white}}r|>{\cellcolor{gray}\color{white}}r|X[cm]|X[cm]|X[cm]|X[cm]|}
    \hline
    \multicolumn{2}{|>{ \columncolor{gray}}c|}{\strut} & \cellcolor{gray}\color{white}A & \cellcolor{gray}\color{white}B & \cellcolor{gray}\color{white}C & \cellcolor{gray}\cellcolor{gray}\color{white}D\\
    \hline
    % Content Start
    \multirow{2}{*}{CTRL} & LB         & Oui        &            &            & Non \\
                          & HA         & Non        & Oui        & Oui        &  \\
    % Content End
    \hline
\end{longtabu} 

Generated PDF

Thanks !

1

The content in the multi row is put first and the first cell in the second row is painted later. This results in the lower part of the content (that is put over this first cell) going below. To avoid this, delay putting the contents. This is done by adding \multirow{-2}{*}{CTRL} in the second row. Notw the -2 which asks multirow to span backwards.

\documentclass{article}
\usepackage{tabu}
\usepackage{longtable}
\usepackage{multirow}
\usepackage[table]{xcolor}

\begin{document}
  \taburowcolors[2]{white .. black!10}
\sffamily\footnotesize
\tabulinesep=6pt

\begin{longtabu}{|>{\cellcolor{gray}\color{white}}r|>{\cellcolor{gray}\color{white}}r|X[cm]|X[cm]|X[cm]|X[cm]|}
    \hline
    \multicolumn{2}{|>{ \columncolor{gray}}c|}{\strut} & \cellcolor{gray}\color{white}A & \cellcolor{gray}\color{white}B & \cellcolor{gray}\color{white}C & \cellcolor{gray}\cellcolor{gray}\color{white}D\\
    \hline
    % Content Start
                      & LB         & Oui        &            &            & Non \\
     \multirow{-2}{*}{CTRL}     & HA         & Non        & Oui        & Oui        &  \\
    % Content End
    \hline
\end{longtabu}
\end{document}

enter image description here

  • Wow really ! Thanks <3 You are so pro. Have a nice day ! – Kodak Oct 12 '14 at 13:29

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.