pele_mele:stack_exchange:tex_latex:377681
Différences
Ci-dessous, les différences entre deux révisions de la page.
Les deux révisions précédentesRévision précédente | |||
pele_mele:stack_exchange:tex_latex:377681 [2024/11/23 04:02] – supprimée - modification externe (Date inconnue) 127.0.0.1 | pele_mele:stack_exchange:tex_latex:377681 [2024/11/23 04:02] (Version actuelle) – ↷ Nom de la page changé de pele_mele:stack_exchange:tex_latex:tex-377681 à pele_mele:stack_exchange:tex_latex:377681 alexis | ||
---|---|---|---|
Ligne 1: | Ligne 1: | ||
+ | ====== How to keep cell border with a column background color? ====== | ||
+ | I used my [[https:// | ||
+ | |||
+ | So my idea was to color every other column so I know which one I need to use. | ||
+ | |||
+ | Here is what I got so far: | ||
+ | |||
+ | <code latex> | ||
+ | \documentclass{letter} | ||
+ | |||
+ | \usepackage[a4paper, | ||
+ | \usepackage{multirow} | ||
+ | \usepackage{tabularx} | ||
+ | \usepackage{graphicx} | ||
+ | \usepackage{color, | ||
+ | |||
+ | \setlength{\extrarowheight}{14pt} | ||
+ | |||
+ | \definecolor{Gray}{gray}{0.85} | ||
+ | |||
+ | \newcolumntype{g}{> | ||
+ | \newcolumntype{G}{> | ||
+ | |||
+ | \newcommand\customTable{ | ||
+ | \begin{tabularx}{\textwidth}{cc|c|X|g|G|c|X|g|G|c|X|g|G|c|X|g|G|c|X|g|G|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} | ||
+ | |||
+ | \customRow{10}{\multirow{20}{*}{\rotatebox[origin=c]{90}{\LARGE Cartes}}}\cline{2-24} | ||
+ | \customRow{9}{}\cline{2-24} | ||
+ | \customRow{8}{}\cline{2-24} | ||
+ | \customRow{7}{}\cline{2-24} | ||
+ | \customRow{6}{}\cline{2-24} | ||
+ | \customRow{5}{}\cline{2-24} | ||
+ | \customRow{4}{}\cline{2-24} | ||
+ | \customRow{3}{}\cline{2-24} | ||
+ | \customRow{2}{}\cline{2-24} | ||
+ | \customRow{1}{}\cline{1-22} | ||
+ | \end{tabularx} | ||
+ | } | ||
+ | |||
+ | \newcommand\customHeader[2]{ | ||
+ | \multicolumn{1}{|c}{# | ||
+ | \multicolumn{1}{|c|}{\multirow{2}{*}{\LARGE #1}} | ||
+ | } | ||
+ | |||
+ | \newcommand\emptyCells{ | ||
+ | & ~~~ & & ~~~ & & ~~~ & & ~~~ & & ~~~ & & ~~~ & & ~~~ & & ~~~ & & ~~~ & & ~~~ & & ~~~ & ~~~ \\ | ||
+ | } | ||
+ | |||
+ | \newcommand\customBorder{ | ||
+ | \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\emptyDoubleCells{ | ||
+ | \multicolumn{1}{|c}{} & \multicolumn{1}{|c|}{} & \multicolumn{2}{c|}{} & \multicolumn{2}{g|}{} & \multicolumn{2}{c|}{} & \multicolumn{2}{g|}{} & \multicolumn{2}{c|}{} & \multicolumn{2}{g|}{} & \multicolumn{2}{c|}{} & \multicolumn{2}{g|}{} & \multicolumn{2}{c|}{} & \multicolumn{2}{g|}{} \\ | ||
+ | } | ||
+ | |||
+ | \newcommand\customRow[2]{ | ||
+ | \customHeader{# | ||
+ | } | ||
+ | |||
+ | \begin{document} | ||
+ | \pagenumbering{gobble} | ||
+ | \customTable | ||
+ | \customTable | ||
+ | \end{document} | ||
+ | </ | ||
+ | |||
+ | Now, every other column have a background but I've lost the borders on those. | ||
+ | |||
+ | I've looked [[http:// | ||
+ | |||
+ | So how do I color the background and keep the borders at the same time? | ||
+ | |||
+ | <WRAP help> | ||
+ | The trick in case of problems with lines in coloured tables consists in using '' | ||
+ | |||
+ | Some explanations on the code: | ||
+ | |||
+ | An '' | ||
+ | |||
+ | To delete white rules in coloured cells, I replaced '' | ||
+ | |||
+ | <code latex> | ||
+ | \documentclass{letter} | ||
+ | |||
+ | \usepackage[a4paper, | ||
+ | \usepackage{multirow} | ||
+ | \usepackage{tabularx} | ||
+ | \usepackage{graphicx} | ||
+ | \usepackage[table]{xcolor} | ||
+ | \usepackage{hhline, | ||
+ | \newcommand\mycline{\hhline{|~*{23}{|-}}} | ||
+ | |||
+ | \setlength{\extrarowheight}{14pt} | ||
+ | |||
+ | \definecolor{Gray}{gray}{0.85} | ||
+ | |||
+ | \newcolumntype{g}{> | ||
+ | \newcolumntype{G}{> | ||
+ | |||
+ | \newcommand\customTable{ | ||
+ | \begin{tabularx}{\textwidth}{cc|*{5}{c|X|g|G|}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} | ||
+ | \hhline{*{24}{-}} | ||
+ | |||
+ | \customRow{10}{\multirow{20}{*}{\rotatebox[origin=c]{90}{\LARGE Cartes}}}%\cline{2-24} | ||
+ | \mycline | ||
+ | \customRow{9}{}\mycline | ||
+ | \customRow{8}{}\mycline | ||
+ | \customRow{7}{}\mycline | ||
+ | \customRow{6}{}\mycline | ||
+ | \customRow{5}{}\mycline | ||
+ | \customRow{4}{}\mycline | ||
+ | \customRow{3}{}\mycline | ||
+ | \customRow{2}{}\mycline | ||
+ | \customRow{1}{}\cline{1-22} | ||
+ | \end{tabularx} | ||
+ | } | ||
+ | |||
+ | \newcommand\customHeader[2]{ | ||
+ | \multicolumn{1}{|c|}{# | ||
+ | \multicolumn{1}{c|}{\multirow{2}{*}{\LARGE #1}} | ||
+ | } | ||
+ | |||
+ | \newcommand\emptyCells{ | ||
+ | & ~~~ & & ~~~ & & ~~~ & & ~~~ & & ~~~ & & ~~~ & & ~~~ & & ~~~ & & ~~~ & & ~~~ & & ~~~ & ~~~ \\ | ||
+ | } | ||
+ | |||
+ | \newcommand\customBorder{% | ||
+ | \hhline{|~|~|*{5}{> | ||
+ | }% | ||
+ | |||
+ | \newcommand\emptyDoubleCells{ | ||
+ | \multicolumn{1}{|c|}{} & \multicolumn{1}{c|}{} & \multicolumn{2}{c|}{} & \multicolumn{2}{g|}{} & \multicolumn{2}{c|}{} & \multicolumn{2}{g|}{} & \multicolumn{2}{c|}{} & \multicolumn{2}{g|}{} & \multicolumn{2}{c|}{} & \multicolumn{2}{g|}{} & \multicolumn{2}{c|}{} & \multicolumn{2}{g|}{} \\ | ||
+ | } | ||
+ | |||
+ | \newcommand\customRow[2]{ | ||
+ | \customHeader{# | ||
+ | } | ||
+ | |||
+ | \begin{document} | ||
+ | |||
+ | \pagenumbering{gobble} | ||
+ | \customTable | ||
+ | \customTable | ||
+ | |||
+ | \end{document} | ||
+ | </ | ||
+ | |||
+ | {{: | ||
+ | </ | ||
+ | <WRAP help> | ||
+ | I learned how to deal with the annoying effect of white lines in colored cells using the technique explained in the comment of Ulrike Fischer in [[https:// | ||
+ | |||
+ | It is only necessary to raise the line a little. | ||
+ | |||
+ | In the above code, replace | ||
+ | |||
+ | <code latex> | ||
+ | \newcommand\emptyCells{ | ||
+ | & ~~~ & & ~~~ & & ~~~ & & ~~~ & & ~~~ & & ~~~ & & ~~~ & & ~~~ & & ~~~ & & ~~~ & & ~~~ & ~~~ \\ | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | with | ||
+ | |||
+ | <code latex> | ||
+ | \newcommand\emptyCells{ | ||
+ | & ~~~ & & ~~~ & & ~~~ & & ~~~ & & ~~~ & & ~~~ & & ~~~ & & ~~~ & & ~~~ & & ~~~ & & ~~~ & ~~~ \\[-0.5pt] % small shift up <<<<<<<< | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | It may just be a PDF viewer effect, but you never know what will come out of a digital press. | ||
+ | |||
+ | Original output | ||
+ | |||
+ | {{: | ||
+ | |||
+ | With the modified code | ||
+ | |||
+ | {{: | ||
+ | </ | ||
+ | <WRAP info> | ||
+ | [[https:// | ||
+ | </ | ||