3

I tried to color the text of the headers of my tables. Sadly it doesn't work properly as soon as you use it with paragraph columns.

Below is my MWE presented. The header in the first table is as I want it to be. Unfortunately the table is too long, so I need a paragraph column for the right column. But when I use this, I get problems with the layout (see second table in picture).

Can anyone tell me, why this happens and/or how to correct it?

\documentclass{article}

\usepackage{array}
\usepackage{xcolor}

\makeatletter

\newcommand*{\@rowstyle}{}

\newcommand*{\rowstyle}[1]{% sets the style of the next row
  \gdef\@rowstyle{#1}%
  \@rowstyle\ignorespaces%
}

\newcolumntype{=}{% resets the row style
  >{\gdef\@rowstyle{}}%
}

\newcolumntype{+}{% adds the current row style to the next column
  >{\@rowstyle}%
}

\makeatother

\begin{document}

\begin{tabular}{=l +l}
  \rowstyle{\color{red}}
Kategorie & Behandelte Frage(n) \\
\bfseries Usability & Ist das System einfach und intuitiv zu bedienen?\\
\bfseries Adaptability & Kann man das System an die eigenen Prozesse anpassen? Gibt es     eigene Workflows und Felder?\\
\end{tabular}

\vspace{25pt}

\begin{tabular}{=l +p{9cm}}
  \rowstyle{\color{red}}
Kategorie & Behandelte Frage(n) \\
\bfseries Usability & Ist das System einfach und intuitiv zu bedienen?\\
\bfseries Adaptability & Kann man das System an die eigenen Prozesse anpassen? Gibt es     eigene Workflows und Felder?\\
\end{tabular}

\end{document}

MWE with 2 Tables

David Carlisle
  • 757,742
Arno Nym
  • 63
  • 5

1 Answers1

4

The text in the p and the X column (which uses in the default setting a p column) will get moved to the second line. The cells themselves are top-aligned.

While I don’t know what \color exactly does, the result can be reproduced with

\hrulefill                       \par
\parbox[t]{8cm}{\color{red}Text} \par
\hrulefill

References

Code

\documentclass{article}
\usepackage{array,xcolor,tabularx}

\makeatletter
\newcommand*{\rowstyle}[1]{% sets the style of the next row
  \gdef\@rowstyle{\leavevmode#1}%
  \@rowstyle\ignorespaces}
\newcolumntype{=}{>{\gdef\@rowstyle{}}}
\newcolumntype{+}{>{\@rowstyle}}
\makeatother

\begin{document}

\noindent
\begin{tabular}{=l +l}
    \rowstyle{\color{red}} Kategorie & Behandelte Frage(n)                                                                        \\
    \bfseries Usability              & Ist das System einfach und intuitiv zu bedienen?                                           \\
    \bfseries Adaptability           & Kann man das System an die eigenen Prozesse anpassen? Gibt es eigene Workflows und Felder?
\end{tabular}

\vspace{25pt}

\noindent
\begin{tabular}{=l +p{8cm}}
    \rowstyle{\color{red}} Kategorie & Behandelte Frage(n)                                                                        \\
    \bfseries Usability              & Ist das System einfach und intuitiv zu bedienen?                                           \\
    \bfseries Adaptability           & Kann man das System an die eigenen Prozesse anpassen? Gibt es eigene Workflows und Felder?
\end{tabular}

\vspace{25pt}

\noindent
\begin{tabularx}{\linewidth}{=l +X}
    \rowstyle{\color{red}} Kategorie & Behandelte Frage(n)                                                                        \\
    \bfseries Usability              & Ist das System einfach und intuitiv zu bedienen?                                           \\
    \bfseries Adaptability           & Kann man das System an die eigenen Prozesse anpassen? Gibt es eigene Workflows und Felder?
\end{tabularx}
\end{document}

Output

enter image description here

Moriambar
  • 11,466
Qrrbrbirlbel
  • 119,821