我制作了一个带有重复空单元格的表格,所以我想知道是否有更好的方法来绘制它。
以下是我想出的代码:
\documentclass{article}
\usepackage[a4paper, landscape, margin=0.5in]{geometry}
\usepackage{multirow}
\usepackage{tabularx}
\usepackage{graphicx}
\setlength{\extrarowheight}{11pt}
\begin{document}
\pagenumbering{gobble}
\begin{tabularx}{\textwidth}{cc|c|X|c|X|c|X|c|X|c|X|c|X|c|X|c|X|c|X|c|X|c|c|}
\cline{3-22}
& & \multicolumn{20}{ c| }{\LARGE Joueurs} \\ \cline{3-22}
& & \multicolumn{4}{ c| }{} & \multicolumn{4}{ c| }{} & \multicolumn{4}{ c| }{} & \multicolumn{4}{ c| }{} & \multicolumn{4}{ c| }{} \\ \cline{1-24}
\multicolumn{1}{ |c }{\multirow{20}{*}{\rotatebox[origin=c]{90}{\LARGE Cartes}} } &
\multicolumn{1}{ |c| }{\multirow{2}{*}{\LARGE 10}} & ~~~
& & ~~~ & & ~~~ & & ~~~ & & ~~~ & & ~~~ & & ~~~ & & ~~~ & & ~~~ & & ~~~ & & ~~~ & ~~~ \\ \cline{3-3} \cline{5-5} \cline{7-7} \cline{9-9} \cline{11-11} \cline{13-13} \cline{15-15} \cline{17-17} \cline{19-19} \cline{21-21} \cline{23-24}
\multicolumn{1}{ |c }{} &
\multicolumn{1}{ |c| }{} &
\multicolumn{2}{ c| }{} & \multicolumn{2}{ c| }{} & \multicolumn{2}{ c| }{} & \multicolumn{2}{ c| }{} & \multicolumn{2}{ c| }{} & \multicolumn{2}{ c| }{} & \multicolumn{2}{ c| }{} & \multicolumn{2}{ c| }{} & \multicolumn{2}{ c| }{} & \multicolumn{2}{ c| }{} \\ \cline{2-24}
\multicolumn{1}{ |c }{} &
\multicolumn{1}{ |c| }{\multirow{2}{*}{\LARGE 9}} &
& & & & & & & & & & & & & & & & & & & & & \\ \cline{3-3} \cline{5-5} \cline{7-7} \cline{9-9} \cline{11-11} \cline{13-13} \cline{15-15} \cline{17-17} \cline{19-19} \cline{21-21} \cline{23-24}
\multicolumn{1}{ |c }{} &
\multicolumn{1}{ |c| }{} &
\multicolumn{2}{ c| }{} & \multicolumn{2}{ c| }{} & \multicolumn{2}{ c| }{} & \multicolumn{2}{ c| }{} & \multicolumn{2}{ c| }{} & \multicolumn{2}{ c| }{} & \multicolumn{2}{ c| }{} & \multicolumn{2}{ c| }{} & \multicolumn{2}{ c| }{} & \multicolumn{2}{ c| }{} \\ \cline{2-24}
\multicolumn{1}{ |c }{} &
\multicolumn{1}{ |c| }{\multirow{2}{*}{\LARGE 8}} &
& & & & & & & & & & & & & & & & & & & & & \\ \cline{3-3} \cline{5-5} \cline{7-7} \cline{9-9} \cline{11-11} \cline{13-13} \cline{15-15} \cline{17-17} \cline{19-19} \cline{21-21} \cline{23-24}
\multicolumn{1}{ |c }{} &
\multicolumn{1}{ |c| }{} &
\multicolumn{2}{ c| }{} & \multicolumn{2}{ c| }{} & \multicolumn{2}{ c| }{} & \multicolumn{2}{ c| }{} & \multicolumn{2}{ c| }{} & \multicolumn{2}{ c| }{} & \multicolumn{2}{ c| }{} & \multicolumn{2}{ c| }{} & \multicolumn{2}{ c| }{} & \multicolumn{2}{ c| }{} \\ \cline{2-24}
\multicolumn{1}{ |c }{} &
\multicolumn{1}{ |c| }{\multirow{2}{*}{\LARGE 7}} &
& & & & & & & & & & & & & & & & & & & & & \\ \cline{3-3} \cline{5-5} \cline{7-7} \cline{9-9} \cline{11-11} \cline{13-13} \cline{15-15} \cline{17-17} \cline{19-19} \cline{21-21} \cline{23-24}
\multicolumn{1}{ |c }{} &
\multicolumn{1}{ |c| }{} &
\multicolumn{2}{ c| }{} & \multicolumn{2}{ c| }{} & \multicolumn{2}{ c| }{} & \multicolumn{2}{ c| }{} & \multicolumn{2}{ c| }{} & \multicolumn{2}{ c| }{} & \multicolumn{2}{ c| }{} & \multicolumn{2}{ c| }{} & \multicolumn{2}{ c| }{} & \multicolumn{2}{ c| }{} \\ \cline{2-24}
\multicolumn{1}{ |c }{} &
\multicolumn{1}{ |c| }{} &
\multicolumn{2}{ c| }{} & \multicolumn{2}{ c| }{} & \multicolumn{2}{ c| }{} & \multicolumn{2}{ c| }{} & \multicolumn{2}{ c| }{} & \multicolumn{2}{ c| }{} & \multicolumn{2}{ c| }{} & \multicolumn{2}{ c| }{} & \multicolumn{2}{ c| }{} & \multicolumn{2}{ c| }{} \\ \cline{2-24}
\multicolumn{1}{ |c }{} &
\multicolumn{1}{ |c| }{\multirow{2}{*}{\LARGE 6}} &
& & & & & & & & & & & & & & & & & & & & & \\ \cline{3-3} \cline{5-5} \cline{7-7} \cline{9-9} \cline{11-11} \cline{13-13} \cline{15-15} \cline{17-17} \cline{19-19} \cline{21-21} \cline{23-24}
\multicolumn{1}{ |c }{} &
\multicolumn{1}{ |c| }{} &
\multicolumn{2}{ c| }{} & \multicolumn{2}{ c| }{} & \multicolumn{2}{ c| }{} & \multicolumn{2}{ c| }{} & \multicolumn{2}{ c| }{} & \multicolumn{2}{ c| }{} & \multicolumn{2}{ c| }{} & \multicolumn{2}{ c| }{} & \multicolumn{2}{ c| }{} & \multicolumn{2}{ c| }{} \\ \cline{2-24}
\multicolumn{1}{ |c }{} &
\multicolumn{1}{ |c| }{\multirow{2}{*}{\LARGE 5}} &
& & & & & & & & & & & & & & & & & & & & & \\ \cline{3-3} \cline{5-5} \cline{7-7} \cline{9-9} \cline{11-11} \cline{13-13} \cline{15-15} \cline{17-17} \cline{19-19} \cline{21-21} \cline{23-24}
\multicolumn{1}{ |c }{} &
\multicolumn{1}{ |c| }{} &
\multicolumn{2}{ c| }{} & \multicolumn{2}{ c| }{} & \multicolumn{2}{ c| }{} & \multicolumn{2}{ c| }{} & \multicolumn{2}{ c| }{} & \multicolumn{2}{ c| }{} & \multicolumn{2}{ c| }{} & \multicolumn{2}{ c| }{} & \multicolumn{2}{ c| }{} & \multicolumn{2}{ c| }{} \\ \cline{2-24}
\multicolumn{1}{ |c }{} &
\multicolumn{1}{ |c| }{\multirow{2}{*}{\LARGE 4}} &
& & & & & & & & & & & & & & & & & & & & & \\ \cline{3-3} \cline{5-5} \cline{7-7} \cline{9-9} \cline{11-11} \cline{13-13} \cline{15-15} \cline{17-17} \cline{19-19} \cline{21-21} \cline{23-24}
\multicolumn{1}{ |c }{} &
\multicolumn{1}{ |c| }{} &
\multicolumn{2}{ c| }{} & \multicolumn{2}{ c| }{} & \multicolumn{2}{ c| }{} & \multicolumn{2}{ c| }{} & \multicolumn{2}{ c| }{} & \multicolumn{2}{ c| }{} & \multicolumn{2}{ c| }{} & \multicolumn{2}{ c| }{} & \multicolumn{2}{ c| }{} & \multicolumn{2}{ c| }{} \\ \cline{2-24}
\multicolumn{1}{ |c }{} &
\multicolumn{1}{ |c| }{\multirow{2}{*}{\LARGE 3}} &
& & & & & & & & & & & & & & & & & & & & & \\ \cline{3-3} \cline{5-5} \cline{7-7} \cline{9-9} \cline{11-11} \cline{13-13} \cline{15-15} \cline{17-17} \cline{19-19} \cline{21-21} \cline{23-24}
\multicolumn{1}{ |c }{} &
\multicolumn{1}{ |c| }{} &
\multicolumn{2}{ c| }{} & \multicolumn{2}{ c| }{} & \multicolumn{2}{ c| }{} & \multicolumn{2}{ c| }{} & \multicolumn{2}{ c| }{} & \multicolumn{2}{ c| }{} & \multicolumn{2}{ c| }{} & \multicolumn{2}{ c| }{} & \multicolumn{2}{ c| }{} & \multicolumn{2}{ c| }{} \\ \cline{2-24}
\multicolumn{1}{ |c }{} &
\multicolumn{1}{ |c| }{\multirow{2}{*}{\LARGE 2}} &
& & & & & & & & & & & & & & & & & & & & & \\ \cline{3-3} \cline{5-5} \cline{7-7} \cline{9-9} \cline{11-11} \cline{13-13} \cline{15-15} \cline{17-17} \cline{19-19} \cline{21-21} \cline{23-24}
\multicolumn{1}{ |c }{} &
\multicolumn{1}{ |c| }{} &
\multicolumn{2}{ c| }{} & \multicolumn{2}{ c| }{} & \multicolumn{2}{ c| }{} & \multicolumn{2}{ c| }{} & \multicolumn{2}{ c| }{} & \multicolumn{2}{ c| }{} & \multicolumn{2}{ c| }{} & \multicolumn{2}{ c| }{} & \multicolumn{2}{ c| }{} & \multicolumn{2}{ c| }{} \\ \cline{2-24}
\multicolumn{1}{ |c }{} &
\multicolumn{1}{ |c| }{\multirow{2}{*}{\LARGE 1}} &
& & & & & & & & & & & & & & & & & & & & & \\ \cline{3-3} \cline{5-5} \cline{7-7} \cline{9-9} \cline{11-11} \cline{13-13} \cline{15-15} \cline{17-17} \cline{19-19} \cline{21-21} \cline{23-24}
\multicolumn{1}{ |c }{} &
\multicolumn{1}{ |c| }{} &
\multicolumn{2}{ c| }{} & \multicolumn{2}{ c| }{} & \multicolumn{2}{ c| }{} & \multicolumn{2}{ c| }{} & \multicolumn{2}{ c| }{} & \multicolumn{2}{ c| }{} & \multicolumn{2}{ c| }{} & \multicolumn{2}{ c| }{} & \multicolumn{2}{ c| }{} & \multicolumn{2}{ c| }{} \\ \cline{1-22}
\end{tabularx}
\end{document}
答案1
由于存在大量重复或反复出现的材料,设置宏来处理代码中重复出现的部分是一个好主意。
\documentclass{article}
\usepackage[a4paper, landscape, margin=0.5in]{geometry}
\usepackage{multirow,tabularx,graphicx}
\setlength{\extrarowheight}{11pt}
%% Define a few macros to handle recurring material
\newcommand\myheader[1]{%
\multicolumn{1}{|c}{} &
\multicolumn{1}{|c|}{\multirow{2}{*}{\LARGE #1}}}
\newcommand\manyamps{%
& & & & & & & & & & & & & & & & & & & & & & \\}
\newcommand\manyclines{%
\cline{3-3} \cline{5-5} \cline{7-7} \cline{9-9} \cline{11-11} \cline{13-13}
\cline{15-15} \cline{17-17} \cline{19-19} \cline{21-21} \cline{23-24}}
\newcommand\manymulticols{%
\multicolumn{1}{|c}{} & \multicolumn{1}{|c|}{} &
\multicolumn{2}{c|}{} & \multicolumn{2}{c|}{} &
\multicolumn{2}{c|}{} & \multicolumn{2}{c|}{} &
\multicolumn{2}{c|}{} & \multicolumn{2}{c|}{} &
\multicolumn{2}{c|}{} & \multicolumn{2}{c|}{} &
\multicolumn{2}{c|}{} & \multicolumn{2}{c|}{} \\}
\newcommand\myline[1]{% combine the four preceding macros
\myheader{#1}\manyamps\manyclines\manymulticols}
\begin{document}
\pagenumbering{gobble}
\noindent % <--- new
\begin{tabularx}{\textwidth}{cc| *{10}{c|X|} c|c|}
\cline{3-22}
& & \multicolumn{20}{c|}{\LARGE Joueurs} \\
\cline{3-22}
& & \multicolumn{4}{c|}{} & \multicolumn{4}{c|}{}
& \multicolumn{4}{c|}{} & \multicolumn{4}{c|}{}
& \multicolumn{4}{c|}{} \\
\hline %%\cline{1-24}
\multicolumn{1}{|c}{\multirow{21}{*}{\rotatebox[origin=c]{90}{\LARGE Cartes}} } &
\multicolumn{1}{|c|}{\multirow{2}{*}{\LARGE 10}}
& ~~~ & & ~~~ & & ~~~ & & ~~~ & & ~~~ & & ~~~ &
& ~~~ & & ~~~ & & ~~~ & & ~~~ & & ~~~ & ~~~ \\
\manyclines\manymulticols \cline{2-24}
% Use the "\myline" macro for rows 9, 8, ..., 2, 1.
\myline{9} \cline{2-24}
\myline{8} \cline{2-24}
\myline{7} \cline{2-22} % not "2-24"
\manymulticols \cline{2-24}
\myline{6} \cline{2-24}
\myline{5} \cline{2-24}
\myline{4} \cline{2-24}
\myline{3} \cline{2-24}
\myline{2} \cline{2-24}
\myline{1} \cline{1-22} % not "2-24"
\end{tabularx}
\end{document}