Search code examples
latexmultirow

Latex \multirow : giving multirow an inverted argument shifts text


I want to color a \multirow text but it overwrites the text at the second line. I found out that using \rowcolor{} and \multirow{-2}{text} don't overlay the text. But when using it the whole text shifts up and don't fit with the \rowcolor.

So here is my origin problem:

\begin{tabular}{ll}
        \toprule
        
        \textbf{Parameter} & \textbf{Beschreibung} \\
        \hline
        \midrule
        \rowcolor{gray!10}
        \textit{CV\_RETR\_EXTERNAL} & Abfrage der Extremwerte der Außenkontur\\
        
        \multirow{2}{*}{\textit{CV\_RETR\_LIST}} & \multirow{2}{10cm}{Abfrage aller Konturen in einer Liste und Verknüpfung aller Konturen miteinander. } \\
        &\\
        
        \rowcolor{gray!10}
            \multirow{2}{*}{\textit{CV\_RETR\_CCOMP}} & \multirow{2}{10cm}{Abfrage aller Konturen mit anschließender Einordnung in einer zweistufigen Hierarchie}\\
        \rowcolor{gray!10}
            &\\
        
        \textit{CV\_RETR\_TREE} &   Abfrage aller Konturen und Rekosntruktion der gesamten Hierarchie.\\
        \hline
        
    \end{tabular}

Result: Image1

When changing code to \multirow{-2} the text shifts up.

\begin{tabular}{ll}
        \toprule
        
        \textbf{Parameter} & \textbf{Beschreibung} \\
        \hline
        \midrule
        \rowcolor{gray!10}
        \textit{CV\_RETR\_EXTERNAL} & Abfrage der Extremwerte der Außenkontur\\
        
        \multirow{2}{*}{\textit{CV\_RETR\_LIST}} & \multirow{2}{10cm}{Abfrage aller Konturen in einer Liste und Verknüpfung aller Konturen miteinander. } \\
        &\\
        
        \rowcolor{gray!10}
            \multirow{-2}{*}{\textit{CV\_RETR\_CCOMP}} & \multirow{-2}{10cm}{Abfrage aller Konturen mit anschließender Einordnung in einer zweistufigen Hierarchie}\\
        \rowcolor{gray!10}
            &\\
        
        \textit{CV\_RETR\_TREE} &   Abfrage aller Konturen und Rekosntruktion der gesamten Hierarchie.\\
        \hline
        
    \end{tabular}

Result: Image2

Any hints?


Solution

  • Just forget \multirow here. What I suppose you want is to center the left column entries with respect to their right column cells. The easiest way to do this is to use a m{10cm} spec for the right column and then just enter the values.

    \documentclass{article}
    
    \usepackage{booktabs}
    \usepackage{array}
    \usepackage[table]{xcolor}
    \begin{document}
    \begin{tabular}{lm{10cm}}
            \toprule
            
            \textbf{Parameter} & \textbf{Beschreibung} \\
            \hline
            \midrule
            \rowcolor{gray!10}
            \textit{CV\_RETR\_EXTERNAL} & Abfrage der Extremwerte der Außenkontur\\
            
            {\textit{CV\_RETR\_LIST}} & Abfrage aller Konturen in einer Liste und Verknüpfung aller Konturen miteinander. \\
    
            \rowcolor{gray!10}
                {\textit{CV\_RETR\_CCOMP}} & Abfrage aller Konturen mit anschließender Einordnung in einer zweistufigen Hierarchie \\
    
            \textit{CV\_RETR\_TREE} &   Abfrage aller Konturen und Rekosntruktion der gesamten Hierarchie.\\
            \hline
            
        \end{tabular}
    \end{document}
    

    enter image description here