pele_mele:stack_exchange:tex_latex:367891
Is there a better way for drawing my table
I've made a table with repeating empty cells so I was wondering if there is a better way to draw it.
Here is the code I came up with:
\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}
Since there's a lot of repeated or recurring material, it's a good idea to set up macros to handle the recurring parts of the code.
\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}
pele_mele/stack_exchange/tex_latex/367891.txt · Dernière modification : 2024/11/23 03:58 de alexis