Wie kombiniere ich Zellenfarbe und gedrehten Text in einer Tabelle richtig?

Wie kombiniere ich Zellenfarbe und gedrehten Text in einer Tabelle richtig?

Ich versuche, eine Tabelle mit einer Breite von , farbigen Zellen und gedrehtem Text in den Spalten 4 bis 9 zu erstellen. Ich habe Probleme, die Zellen mit dem gedrehten Text einzufärben und die Tabelle über die Seite 1.2\linewidthauszudehnen . Können Sie mir bitte helfen?1.2\linewidth

\documentclass{article}

\usepackage[table]{xcolor}
\usepackage{tabularx}
\usepackage{booktabs}

\definecolor{mydarkblue}{RGB}{14,101,123}
\definecolor{mybrightblue}{RGB}{0,176,240}
\definecolor{mybrightgreen}{RGB}{197,224,180}
\definecolor{mybrightorange}{RGB}{248,203,173}
\definecolor{mybrightred}{RGB}{255,109,109}

\begin{document}

\newcommand{\STAB}[1]{\begin{tabular}{@{}c@{}}\cellcolor{mybrightblue}#1            

\begin{table}[!h]
\centering
\scriptsize
\begin{tabular*}{1.2\linewidth}{|l|l|l|c|c|c|c|c|c|l|l|@{}}
    \hline
    \multicolumn{1}{|c|}{\cellcolor{mydarkblue}\textbf{ID}} & 
    \multicolumn{1}{l|}{\cellcolor{mydarkblue}\textbf{Test}} & 
    \multicolumn{1}{l|}{\cellcolor{mydarkblue}\textbf{Test Text}} & 
    \multicolumn{6}{c|}{\cellcolor{mydarkblue}\textbf{Inspection Criteria}} & 
    \multicolumn{1}{l|}{\cellcolor{mydarkblue}\textbf{New}} & \multicolumn{1}{c|}{\cellcolor{mydarkblue}\textbf{Comment}} \\ \cline{4-9}
    \cellcolor{mydarkblue} & \multicolumn{1}{l|}{\cellcolor{mydarkblue}\textbf{Text}} & \multicolumn{1}{l|}{\cellcolor{mydarkblue}\textbf{Description}} & \multirow{3}{*}{\cellcolor{mybrightblue}\STAB{\rotatebox[origin=c]{90}{~~Criteria 1~~}}} &    
    \multirow{3}{*}{\cellcolor{mybrightblue}\STAB{\rotatebox[origin=c]{90}{Criteria 2}}} &
    \multirow{3}{*}{\cellcolor{mybrightblue}\STAB{\rotatebox[origin=c]{90}{Criteria 3}}} &
    \multirow{3}{*}{\cellcolor{mybrightblue}\STAB{\rotatebox[origin=c]{90}{Criteria 4}}} & 
    \multirow{3}{*}{\cellcolor{mybrightblue}\STAB{\rotatebox[origin=c]{90}{Criteria 5}}} &
    \multirow[c]{3}{*}{\cellcolor{mybrightblue}\STAB{\rotatebox[origin=c]{90}{Criteria 6}}} &
    \multicolumn{1}{l|}{\cellcolor{mydarkblue}\textbf{Workflow}} & \cellcolor{mydarkblue} \\
    \cellcolor{mydarkblue} & \multirow[t]{2}{*}{\cellcolor{mydarkblue}\textbf{Name}} & \cellcolor{mydarkblue} & & & & & & & \cellcolor{mydarkblue}\textbf{State} & \cellcolor{mydarkblue} \\
    \cellcolor{mydarkblue} & \cellcolor{mydarkblue} & \cellcolor{mydarkblue} & & & & & & & \cellcolor{mydarkblue} & \cellcolor{mydarkblue} \\ \hline 

    T-123 & Test Text 1 & Description 1 & \cellcolor{mybrightgreen} \cellcolor{mybrightgreen} OK & \cellcolor{mybrightgreen} OK & \cellcolor{mybrightgreen} OK & \cellcolor{mybrightgreen} OK & \cellcolor{mybrightgreen} OK & \cellcolor{mybrightgreen} OK & \cellcolor{mybrightgreen} APPROVED & \\ \hline
    T-124 & Test Text 2 & Description 2 & \cellcolor{mybrightgreen} OK & \cellcolor{mybrightred} NOK & \cellcolor{mybrightorange} PARTLY & \cellcolor{mybrightgreen} OK & \cellcolor{mybrightgreen} OK & \cellcolor{mybrightred} NOK & \cellcolor{mybrightred} REJECTED & \\ \hline
    & & & & & & & & & & \\ \hline
    & & & & & & & & & & \\ \hline
\end{tabular*}
\end{table} 

\end{document}

Mein Problem sieht folgendermaßen aus: Bildbeschreibung hier eingeben

Die Zellen mit den Kriterien sollten vollständig ausgefüllt werden und die Zellen mit den Wörtern OK, TEILWEISE, NOK, GENEHMIGT, ABGELEHNT sollten wie die Kriterienzellen gedreht werden. Außerdem sollte die Tabelle eine Breite von haben 1.2\linewidth. Die Spalten für die Kriterien sollten gleich breit sein. Wenn möglich, sollten die Spalten 1, 2, 3 und 11 mehrzeilig sein.

Antwort1

Und der Vollständigkeit halber ist hier ein calstable, das das Paket verwendetKalorien:

Bildbeschreibung hier eingeben

\documentclass{article}
\usepackage{graphicx, cals, xcolor}
\usepackage{changepage}

\let\nc=\nullcell                                                  % Shortcuts
\let\sc=\spancontent

\definecolor{mydarkblue}{RGB}{14,101,123}
\definecolor{mybrightblue}{RGB}{0,176,240}
\definecolor{mybrightgreen}{RGB}{197,224,180}
\definecolor{mybrightorange}{RGB}{248,203,173}
\definecolor{mybrightred}{RGB}{255,109,109}

\begin{document}

\noindent Blindtext. The quick brown fox jumped over the lazy dog. Which is just a text to see the text line.

\begin{calstable}[c]

% Defining 11 column relativ to each other and relativ to the margins
\colwidths{{\dimexpr(1.2\columnwidth/20)*2\relax}
            {\dimexpr(1.2\columnwidth/20)*3\relax}
            {\dimexpr(1.2\columnwidth/20)*3\relax}
            {\dimexpr(1.2\columnwidth/20)*1\relax}
            {\dimexpr(1.2\columnwidth/20)*1\relax}
            {\dimexpr(1.2\columnwidth/20)*1\relax}
            {\dimexpr(1.2\columnwidth/20)*1\relax}
            {\dimexpr(1.2\columnwidth/20)*1\relax}
            {\dimexpr(1.2\columnwidth/20)*1\relax}
            {\dimexpr(1.2\columnwidth/20)*3\relax}
            {\dimexpr(1.2\columnwidth/20)*3\relax}
            }
% The tabular fills 120% of the text area

% Set up the tabular
\makeatletter
\def\cals@framers@width{0.4pt}   % Outside frame rules, reduce if the rule is too heavy
\def\cals@framecs@width{0.4pt}
\def\cals@bodyrs@width{0.4pt}
\cals@setpadding{Ag}
\cals@setcellprevdepth{Al}
\def\cals@cs@width{0.4pt}             % Inside rules, reduce if the rule is too heavy
\def\cals@rs@width{0.4pt}
\def\cals@bgcolor{}             % Define cals@bgcolor to empty

\def\dblue{\ifx\cals@bgcolor\empty      % Colour switch (on-off)
    \def\cals@bgcolor{mydarkblue}
\else \def\cals@bgcolor{} \fi}

\def\bblue{\ifx\cals@bgcolor\empty      % Colour switch (on-off)
    \def\cals@bgcolor{mybrightblue}
\else \def\cals@bgcolor{} \fi}

\def\bgreen{\ifx\cals@bgcolor\empty     % Colour switch (on-off)
    \def\cals@bgcolor{mybrightgreen}
\else \def\cals@bgcolor{} \fi}

\def\bred{\ifx\cals@bgcolor\empty   % Colour switch (on-off)
    \def\cals@bgcolor{mybrightred}
\else \def\cals@bgcolor{} \fi}

\def\borange{\ifx\cals@bgcolor\empty    % Colour switch (on-off)
    \def\cals@bgcolor{mybrightorange}
\else \def\cals@bgcolor{} \fi}

\makeatother

\thead{\small\bfseries
\brow 
    \dblue\alignL\nc{tlr}
    \alignL\nc{tlr}
    \alignL\nc{tlr}
    \alignC\nc{ltb}
    \alignC\nc{tb}
    \alignC\nc{tb}
    \alignC\nc{tb}
    \alignC\nc{tb}
    \alignC\nc{rtb}\sc{Inspection Criteria}
    \alignL\nc{tlr}
    \alignL\nc{tlr}
\erow
\brow 
    \alignL\nc{blr}\sc{ID}
    \alignL\nc{blr}\sc{Test\par Text\par Name}
    \alignL\nc{blr}\sc{Test Text\par Description}\dblue
    \bblue\alignC\cell{\rotatebox[origin=c]{90}{Criteria 1}}
    \alignC\cell{\rotatebox[origin=c]{90}{Criteria 2}}
    \alignC\cell{\rotatebox[origin=c]{90}{Criteria 3}}
    \alignC\cell{\rotatebox[origin=c]{90}{Criteria 4}}
    \alignC\cell{\rotatebox[origin=c]{90}{Criteria 5}}
    \alignC\cell{\rotatebox[origin=c]{90}{Criteria 6}}\bblue
    \dblue\alignL\nc{blr}\sc{New\par Workflow\par State}
    \alignL\nc{blr}\sc{Comment}\bblue
\erow
\mdseries}
\brow 
    \alignL\cell{T-123}
    \alignL\cell{Test Text 1}
    \alignL\cell{Description 1}
    \bgreen\alignC\cell{\vfil\rotatebox[origin=c]{90}{OK}}
    \alignC\cell{\vfil\rotatebox[origin=c]{90}{OK}}
    \alignC\cell{\vfil\rotatebox[origin=c]{90}{OK}}
    \alignC\cell{\vfil\rotatebox[origin=c]{90}{OK}}
    \alignC\cell{\vfil\rotatebox[origin=c]{90}{OK}}
    \alignC\cell{\vfil\rotatebox[origin=c]{90}{OK}}
    \alignL\cell{\vfil\rotatebox[origin=c]{90}{APPROVED}}\bgreen
    \alignL\cell{}
\erow
\brow 
    \alignL\cell{T-124}
    \alignL\cell{Test Text 2}
    \alignL\cell{Description 2}
    \bgreen\alignC\cell{\vfil\rotatebox[origin=c]{90}{OK}}\bgreen
    \bred\alignC\cell{\vfil\rotatebox[origin=c]{90}{NOK}}\bred
    \borange\alignC\cell{\vfil\rotatebox[origin=c]{90}{PARTLY}}\borange
    \bgreen\alignC\cell{\vfil\rotatebox[origin=c]{90}{OK}}
    \alignC\cell{\vfil\rotatebox[origin=c]{90}{OK}}\bgreen
    \bred\alignC\cell{\vfil\rotatebox[origin=c]{90}{NOK}}
    \alignL\cell{\vfil\rotatebox[origin=c]{90}{REJECTED}}\bred
    \alignL\cell{}
\erow
\brow 
    \alignL\cell{T-125}
    \alignL\cell{}
    \alignL\cell{}
    \alignC\cell{}
    \alignC\cell{}
    \alignC\cell{}
    \alignC\cell{}
    \alignC\cell{}
    \alignC\cell{}
    \alignL\cell{}
    \alignL\cell{}
\erow
\brow 
    \alignL\cell{T126}
    \alignL\cell{}
    \alignL\cell{}
    \alignC\cell{}
    \alignC\cell{}
    \alignC\cell{}
    \alignC\cell{}
    \alignC\cell{}
    \alignC\cell{}
    \alignL\cell{}
    \alignL\cell{}
\erow
\end{calstable}

\end{document}

Antwort2

Hier ist eine mögliche Lösung. Viel einfacherer Code als Ihr MWE. Insbesondere die Anforderung, dass die Tabelle breiter als die Linienbreite sein muss, war eine Herausforderung. Natürlich haben Sie das übliche Problem, wenn Sie Linien und Farben in Tabellen kombinieren. Linien werden von den Farben überschrieben.

Bildbeschreibung hier eingeben

\documentclass{article}

\usepackage[table]{xcolor}
\usepackage{ adjustbox}
\usepackage{array}
\usepackage{changepage}

\definecolor{mydarkblue}{RGB}{14,101,123}
\definecolor{mybrightblue}{RGB}{0,176,240}
\definecolor{mybrightgreen}{RGB}{197,224,180}
\definecolor{mybrightorange}{RGB}{248,203,173}
\definecolor{mybrightred}{RGB}{255,109,109}

\newcolumntype{F}{>{\raggedright\arraybackslash}p{\dimexpr(0.095\linewidth-(2\tabcolsep+\arrayrulewidth))}}
\newcolumntype{P}{>{\raggedright\arraybackslash}p{\dimexpr(0.15\linewidth-(2\tabcolsep+\arrayrulewidth))}}
\newcolumntype{Q}{>{\centering\arraybackslash}p{\dimexpr(0.05\linewidth-(2\tabcolsep+\arrayrulewidth))}}


\begin{document}

\noindent Blindtext. The quick brown fox jumped over the lazy dog. Which is just a text to see the text line.

\begin{adjustwidth}{-0.1\linewidth}{-0.1\linewidth}

\noindent Blindtext. The quick brown fox jumped over the lazy dog. Which is just a text to see the text line.
\setlength{\extrarowheight}{3pt}
\def\arraystretch{1.2}

\centering
\scriptsize
\begin{tabular}{|F|P|P|Q|Q|Q|Q|Q|Q|P|P|}
\hline
    \rowcolor{mydarkblue}
    \bfseries ID & 
    \bfseries Test & 
    \bfseries Test Text & 
    \multicolumn{6}{c|}{\bfseries Inspection Criteria} & 
    \bfseries New &
    \bfseries Comment
\\\cline{4-9}
    \rowcolor{mybrightblue}
    \cellcolor{mydarkblue}&
    \cellcolor{mydarkblue}\begin{tabular}[b]{@{}l@{}}\cellcolor{mydarkblue}\bfseries Text\\ \cellcolor{mydarkblue}Name\end{tabular}
&
    \cellcolor{mydarkblue}\cellcolor{mydarkblue}\begin{tabular}[b]{@{}l@{}}\cellcolor{mydarkblue}\bfseries Description\\\cellcolor{mydarkblue}~\end{tabular}&
    \rotatebox[origin=c]{90}{~Criteria 1} &    
    \rotatebox[origin=c]{90}{~Criteria 2} &
    \rotatebox[origin=c]{90}{~Criteria 3} &
    \rotatebox[origin=c]{90}{~Criteria 4} & 
    \rotatebox[origin=c]{90}{~Criteria 5} &
    \rotatebox[origin=c]{90}{~Criteria 6} &
    \cellcolor{mydarkblue}\begin{tabular}[b]{@{}l@{}}\cellcolor{mydarkblue}\bfseries Workflow\\ \cellcolor{mydarkblue}State \end{tabular}&
    \cellcolor{mydarkblue}
\\\hline 
    T-123 & 
    Test Text 1 &
    Description 1 &
    \cellcolor{mybrightgreen}\rotatebox[origin=c]{90}{OK} &
    \cellcolor{mybrightgreen}\rotatebox[origin=c]{90}{OK} &
    \cellcolor{mybrightgreen}\rotatebox[origin=c]{90}{OK} &
    \cellcolor{mybrightgreen}\rotatebox[origin=c]{90}{OK} &
    \cellcolor{mybrightgreen}\rotatebox[origin=c]{90}{OK} &
    \cellcolor{mybrightgreen}\rotatebox[origin=c]{90}{OK} &
    \cellcolor{mybrightgreen}\rotatebox[origin=c]{90}{~APPROVED~} &
\\ \hline
    T-124 &
    Test Text 2 &
    Description 2 &
    \cellcolor{mybrightgreen}\rotatebox[origin=c]{90}{OK}&
    \cellcolor{mybrightred}\rotatebox[origin=c]{90}{NOK}&
    \cellcolor{mybrightorange}\rotatebox[origin=c]{90}{PARTLY} &
    \cellcolor{mybrightgreen}\rotatebox[origin=c]{90}{OK} &
    \cellcolor{mybrightgreen}\rotatebox[origin=c]{90}{OK} &
    \cellcolor{mybrightred}\rotatebox[origin=c]{90}{NOK} &
    \cellcolor{mybrightred}\rotatebox[origin=c]{90}{~REJECTED~} &
\\ \hline
    & & & & & & & & & & \\ \hline
    & & & & & & & & & & \\ \hline
\end{tabular}

\end{adjustwidth}

\end{document}

verwandte Informationen