如果有人搜索我今天的问题,就会发现都是关于桌子的。尽管我收到了重要的提示,但我仍然不知道如何创建我的桌子。所以我决定展示一张我真正想要的和我拥有的东西的图片
这是我想要的表格:
这实际上是我在 LaTeX 中所拥有的
\documentclass[12pt]{standalone}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{rotating}
\usepackage{booktabs}
\usepackage{multicol}
\usepackage{multirow}
\usepackage{array}
\usepackage{colortbl}
\definecolor{darkblue}{RGB}{55,171,200}
\definecolor{green}{RGB}{113,200,55}
\definecolor{pool}{RGB}{85,221,255}
\begin{document}
\footnotesize
\begin{tabular}{c|*4{>{\centering\arraybackslash}m{3cm}}}
& \textbf{Text} & \textbf{Text} & \textbf{Text} & \textbf{Text} \\
\hline
\parbox[c]{10pt}{\begin{sideways}\textbf{Text}\end{sideways}} & \multirow{2}{3cm}{\centering\cellcolor{darkblue}Three\\Lines\\Text} & \multirow{2}{3cm}{\cellcolor{darkblue}\centering Three\\Lines\\Text} & & \\
\cline{1-1}\cline{3-5}
\parbox[c]{10pt}{\begin{sideways}\textbf{Text}\end{sideways}} &\cellcolor{darkblue} &\cellcolor{darkblue} & \cellcolor{darkblue}\shortstack[c]{Three\\Lines\\Text} & \\
\hline
\parbox[c]{10pt}{\begin{sideways}\textbf{Text}\end{sideways}} & \cellcolor{green}\shortstack[c]{Three\\Lines\\Text} & \multicolumn{3}{c}{\cellcolor{pool}Single line text}\\
\hline
\parbox[c]{10pt}{\begin{sideways}\textbf{Text}\end{sideways}} & \cellcolor{darkblue} \shortstack[c]{Two Lines\\Text} & \multicolumn{3}{c}{\cellcolor{pool}Single line text}\\
\hline
\parbox[c]{10pt}{\begin{sideways}\textbf{Text}\end{sideways}} & \cellcolor{green}\shortstack[c]{Three\\Lines\\Text} & \multicolumn{3}{c}{\cellcolor{pool}Single line text}\\
\hline
\parbox[c]{10pt}{\begin{sideways}\textbf{Text}\end{sideways}} & \cellcolor{darkblue} \shortstack[c]{two Lines\\Text} & \multicolumn{3}{c}{\cellcolor{pool} single line text} \\
\hline
\end{tabular}
答案1
一般来说,colortbl
与混用不是一个好主意multirow
,同样适用于表格规则,特别是与 的规则混用booktabs
。有时可能是一种巧妙的方法来适应事物,但无论如何我的建议是重新设计表格。
\documentclass[12pt,margin=1mm]{standalone}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{rotating}
\usepackage{booktabs}
\usepackage{multicol}
\usepackage{multirow}
\usepackage{array}
\usepackage{colortbl}
\definecolor{darkblue}{RGB}{55,171,200}
\definecolor{green}{RGB}{113,200,55}
\definecolor{pool}{RGB}{85,221,255}
\begin{document}
\footnotesize
\setlength\arrayrulewidth{-1pt}
\setlength\aboverulesep{0pt}
\setlength\belowrulesep{0pt}
\setlength\fboxsep{-1pt}
\renewcommand{\arraystretch}{4}
\colorbox{darkblue}{%
\begin{tabular}{|>{\cellcolor{white}}c*4{>{\centering\arraybackslash}m{3cm}|}}\\[-7em]
\rowcolor{white}& \textbf{Text} & \textbf{Text} & \textbf{Text} & \textbf{Text} \\
\cmidrule{1-5}
\rotatebox[origin=c]{45}{\textbf{Text}} & \multirow{2}{3cm}{\centering Three\\Lines\\Text} & \multirow{2}{3cm}{\centering Three\\Lines\\Text} &\cellcolor{white} &\cellcolor{white} \\
\cmidrule{1-1}\cmidrule{4-5}
\rotatebox[origin=c]{45}{\textbf{Text}} & & & \shortstack[c]{Three\\Lines\\Text} &\cellcolor{white} \\
\cmidrule{1-5}
\rotatebox[origin=b]{45}{\textbf{Text}} & \cellcolor{green}\shortstack[c]{Three\\Lines\\Text} & \multicolumn{3}{c}{\cellcolor{pool}Single line text}\\
\cmidrule{1-5}
\rotatebox[origin=c]{45}{\textbf{Text}} & \cellcolor{darkblue} \shortstack[c]{Two Lines\\Text} & \multicolumn{3}{c}{\cellcolor{pool}Single line text}\\
\cmidrule{1-5}
\rotatebox[origin=c]{45}{\textbf{Text}} & \cellcolor{green}\shortstack[c]{Three\\Lines\\Text} & \multicolumn{3}{c}{\cellcolor{pool}Single line text}\\
\cmidrule{1-5}
\rotatebox[origin=c]{45}{\textbf{Text}} & \cellcolor{darkblue} \shortstack[c]{two Lines\\Text} & \multicolumn{3}{c}{\cellcolor{pool} single line text} \\
\midrule
\end{tabular}}
\end{document}
答案2
multirow text
这是一个解决方案。不被彩色背景隐藏的诀窍是\multirow
在最后一行插入命令,并使用负参数。我借此机会简化了您的代码。
\documentclass[12pt, border=3pt]{standalone}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{rotating}
\usepackage{booktabs}
\usepackage{multirow, bigstrut, cellspace}
\setlength{\cellspacetoplimit}{3pt}
\setlength{\cellspacebottomlimit}{3pt}
\usepackage{array}
\usepackage[table]{xcolor}
\definecolor{darkblue}{RGB}{55,171,200}
\definecolor{green}{RGB}{113,200,55}
\definecolor{pool}{RGB}{85,221,255}
\begin{document}
\footnotesize\setlength{\aboverulesep}{0pt}\setlength{\belowrulesep}{0pt}
\begin{tabular}{>{\bfseries}Sc|*4{>{\centering\arraybackslash}m{3cm}}}
\multicolumn{1}{c}{} & \textbf{Text} & \textbf{Text} & \textbf{Text} & \textbf{Text} \\
\toprule
\rotatebox[origin=c]{90}{Text} &\cellcolor{darkblue} & \cellcolor{darkblue} & & \\
\arrayrulecolor{darkblue}\cmidrule{1-5}\noalign{\vspace*{-\cmidrulewidth}}\arrayrulecolor{black}\cmidrule{1-1}\cmidrule{4-5}
\rotatebox[origin=c]{90}{Text} & \multirow{-3}{=}{\centering\cellcolor{darkblue}Three\\Lines\\Text} & \multirow{-3}{=}{\centering Three\\Lines\\Text}\cellcolor{darkblue} & \cellcolor{darkblue}\shortstack[c]{\bigstrut[t] Three\\Lines\\Text} & \\
\midrule
\rotatebox[origin=c]{90}{Text} & \cellcolor{green}\shortstack[c]{\bigstrut[t] Three\\Lines\\Text} & \multicolumn{3}{c}{\cellcolor{pool}Single line text}\\
\midrule
\rotatebox[origin=c]{90}{Text} & \cellcolor{darkblue} \shortstack[c]{Two Lines\\Text} & \multicolumn{3}{c}{\cellcolor{pool}Single line text}\\
\midrule
\rotatebox[origin=c]{90}{Text} & \cellcolor{green}\shortstack[c]{\bigstrut[t]Three\\Lines\\Text} & \multicolumn{3}{c}{\cellcolor{pool}Single line text}\\
\midrule
\rotatebox[origin=c]{90}{Text} & \cellcolor{darkblue} \shortstack[c]{two Lines\\Text} & \multicolumn{3}{c}{\cellcolor{pool} single line text} \\
\bottomrule
\end{tabular}
\end{document}