答案1
这卢阿普罗格表我编写的这个包就是为了处理这种大型而复杂的表格。下面是一个使用该包减少工作量的示例(需要 LuaLaTeX!):
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[landscape]{geometry}
\usepackage{array}
\usepackage{multirow}
\usepackage{colortbl}
\usepackage{xcolor}
% the package is new, so it is unlikely to be included
% in your TeX distribution. You can download it form
% https://github.com/xziyue/luaprogtable
\usepackage{luaprogtable}
\usepackage{expl3}
\begin{document}
% create a table with 24 columns
\LPTNewTable{schedule}{24}{|*{24}{c|}}[
default after line=\hline,
nrows=16
]
% set current table
\LPTSetCurrentTable{schedule}
% add horizontal line before first line
\LPTSetRowProp{1}{before line=\hline}
\LPTSetCell{1, 1}[3,1]{\multirow{3}{*}{No.}}
\LPTSetRowProp{1}{after line=\cline{2-24}}
\LPTSetCell{1,2}[1,23]{\multicolumn{23}{c|}{Title}}
\LPTSetCell{2,2}[2,1]{\multirow{2}{*}{Activities}}
\LPTSetRowProp{2}{after line=\cline{3-24}}
\begin{lptview}{2,3:}
{\multicolumn{4}{c|}{August}}[-4]
{\multicolumn{5}{c|}{September}}[-5]
{\multicolumn{4}{c|}{October}}[-4]
{\multicolumn{4}{c|}{November}}[-4]
{\multicolumn{5}{c|}{December}}[-5]
\end{lptview}
% latex3 code to fill the table quickly
\ExplSyntaxOn
% list the "activities"
\clist_set:Nn \l_tmpa_clist {lorem,ipsum,dolor,sit,amet,consectetuer,adipiscing,elit,aenean,commodo,ligula,eget,dolor}
% start filling the table
\int_step_inline:nn {\clist_count:N \l_tmpa_clist} {
% set number indices
\exp_args:Nxx \LPTSetCell {\int_eval:n {3+#1}, 1} {#1}
% set activities
\exp_args:Nxx \LPTSetCell {\int_eval:n {3+#1}, 2} {\clist_item:Nn \l_tmpa_clist {#1}}
}
% fill the numbers
\tl_set:Nn \l_tmpa_tl {1234123451234123412345}
\int_step_inline:nn {\tl_count:N \l_tmpa_tl} {
\exp_args:Nxx \LPTSetCell {3,\int_eval:n {2+#1}} {\tl_item:Nn \l_tmpa_tl {#1}}
}
% now, declare a command to change cell color
\newcommand{\togglecell}[2]{
\exp_args:Nxx \LPTSetCell {\int_eval:n {3+#1},\int_eval:n {2+#2}} {\exp_not:n{\cellcolor{blue!50}}}
}
\ExplSyntaxOff
\togglecell{1}{1}
\togglecell{5}{12}
% use the table
\LPTUseTable
\end{document}
当然,如果你对该包不感兴趣,你可以参考上面代码生成的 LaTeX 源代码(如果你愿意编辑这样的内容的话)
\begin{tabular}{|*{24}{c|}}
\hline
\multirow {3}{*}{No.} & \multicolumn {23}{c|}{Title} \\\cline {2-24}
& \multirow {2}{*}{Activities} & \multicolumn{4}{c|}{August} & \multicolumn{5}{c|}{September} & \multicolumn{4}{c|}{October} & \multicolumn{4}{c|}{November} & \multicolumn{5}{c|}{December} \\\cline {3-24}
& & 1 & 2 & 3 & 4 & 1 & 2 & 3 & 4 & 5 & 1 & 2 & 3 & 4 & 1 & 2 & 3 & 4 & 1 & 2 & 3 & 4 & 5 \\\hline
1 & lorem & \cellcolor {blue!50} & & & & & & & & & & & & & & & & & & & & & \\\hline
2 & ipsum & & & & & & & & & & & & & & & & & & & & & & \\\hline
3 & dolor & & & & & & & & & & & & & & & & & & & & & & \\\hline
4 & sit & & & & & & & & & & & & & & & & & & & & & & \\\hline
5 & amet & & & & & & & & & & & & \cellcolor {blue!50} & & & & & & & & & & \\\hline
6 & consectetuer & & & & & & & & & & & & & & & & & & & & & & \\\hline
7 & adipiscing & & & & & & & & & & & & & & & & & & & & & & \\\hline
8 & elit & & & & & & & & & & & & & & & & & & & & & & \\\hline
9 & aenean & & & & & & & & & & & & & & & & & & & & & & \\\hline
10 & commodo & & & & & & & & & & & & & & & & & & & & & & \\\hline
11 & ligula & & & & & & & & & & & & & & & & & & & & & & \\\hline
12 & eget & & & & & & & & & & & & & & & & & & & & & & \\\hline
13 & dolor & & & & & & & & & & & & & & & & & & & & & & \\\hline
\end{tabular}