0

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} \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}{#2} & \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{#1}{#2}\emptyCells\customBorder\emptyDoubleCells } \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?

5
  • Why letter as document class? Commented Jul 1, 2017 at 12:05
  • @ChristianHupfer no reason. What do you suggest? Commented Jul 1, 2017 at 12:09
  • article? Unless you're writing a letter, of course. Are the borders there when you zoom in? \usepackage[table]{xcolor} is recommended, by the way. Commented Jul 1, 2017 at 13:09
  • I found why I use letter. It's for the margins. I don't see borders while zooming in. Commented Jul 1, 2017 at 13:21
  • @A.D. Use the geometry package in order to change margins etc. The letter class is meant for, you guess it, letters and their special typography. Commented Jul 1, 2017 at 14:02

2 Answers 2

2

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} \newcommand\mycline{\hhline{|~*{23}{|-}}} \setlength{\extrarowheight}{14pt} \definecolor{Gray}{gray}{0.85} \newcolumntype{g}{>{\columncolor{Gray}}c} \newcolumntype{G}{>{\columncolor{Gray}}X} \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|}{#2} & \multicolumn{1}{c|}{\multirow{2}{*}{\LARGE #1}} } \newcommand\emptyCells{ & ~~~ & & ~~~ & & ~~~ & & ~~~ & & ~~~ & & ~~~ & & ~~~ & & ~~~ & & ~~~ & & ~~~ & & ~~~ & ~~~ \\ } \newcommand\customBorder{% \hhline{|~|~|*{5}{>{\arrayrulecolor{black}}-~|->{\arrayrulecolor{Gray}}->{\arrayrulecolor{black}}|}--} }% \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{#1}{#2}\emptyCells\customBorder\emptyDoubleCells } \begin{document} \pagenumbering{gobble} \customTable \customTable \end{document} 

enter image description here

3
  • You're the man. I've seen about hhline but wasn't sure how to use it. Could you add some explanations on how it works? Commented Jul 1, 2017 at 22:02
  • I'll add some words, but you should take a look at the (rather short) documentation of hhline and also of colortbl, more specifically § 9, More fun with hhline. Commented Jul 1, 2017 at 22:09
  • Wow! great explanation Commented Jul 1, 2017 at 22:51
1

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

\newcommand\emptyCells{ & ~~~ & & ~~~ & & ~~~ & & ~~~ & & ~~~ & & ~~~ & & ~~~ & & ~~~ & & ~~~ & & ~~~ & & ~~~ & ~~~ \\ } 

with

 \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 original

With the modified code no white lines!

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.