我正在为某份报告做规划,并使用 LaTeX 表格生成器将其从 Excel 更改为 LaTeX。但是,如果我运行生成的代码,垂直文本就会被拆分,这是我不想要的,见下图。你们中有人知道如何解决这个问题吗?我希望周数列有相等的间距,但无法做到这一点。我猜这也是合并行和合并列组合的问题......
代码(仅限第一个月):
\usepackage{makecell}
\usepackage{multirow}
\usepackage{colortbl}
\begin{table}
\centering
\begin{tabular}{|c|lllll|}
\hline
\multicolumn{1}{|r|}{Week number} & 1 & 2 & 3 & 4 & 5 \\
\hline
\multicolumn{1}{|r|}{Month} & \multicolumn{5}{l|}{January} \\
\hline
\multicolumn{1}{|l|}{Item} & & & & & \\
\hline
1 & {\cellcolor[rgb]{0.753,0.753,0.753}} & & & & \\
2 & {\cellcolor[rgb]{0.753,0.753,0.753}} & & & & \\
3 & {\cellcolor[rgb]{0.753,0.753,0.753}} & & & & \\
4 & {\cellcolor[rgb]{0.753,0.753,0.753}} & & & & \\
5 & {\cellcolor[rgb]{0.753,0.753,0.753}} & & & & \\
6 & {\cellcolor[rgb]{0.753,0.753,0.753}} & & & & \\
7 & {\cellcolor[rgb]{0.753,0.753,0.753}} & & & & \\
8 & {\cellcolor[rgb]{0.753,0.753,0.753}} & & & & \\
9 & {\cellcolor[rgb]{0.753,0.753,0.753}} & & & & \\
A & \multirow{-10}{*}{{\cellcolor[rgb]{0.753,0.753,0.753}}\rotcell{Holidays}} & & & & \\
\hline
\end{tabular}
\end{table}
答案1
您可以使用\rotatebox
。将命令替换\multirow{-10}{*}{{\cellcolor[rgb]{0.753,0.753,0.753}}\rotcell{Holidays}}
为
\parbox[t]{5mm}{\multirow{-10}{*}{\cellcolor[rgb]{0.753,0.753,0.753}\rotatebox[origin=c]{90}{Holidays}}}
并且它应该可以工作。5mm 设置灰色列的宽度。