1

Im trying to have get a backgroundcolor at my tables consising of both multirows and multicoloums. Without any color, the table works fine. But what i want to color expands over variable amounts of rows. Ive triyng to color 4 rows with the same color, with 1 cell stretching over 4 rows and 1 cell stretching over 2 rows.

But if i do that the second coloring, applies the color on top of the multirow text. table wouthout color

table with text

As you can see, the 2nd line of rowcolor removes the upper part of 'Grade' from cell 1 and 3rd row color removed the lower part of 'Grade' and lower part of Thickness. Any solution ideas?

my tex:

\begin{table}[ht]
\begin{tabular}{|c|c|lll|}
\hline
\rowcolor{blue!20} 
\multirow{4}{*}{Grades}&Yield&\multicolumn{3}{c|}{Impact bending test}\\
\rowcolor{blue!20}
                      &Strength&\multirow{2}{*}{Thickness}&Test& Impact\\
\rowcolor{blue!20}
                             &$\mathbf{R_e[N/mm^2]}$&                                &{\bf temperature}     & {\bf work}\\
\rowcolor{blue!20}
                             &\bf{transv.min.}      &\bf{ transv.}                   &$\mathbf{[\grader]}$  & {\bf [J]} \\\hline
\multirow{ 1}{*}{{\bf DH36}}   &     & {\bf 5.5 – 7.0} & {\bf         -40} & {\bf       24} \\

\hline
\end{tabular}
\end{table}
  • the - in \multirow{-2}{*}{ } doesnt work for me.. it just moves the text outside the table – onmikkelsen Nov 14 '16 at 18:43
  • 1
    Please, extend your code sniped to complete document starting with \documentclass{...}, with necessary packages and your new commands definitions and ending with end{document}. In present state it is not possible to compile. Welcome to site! – Zarko Nov 14 '16 at 19:09
0

Based on guessing about your preamble and meaning of used commands:

enter image description here

\documentclass{article}
\usepackage{siunitx}
\usepackage{makecell,multirow}
\usepackage[table]{xcolor}

\begin{document}
    \begin{table}[htb]
\sisetup{detect-weight=true}
\renewcommand\arraystretch{1.3}
\begin{tabular}{|*{2}{>{\bfseries}c|}
                 *{3}{>{\bfseries}c}|}
    \hline
\rowcolor{blue!20}
                &   &   \multicolumn{3}{c|}{\textbf{Impact bending test}}    \\
\rowcolor{blue!20}
\multirow{-2}*{Grades}  
        &   \multirow{-3}*[-1ex]{\makecell{Yield\\  Strength\\ 
                                            {$\mathbf{R_e[\si{N\per\milli\meter^2}]}$} \\transv. min.}}
                    &   \makecell{Thickness\\  transv.}    
                        &   \makecell{Test\\ temperature\\ \si{\celsius}}
                            &   \makecell{Impact\\ work\\ \si{J} }          \\
    \hline
DH36   &       & 5.5 – 7.0 & -40   & 24    \\
    \hline
\end{tabular}
    \end{table}
\end{document}

Edit: macro makecell have options ˙bfor bottom position,tfor top position,lfor left aligned cell content andr` for right aligned. Use of it without options the cell content is vertically and horizontally centered.

If in above MWE replace the second row of table with

\multirow{-3}*{Grades}
        &   \multirow{-3}*[3pt]{\makecell{Yield\\  Strength\\
                                            {$\mathbf{R_e[\si{N\per\milli\meter^2}]}$} \\transv. min.}}
                    &   \makecell[b]{Thickness\\  transv.}
                        &   \makecell[b]{Test\\ temperature\\ \si{\celsius}}
                            &   \makecell[b]{Impact\\ work\\ \si{J} }          \\

than the table is as follows:

enter image description here

  • Probably, you should use [detect-weight=true]. – Bernard Nov 14 '16 at 20:30
  • @Bernard, yes, this is right key for siunitx, I consider this in edited answer – Zarko Nov 14 '16 at 20:38

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.