4~9열의 색상 셀과 회전된 텍스트 에 해당하는 너비를 갖는 테이블을 만들려고 합니다. 1.2\linewidth
회전된 텍스트가 포함된 셀 색상을 지정하고 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}
기준이 있는 셀은 완전히 채워야 하며 OK, PARTLY, NOK, APPROVED, REJECTED라는 단어가 포함된 셀은 기준 셀처럼 회전되어야 합니다. 또한 테이블의 너비는 1.2\linewidth
. 기준에 대한 열의 너비는 동일해야 합니다. 가능하다면 1, 2, 3, 11열은 여러 줄로 구성되어야 합니다.
답변1
완전성을 기하기 위해 여기에는 calstable
패키지를 사용하는 가 있습니다.칼로리:
\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}
답변2
가능한 해결책은 다음과 같습니다. MWE보다 훨씬 간단한 코드입니다. 특히, 테이블이 선폭보다 넓어야 한다는 요청이 까다로웠습니다. 당연히 표에서 선과 색상을 결합할 때 일반적인 문제가 발생합니다. 색상이 선을 덮어씁니다.
\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}