TeX - LaTeX Asked by A.D. on January 19, 2021
I used my score board for a while now, but it appears that it’s hard to know in which column I need to write.
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:
documentclass{letter}
usepackage[a4paper, landscape, margin=0.5cm]{geometry}
usepackage{multirow}
usepackage{tabularx}
usepackage{graphicx}
usepackage{color, colortbl}
setlength{extrarowheight}{14pt}
definecolor{Gray}{gray}{0.85}
newcolumntype{g}{>{columncolor{Gray}}c}
newcolumntype{G}{>{columncolor{Gray}}X}
newcommandcustomTable{
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}
}
newcommandcustomHeader[2]{
multicolumn{1}{|c}{#2} &
multicolumn{1}{|c|}{multirow{2}{*}{LARGE #1}}
}
newcommandemptyCells{
& ~~~ & & ~~~ & & ~~~ & & ~~~ & & ~~~ & & ~~~ & & ~~~ & & ~~~ & & ~~~ & & ~~~ & & ~~~ & ~~~ \
}
newcommandcustomBorder{
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}
}
newcommandemptyDoubleCells{
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|}{} \
}
newcommandcustomRow[2]{
customHeader{#1}{#2}emptyCellscustomBorderemptyDoubleCells
}
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 here and here for inspiration, but I cannot spot where is my mistake.
So how do I color the background and keep the borders at the same time?
The trick in case of problems with lines in coloured tables consists in using hhline
, so I redefined customBorder
. Note the very thin white lines in the coloured cells seem to come from the viewer.
Some explanations on the code:
An hhline
is described by a succession of symbols (one per column): either ~
(no rule in the corresponding column), or -
(a single rule) or =
(a double rule) These symbols can be separated by symbols describing how horizontal rule and vertical rule intersect (|
, ||
and :
). Furthermore, if a motto is repeated several times, a short syntax similar to the array
package syntax for repeated column type can be used. Here, I used *{5}{...}
, which means the same motto is repeated 4 times (and used 5!). Also the syntax >{...}
allows to insert code before the following segment (e.g. to change the rule colour from the next segment).
To delete white rules in coloured cells, I replaced ~
which would have been used if the cell were not coloured, with a rule segment of the same colour as the cell, like this |>{arrayrulecolor{Gray}->{arrayrulecolor{black}|- ...
.
documentclass{letter}
usepackage[a4paper, landscape, margin=0.5cm]{geometry}
usepackage{multirow}
usepackage{tabularx}
usepackage{graphicx}
usepackage[table]{xcolor}
usepackage{hhline, booktabs}
newcommandmycline{hhline{|~*{23}{|-}}}
setlength{extrarowheight}{14pt}
definecolor{Gray}{gray}{0.85}
newcolumntype{g}{>{columncolor{Gray}}c}
newcolumntype{G}{>{columncolor{Gray}}X}
newcommandcustomTable{
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}
}
newcommandcustomHeader[2]{
multicolumn{1}{|c|}{#2} &
multicolumn{1}{c|}{multirow{2}{*}{LARGE #1}}
}
newcommandemptyCells{
& ~~~ & & ~~~ & & ~~~ & & ~~~ & & ~~~ & & ~~~ & & ~~~ & & ~~~ & & ~~~ & & ~~~ & & ~~~ & ~~~ \
}
newcommandcustomBorder{%
hhline{|~|~|*{5}{>{arrayrulecolor{black}}-~|->{arrayrulecolor{Gray}}->{arrayrulecolor{black}}|}--}
}%
newcommandemptyDoubleCells{
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|}{} \
}
newcommandcustomRow[2]{
customHeader{#1}{#2}emptyCellscustomBorderemptyDoubleCells
}
begin{document}
pagenumbering{gobble}
customTable
customTable
end{document}
Correct answer by Bernard on January 19, 2021
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 hhline and cell color problems revisited
It is only necessary to raise the line a little.
In the above code, replace
newcommandemptyCells{
& ~~~ & & ~~~ & & ~~~ & & ~~~ & & ~~~ & & ~~~ & & ~~~ & & ~~~ & & ~~~ & & ~~~ & & ~~~ & ~~~ \
}
with
newcommandemptyCells{
& ~~~ & & ~~~ & & ~~~ & & ~~~ & & ~~~ & & ~~~ & & ~~~ & & ~~~ & & ~~~ & & ~~~ & & ~~~ & ~~~ \[-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.
Answered by Simon Dispa on January 19, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP