Intento crear una tabla que tenga un ancho correspondiente a 1.2\linewidth
celdas coloreadas y texto rotado en las columnas 4 a 9. Tengo problemas para colorear las celdas que contienen el texto rotado y para estirar la tabla sobre 1.2\linewidth
la página. ¿Puedes ayudarme por favor?
\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}
Las celdas con los criterios deben llenarse por completo y las celdas que contienen las palabras OK, PARCIALMENTE, NOK, APROBADO, RECHAZADO deben rotarse como las celdas de criterios. Además, la mesa debe tener un ancho de 1.2\linewidth
. Las columnas de los criterios deben tener el mismo ancho. Si es posible, las columnas 1, 2, 3 y 11 deben tener varias líneas.
Respuesta1
Y para completar, aquí hay un calstable
, usando el paquetecalorías:
\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}
Respuesta2
Aquí hay una posible solución. Código mucho más simple que tu MWE. En particular, la solicitud de que la tabla tuviera que ser más ancha que el ancho de la línea fue un desafío. Por supuesto, tendrás el problema habitual a la hora de combinar líneas y colores en tablas. Las líneas se sobrescriben con los colores.
\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}