0

Tables again. I want to color several rows in the table and use colortbl package. Everything works fine. Now I want to add extra gap between the first and the second column to make the table more legible. I do it in the way of adding @{\hspace{20pt}} in the table preamble. Works fine and adds what I want. BUT! It also adds that gap in the color stripe of the table.

How to add the gap but still have the color row in one piece?

(the actual color was changed to make it more visual)

MWE:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{euler, beton}
\usepackage{booktabs}
\usepackage{array}
\usepackage{color, colortbl}
\usepackage{multirow}
%============================================================
\definecolor{LightCyan}{rgb}{0.88,1,1}
\begin{document}
\begin{tabular}{@{}r@{\hspace{20pt}}*{3}{l@{\enspace}l}l@{\enspace}l@{\enspace}lp{1cm}>{\centering\arraybackslash}p{1cm}}
\toprule
\multirow{3}{*}{\#}&\multicolumn{6}{c}{\small Results}&\multicolumn{3}{c}{Scores}& \multirow{3}{*}{\parbox{1.2cm}{All Diff\textsuperscript{nt}?}}&\multirow{3}{*}{\parbox{1.5cm}{Draws}}\\
\cmidrule(r){2-7}
\cmidrule(lr){8-10}
&\multicolumn{2}{c}{1}&\multicolumn{2}{c}{2}&\multicolumn{2}{c}{3}&\multirow{2}{*}{A}&\multirow{2}{*}{B}&\multirow{2}{*}{C}\\ 
\cmidrule(r){2-3}
\cmidrule(lr){4-5}
\cmidrule(lr){6-7}
&A&B&B&C&C&A\\
\midrule
1  &    0  &    2  &    0 & 2 & 0 & 2 & 2 & 2 & 2 & No &    - \\
2  &    0  &    2  &    0 & 2 & 1 & 1 & 1 & 2 & 3 & Yes &   1 \\
3  &    0  &    2  &    1 & 1 & 0 & 2 & 2 & 3 & 1 & Yes &   1 \\
4  &    1  &    1  &    0 & 2 & 0 & 2 & 3 & 1 & 2 & Yes &   1 \\
5  &    0  &    2  &    0 & 2 & 2 & 0 & 0 & 2 & 4 & Yes &   0 \\
6  &    0  &    2  &    2 & 0 & 0 & 2 & 2 & 4 & 0 & Yes &   0 \\
7  &    2  &    0  &    0 & 2 & 0 & 2 & 4 & 0 & 2 & Yes &   0 \\\rowcolor{LightCyan}
8  &    0  &    2  &    1 & 1 & 1 & 1 & 1 & 3 & 2 & Yes &   2 \\\rowcolor{LightCyan}
9  &    1  &    1  &    0 & 2 & 1 & 1 & 2 & 1 & 3 & Yes &   2 \\\rowcolor{LightCyan}
10 &    1  &    1  &    1 & 1 & 0 & 2 & 3 & 2 & 1 & Yes &   2 \\
11 &    0  &    2  &    2 & 0 & 2 & 0 & 0 & 4 & 2 & Yes &   0 \\
12 &    2  &    0  &    2 & 0 & 0 & 2 & 4 & 2 & 0 & Yes &   0 \\
13 &    2  &    0  &    0 & 2 & 2 & 0 & 2 & 0 & 4 & Yes &   0 \\
14 &    1  &    1  &    1 & 1 & 1 & 1 & 2 & 2 & 2 & No &- \\
15 &    2  &    0  &    2 & 0 & 2 & 0 & 2 & 2 & 2 & No &- \\\rowcolor{LightCyan}
16 &    2  &    0  &    1 & 1 & 1 & 1 & 3 & 1 & 2 & Yes &   2 \\\rowcolor{LightCyan}
17 &    1  &    1  &    2 & 0 & 1 & 1 & 2 & 3 & 1 & Yes &   2 \\\rowcolor{LightCyan}
18 &    1  &    1  &    1 & 1 & 2 & 0 & 1 & 2 & 3 & Yes &   2 \\
19 &    1  &    1  &    2 & 0 & 2 & 0 & 1 & 3 & 2 & Yes &   1 \\
20 &    2  &    0  &    1 & 1 & 2 & 0 & 2 & 1 & 3 & Yes &   1 \\
21 &    2  &    0  &    2 & 0 & 1 & 1 & 3 & 2 & 1 & Yes &   1 \\
22 &    0  &    2  &    1 & 1 & 2 & 0 & 0 & 3 & 3 & No &1 \\
23 &    0  &    2  &    2 & 0 & 1 & 1 & 1 & 4 & 1 & No &1 \\
24 &    1  &    1  &    0 & 2 & 2 & 0 & 1 & 1 & 4 & No &1 \\
25 &    1  &    1  &    2 & 0 & 0 & 2 & 3 & 3 & 0 & No &1 \\
26 &    2  &    0  &    0 & 2 & 1 & 1 & 3 & 0 & 3 & No &1 \\
27 &    2  &    0  &    1 & 1 & 0 & 2 & 4 & 1 & 1 & No &1 \\
\bottomrule
\end{tabular}

\end{document}

enter image description here

5
  • @John Kormylo, I tried this. The first column becomes wider (as expected), but the gap is still there. Commented Feb 28, 2020 at 14:46
  • I did. Same thing. I think @{} is about trimming the very left side of the table, It looks like p{} is about the width only. Although, my question is about filling the gap. I thought colortbl is supposed to take care of it Commented Feb 28, 2020 at 15:00
  • If I remove it the color stripe is obviously in one piece - colortbl works fine. But I think I need that gap because otherwise the table is not that legible (in my opinion). Commented Feb 28, 2020 at 15:31
  • Your LightCyan colour looks a bit weird…
    – Bernard
    Commented Feb 28, 2020 at 15:37
  • @Bernard, maybe. I changed it into red to make it more visual - this is not the most important part Commented Feb 28, 2020 at 15:47

2 Answers 2

0

You can simply add an empty column between the first and the second column – not forgetting to shift the \cmidrules:

\documentclass{article}
\usepackage[utf8]{inputenc}
%\usepackage{euler, beton}
\usepackage{booktabs}
\usepackage{array}
\usepackage{color, colortbl}
\usepackage{multirow}
%============================================================
\definecolor{LightCyan}{rgb}{0.88,1,1}
\begin{document}
%\begin{tabular}{@{}r@{\hspace{20pt}}*{3}{l@{\enspace}l}l@{\enspace}l@{\enspace}lp{1cm}>{\centering\arraybackslash}p{1cm}}
\begin{tabular}{@{}rc*{3}{l@{\enspace}l}l@{\enspace}l@{\enspace}lp{1cm}>{\centering\arraybackslash}p{1cm}}
\toprule
\multirow{3}{*}{\#}& & \multicolumn{6}{c}{\small Results}&\multicolumn{3}{c}{Scores}& \multirow{3}{*}{\parbox{1.2cm}{All Diff\textsuperscript{nt}?}}&\multirow{3}{*}{\parbox{1.5cm}{Draws}}\\
\cmidrule(r){3-8}
\cmidrule(lr){9-11}
 & &\multicolumn{2}{c}{1}&\multicolumn{2}{c}{2}&\multicolumn{2}{c}{3}&\multirow{2}{*}{A}&\multirow{2}{*}{B}&\multirow{2}{*}{C}\\
\cmidrule(r){3-4}
\cmidrule(lr){5-6}
\cmidrule(lr){7-8}
& & A&B&B&C&C&A\\
\midrule
1 & & 0 & 2 & 0 & 2 & 0 & 2 & 2 & 2 & 2 & No & - \\
2 & & 0 & 2 & 0 & 2 & 1 & 1 & 1 & 2 & 3 & Yes & 1 \\
3 & & 0 & 2 & 1 & 1 & 0 & 2 & 2 & 3 & 1 & Yes & 1 \\
4 & & 1 & 1 & 0 & 2 & 0 & 2 & 3 & 1 & 2 & Yes & 1 \\
5 & & 0 & 2 & 0 & 2 & 2 & 0 & 0 & 2 & 4 & Yes & 0 \\
6 & & 0 & 2 & 2 & 0 & 0 & 2 & 2 & 4 & 0 & Yes & 0 \\
7 & & 2 & 0 & 0 & 2 & 0 & 2 & 4 & 0 & 2 & Yes & 0 \\\rowcolor{LightCyan}
8 & & 0 & 2 & 1 & 1 & 1 & 1 & 1 & 3 & 2 & Yes & 2 \\\rowcolor{LightCyan}
9 & & 1 & 1 & 0 & 2 & 1 & 1 & 2 & 1 & 3 & Yes & 2 \\\rowcolor{LightCyan}
10 & & 1 & 1 & 1 & 1 & 0 & 2 & 3 & 2 & 1 & Yes & 2 \\
11 & & 0 & 2 & 2 & 0 & 2 & 0 & 0 & 4 & 2 & Yes & 0 \\
12 & & 2 & 0 & 2 & 0 & 0 & 2 & 4 & 2 & 0 & Yes & 0 \\
13 & & 2 & 0 & 0 & 2 & 2 & 0 & 2 & 0 & 4 & Yes & 0 \\
14 & & 1 & 1 & 1 & 1 & 1 & 1 & 2 & 2 & 2 & No &- \\
15 & & 2 & 0 & 2 & 0 & 2 & 0 & 2 & 2 & 2 & No &- \\\rowcolor{LightCyan}
16 & & 2 & 0 & 1 & 1 & 1 & 1 & 3 & 1 & 2 & Yes & 2 \\\rowcolor{LightCyan}
17 & & 1 & 1 & 2 & 0 & 1 & 1 & 2 & 3 & 1 & Yes & 2 \\\rowcolor{LightCyan}
18 & & 1 & 1 & 1 & 1 & 2 & 0 & 1 & 2 & 3 & Yes & 2 \\
19 & & 1 & 1 & 2 & 0 & 2 & 0 & 1 & 3 & 2 & Yes & 1 \\
20 & & 2 & 0 & 1 & 1 & 2 & 0 & 2 & 1 & 3 & Yes & 1 \\
21 & & 2 & 0 & 2 & 0 & 1 & 1 & 3 & 2 & 1 & Yes & 1 \\
22 & & 0 & 2 & 1 & 1 & 2 & 0 & 0 & 3 & 3 & No &1 \\
23 & & 0 & 2 & 2 & 0 & 1 & 1 & 1 & 4 & 1 & No &1 \\
24 & & 1 & 1 & 0 & 2 & 2 & 0 & 1 & 1 & 4 & No &1 \\
25 & & 1 & 1 & 2 & 0 & 0 & 2 & 3 & 3 & 0 & No &1 \\
26 & & 2 & 0 & 0 & 2 & 1 & 1 & 3 & 0 & 3 & No &1 \\
27 & & 2 & 0 & 1 & 1 & 0 & 2 & 4 & 1 & 1 & No &1 \\
\bottomrule
\end{tabular}

\end{document} 

enter image description here

1

You can also add the spaces using <{...} instead of @{...}.

I believe there is an automatic overlap which is big enough for the \enspace but not the 20pt.

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{euler, beton}
\usepackage{booktabs}
\usepackage{array}
\usepackage{color, colortbl}
\usepackage{multirow}
%============================================================
\definecolor{LightCyan}{rgb}{0.88,1,1}
\begin{document}
\begin{tabular}{@{}r<{\hspace{20pt}}@{}*3{l<{\enspace}@{}l}l<{\enspace}@{}l<{\enspace}@{}lp{1cm}>{\centering\arraybackslash}p{1cm}}
\toprule
\multirow{3}{*}{\#}&\multicolumn{6}{c}{\small Results}&\multicolumn{3}{c}{Scores}& \multirow{3}{*}{\parbox{1.2cm}{All Diff\textsuperscript{nt}?}}&\multirow{3}{*}{\parbox{1.5cm}{Draws}}\\
\cmidrule(r){2-7}
\cmidrule(lr){8-10}
&\multicolumn{2}{c}{1}&\multicolumn{2}{c}{2}&\multicolumn{2}{c}{3}&\multirow{2}{*}{A}&\multirow{2}{*}{B}&\multirow{2}{*}{C}\\ 
\cmidrule(r){2-3}
\cmidrule(lr){4-5}
\cmidrule(lr){6-7}
&A&B&B&C&C&A\\
\midrule
1  &    0  &    2  &    0 & 2 & 0 & 2 & 2 & 2 & 2 & No &    - \\
2  &    0  &    2  &    0 & 2 & 1 & 1 & 1 & 2 & 3 & Yes &   1 \\
3  &    0  &    2  &    1 & 1 & 0 & 2 & 2 & 3 & 1 & Yes &   1 \\
4  &    1  &    1  &    0 & 2 & 0 & 2 & 3 & 1 & 2 & Yes &   1 \\
5  &    0  &    2  &    0 & 2 & 2 & 0 & 0 & 2 & 4 & Yes &   0 \\
6  &    0  &    2  &    2 & 0 & 0 & 2 & 2 & 4 & 0 & Yes &   0 \\
7  &    2  &    0  &    0 & 2 & 0 & 2 & 4 & 0 & 2 & Yes &   0 \\\rowcolor{LightCyan}
8  &    0  &    2  &    1 & 1 & 1 & 1 & 1 & 3 & 2 & Yes &   2 \\\rowcolor{LightCyan}
9  &    1  &    1  &    0 & 2 & 1 & 1 & 2 & 1 & 3 & Yes &   2 \\\rowcolor{LightCyan}
10 &    1  &    1  &    1 & 1 & 0 & 2 & 3 & 2 & 1 & Yes &   2 \\
11 &    0  &    2  &    2 & 0 & 2 & 0 & 0 & 4 & 2 & Yes &   0 \\
12 &    2  &    0  &    2 & 0 & 0 & 2 & 4 & 2 & 0 & Yes &   0 \\
13 &    2  &    0  &    0 & 2 & 2 & 0 & 2 & 0 & 4 & Yes &   0 \\
14 &    1  &    1  &    1 & 1 & 1 & 1 & 2 & 2 & 2 & No &- \\
15 &    2  &    0  &    2 & 0 & 2 & 0 & 2 & 2 & 2 & No &- \\\rowcolor{LightCyan}
16 &    2  &    0  &    1 & 1 & 1 & 1 & 3 & 1 & 2 & Yes &   2 \\\rowcolor{LightCyan}
17 &    1  &    1  &    2 & 0 & 1 & 1 & 2 & 3 & 1 & Yes &   2 \\\rowcolor{LightCyan}
18 &    1  &    1  &    1 & 1 & 2 & 0 & 1 & 2 & 3 & Yes &   2 \\
19 &    1  &    1  &    2 & 0 & 2 & 0 & 1 & 3 & 2 & Yes &   1 \\
20 &    2  &    0  &    1 & 1 & 2 & 0 & 2 & 1 & 3 & Yes &   1 \\
21 &    2  &    0  &    2 & 0 & 1 & 1 & 3 & 2 & 1 & Yes &   1 \\
22 &    0  &    2  &    1 & 1 & 2 & 0 & 0 & 3 & 3 & No &1 \\
23 &    0  &    2  &    2 & 0 & 1 & 1 & 1 & 4 & 1 & No &1 \\
24 &    1  &    1  &    0 & 2 & 2 & 0 & 1 & 1 & 4 & No &1 \\
25 &    1  &    1  &    2 & 0 & 0 & 2 & 3 & 3 & 0 & No &1 \\
26 &    2  &    0  &    0 & 2 & 1 & 1 & 3 & 0 & 3 & No &1 \\
27 &    2  &    0  &    1 & 1 & 0 & 2 & 4 & 1 & 1 & No &1 \\
\bottomrule
\end{tabular}

\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .