2

In the table below, when I set the row height, column width and the indentation as desired, the coloring of the rows breaks, leaving some "uncolored" areas (see example). How can I fix this (while keeping the row height and indentation)?
Thanks in advance for any help! P.S. The svmono class can be downloaded here.

Example:

\documentclass[graybox,envcountchap,vecarrow,twoside]{svmono}
\usepackage[paperheight=240mm,paperwidth=170mm,top=2.5cm,inner=2.5cm]{geometry}
\usepackage{newtxtext}
\usepackage{newtxmath}

% Units
\usepackage[detect-weight=true,detect-family=true,per-mode=symbol,detect-all=true]{siunitx}

% Tables
\usepackage{booktabs}
\usepackage{multirow}
\usepackage{multicol}
\usepackage{makecell}
\usepackage{xcolor,colortbl}
\definecolor{cellHighlightColor}{rgb}{0.933333333333333   0.956862745098039   0.984313725490196}
\renewcommand{\arraystretch}{1.2}

\begin{document}
\begin{table}[!ht]
\centering
\caption{Predicted occurrence of technological ``tipping points''}
\begin{small}
\begin{tabular}{@{\hspace{6pt}}p{1.25cm}p{9cm}}
\toprule
Year& \multicolumn{1}{c}{Technological tipping points}\\
\midrule
\rowcolor{cellHighlightColor}2022& 1 trillion sensors connected to the internet\\%S08
\rowcolor{cellHighlightColor}& \SI{10}{\percent} of people wearing clothes connected to the internet\\%S04
\rowcolor{cellHighlightColor}& The first 3D-printed car in production\\%S19
\midrule
2023& The first implantable mobile phone available commercially\\%S01
& The first government to replace its census with big-data sources\\%S11
& \SI{10}{\percent} of reading glasses connected to the internet\\%S03
& \SI{80}{\percent} of people with a digital presence on the internet\\%S02
& Tax collected for the first time by a government via a blockchain\\%S18
& \SI{90}{\percent} of the population using smartphones\\%S06
\midrule
\rowcolor{cellHighlightColor}2024& \SI{90}{\percent} of the population with regular access to the internet\\%S05
\rowcolor{cellHighlightColor}& The first transplant of a 3D-printed liver\\%S20
\rowcolor{cellHighlightColor}& Over \SI{50}{\percent} of internet traffic to homes for appliances and devices\\%S09
\midrule
2025& \SI{5}{\percent} of consumer products printed in 3D\\%S21
& \SI{30}{\percent} of corporate audits performed by AI\\%S14
& Globally more trips/journeys via car sharing than in private cars\\%S17
\midrule
\rowcolor{cellHighlightColor}2026& Driverless cars equalling \SI{10}{\percent} of all cars on US roads\\%S12
\rowcolor{cellHighlightColor}& The first AI machine on a corporate board of directors\\%S13
\rowcolor{cellHighlightColor}& The first city with more than 50,000 people and no traffic lights\\%S10
\midrule
2027& \SI{10}{\percent} of global gross domestic product stored on blockchain technology\\%S16
\bottomrule
\end{tabular}
\end{small}
\end{table}
\end{document} 

Actual Output: enter image description here

Desired Output: enter image description here

UPDATED example: Modified MWE with a possible fix to the missing coloring above and below the rules. Still looking for a solution to the indentation coloring issue!

\documentclass[graybox,envcountchap,vecarrow,twoside]{svmono}
\usepackage[paperheight=240mm,paperwidth=170mm,top=2.5cm,inner=2.5cm]{geometry}
\usepackage{newtxtext}
\usepackage{newtxmath}

% Units
\usepackage[detect-weight=true,detect-family=true,per-mode=symbol,detect-all=true]{siunitx}

% Tables
\usepackage{booktabs}
\usepackage{multirow}
\usepackage{multicol}
\usepackage{makecell}
\usepackage{xcolor,colortbl}
\definecolor{cellHighlightColor}{rgb}{0.933333333333333   0.956862745098039   0.984313725490196}
\renewcommand{\arraystretch}{1.2}

\newcommand{\midlineColoredAbove}{%
            \arrayrulecolor{cellHighlightColor}\specialrule{\aboverulesep}{0pt}{0pt}%
            \arrayrulecolor{black}\specialrule{\lightrulewidth}{0pt}{0pt}%
            \arrayrulecolor{white}\specialrule{\belowrulesep}{0pt}{0pt}%
            \arrayrulecolor{black}%
            }
\newcommand{\midlineColoredBelow}{%
            \arrayrulecolor{black}%
            \arrayrulecolor{white}\specialrule{\belowrulesep}{0pt}{0pt}%
            \arrayrulecolor{black}\specialrule{\lightrulewidth}{0pt}{0pt}%
            \arrayrulecolor{cellHighlightColor}\specialrule{\aboverulesep}{0pt}{0pt}%
            }


\begin{document}
\begin{table}[!ht]
\centering
\caption{Predicted occurrence of technological ``tipping points''}
\begin{small}
\begin{tabular}{@{\hspace{6pt}}p{1.25cm}p{9cm}}
\toprule
Year& \multicolumn{1}{c}{Technological tipping points}\\
%\midrule
\midlineColoredBelow
\rowcolor{cellHighlightColor}2022& 1 trillion sensors connected to the internet\\%S08
\rowcolor{cellHighlightColor}& \SI{10}{\percent} of people wearing clothes connected to the internet\\%S04
\rowcolor{cellHighlightColor}& The first 3D-printed car in production\\%S19
%\midrule
\midlineColoredAbove
2023& The first implantable mobile phone available commercially\\%S01
& The first government to replace its census with big-data sources\\%S11
& \SI{10}{\percent} of reading glasses connected to the internet\\%S03
& \SI{80}{\percent} of people with a digital presence on the internet\\%S02
& Tax collected for the first time by a government via a blockchain\\%S18
& \SI{90}{\percent} of the population using smartphones\\%S06
%\midrule
\midlineColoredBelow
\rowcolor{cellHighlightColor}2024& \SI{90}{\percent} of the population with regular access to the internet\\%S05
\rowcolor{cellHighlightColor}& The first transplant of a 3D-printed liver\\%S20
\rowcolor{cellHighlightColor}& Over \SI{50}{\percent} of internet traffic to homes for appliances and devices\\%S09
%\midrule
\midlineColoredAbove
2025& \SI{5}{\percent} of consumer products printed in 3D\\%S21
& \SI{30}{\percent} of corporate audits performed by AI\\%S14
& Globally more trips/journeys via car sharing than in private cars\\%S17
%\midrule
\midlineColoredBelow
\rowcolor{cellHighlightColor}2026& Driverless cars equalling \SI{10}{\percent} of all cars on US roads\\%S12
\rowcolor{cellHighlightColor}& The first AI machine on a corporate board of directors\\%S13
\rowcolor{cellHighlightColor}& The first city with more than 50,000 people and no traffic lights\\%S10
%\midrule
\midlineColoredAbove
2027& \SI{10}{\percent} of global gross domestic product stored on blockchain technology\\%S16
\bottomrule
\end{tabular}
\end{small}
\end{table}
\end{document} 

Output of UPDATED example:

enter image description here

5
  • 2
    This is because booktabs adds space around its rules.
    – Alan Munn
    Aug 19 '18 at 4:36
  • Thanks for the information, Alan! Following the post you mention I have been able to more or less solve the horizontal coloring (see updated example). Any idea on how I could solve the indentation coloring issue?
    – dontpanic
    Aug 19 '18 at 5:10
  • Remove the @{\hspace{6pt} from your tabular?
    – Alan Munn
    Aug 19 '18 at 5:15
  • Well, the idea is to have both the coloring and the indentation! ;)
    – dontpanic
    Aug 19 '18 at 5:17
  • the simplest way is not use @{\hspace{6pt}} in table columns' declaration.
    – Zarko
    Aug 19 '18 at 5:31
4

The svmono class sets the \tabcolsep to 1.5pt. If you set it to 6pt the indentation will be coloured correctly.

As Zarko points out, there are some other issues with the code (fixed below):

  • \small is not an environment, but a switch (Independently, the publisher is likely not to like changing the font size for a table; it's bad practice).
  • Instead of loading xcolor and colortbl you should load xcolor with the [table] option.

\documentclass[graybox,envcountchap,vecarrow,twoside]{svmono}
\usepackage[paperheight=240mm,paperwidth=170mm,top=2.5cm,inner=2.5cm]{geometry}
\usepackage{newtxtext}
\usepackage{newtxmath}

% Units
\usepackage[detect-weight=true,detect-family=true,per-mode=symbol,detect-all=true]{siunitx}

% Tables
\usepackage{booktabs}
\usepackage{multirow}
\usepackage{multicol}
\usepackage{makecell}
\usepackage[table]{xcolor} % changed here
\definecolor{cellHighlightColor}{rgb}{0.933333333333333   0.956862745098039   0.984313725490196}
\renewcommand{\arraystretch}{1.2}

\newcommand{\midlineColoredAbove}{%
            \arrayrulecolor{cellHighlightColor}\specialrule{\aboverulesep}{0pt}{0pt}%
            \arrayrulecolor{black}\specialrule{\lightrulewidth}{0pt}{0pt}%
            \arrayrulecolor{white}\specialrule{\belowrulesep}{0pt}{0pt}%
            \arrayrulecolor{black}%
            }
\newcommand{\midlineColoredBelow}{%
            \arrayrulecolor{black}%
            \arrayrulecolor{white}\specialrule{\belowrulesep}{0pt}{0pt}%
            \arrayrulecolor{black}\specialrule{\lightrulewidth}{0pt}{0pt}%
            \arrayrulecolor{cellHighlightColor}\specialrule{\aboverulesep}{0pt}{0pt}%
            }


\begin{document}
\begin{table}[!ht]
\setlength{\tabcolsep}{6pt}
\centering
\caption{Predicted occurrence of technological ``tipping points''}
\small
\begin{tabular}{@{\hspace{6pt}}p{1.25cm}p{9cm}}
\toprule
Year& \multicolumn{1}{c}{Technological tipping points}\\
%\midrule
\midlineColoredBelow
\rowcolor{cellHighlightColor}2022& 1 trillion sensors connected to the internet\\%S08
\rowcolor{cellHighlightColor}& \SI{10}{\percent} of people wearing clothes connected to the internet\\%S04
\rowcolor{cellHighlightColor}& The first 3D-printed car in production\\%S19
%\midrule
\midlineColoredAbove
2023& The first implantable mobile phone available commercially\\%S01
& The first government to replace its census with big-data sources\\%S11
& \SI{10}{\percent} of reading glasses connected to the internet\\%S03
& \SI{80}{\percent} of people with a digital presence on the internet\\%S02
& Tax collected for the first time by a government via a blockchain\\%S18
& \SI{90}{\percent} of the population using smartphones\\%S06
%\midrule
\midlineColoredBelow
\rowcolor{cellHighlightColor}2024& \SI{90}{\percent} of the population with regular access to the internet\\%S05
\rowcolor{cellHighlightColor}& The first transplant of a 3D-printed liver\\%S20
\rowcolor{cellHighlightColor}& Over \SI{50}{\percent} of internet traffic to homes for appliances and devices\\%S09
%\midrule
\midlineColoredAbove
2025& \SI{5}{\percent} of consumer products printed in 3D\\%S21
& \SI{30}{\percent} of corporate audits performed by AI\\%S14
& Globally more trips/journeys via car sharing than in private cars\\%S17
%\midrule
\midlineColoredBelow
\rowcolor{cellHighlightColor}2026& Driverless cars equalling \SI{10}{\percent} of all cars on US roads\\%S12
\rowcolor{cellHighlightColor}& The first AI machine on a corporate board of directors\\%S13
\rowcolor{cellHighlightColor}& The first city with more than 50,000 people and no traffic lights\\%S10
%\midrule
\midlineColoredAbove
2027& \SI{10}{\percent} of global gross domestic product stored on blockchain technology\\%S16
\bottomrule
\end{tabular}
\end{table}
\end{document} 

output of code

3
  • off-topic: instead of \usepackage{xcolor, colortbl} i would use \usepackage[table]{xcolor} . \small is not environment but command, so i would replace \begin{small} with \small and delete \end{small}.
    – Zarko
    Aug 19 '18 at 5:44
  • @Zarko Yes, I didn't look at the rest of the code very carefully.
    – Alan Munn
    Aug 19 '18 at 5:46
  • Thanks so much for the solution, Alan, it achieves the desired result! Thanks also for the other corrections, and thanks to Zarko, as well! :)
    – dontpanic
    Aug 19 '18 at 20:48
1

I propose a simpler code, solving the colour indentation problem with the optional arguments of \rowcolor, which set the colour overhang on the left and on the right. Also, since we have p types columns, I sugest making a single row for each year. Last, I have no more white strips at the top and bottom of coloured cells, setting the rules padding of booktabs to 0pt, and replacing it with the minimal top and bottom padding that we can define with package cellspace, for cells in columns with specifier prefixed with the letter S (or C if one loads siunitx).

Unrelated: Are you sure 15 decimal digits are necessary to define a colour? ;–)

\documentclass[graybox,envcountchap,vecarrow,twoside]{svmono}
\usepackage[paperheight=240mm,paperwidth=170mm,top=2.5cm,inner=2.5cm]{geometry}
\usepackage{newtxtext}
\usepackage{newtxmath}

% Units
\usepackage[detect-weight=true,detect-family=true,per-mode=symbol,detect-all=true]{siunitx}

% Tables
\usepackage{booktabs}
\usepackage{multirow}
\usepackage{multicol}
\usepackage{makecell, cellspace}
\usepackage[table]{xcolor}
\definecolor{cellHighlightColor}{rgb}{0.933333333333333 0.956862745098039 0.984313725490196}
\renewcommand{\arraystretch}{1.2}

\newcommand*\nl{\newline}

\begin{document}

\begin{table}[!ht]
\centering
\setlength{\aboverulesep}{0pt}
\setlength{\belowrulesep}{0pt}
\setlength{\cellspacetoplimit}{3pt}
\setlength{\cellspacebottomlimit}{3pt}
\caption{Predicted occurrence of technological ``tipping points''}
\small
\begin{tabular}{@{\hspace{6pt}}p{1.25cm}C{p{9cm}}}
\toprule
Year& \multicolumn{1}{c}{Technological tipping points}\\
\midrule
\rowcolor{cellHighlightColor}[6pt][1.5pt]2022 & 1 trillion sensors connected to the internet\nl%S08
 \SI{10}{\percent} of people wearing clothes connected to the internet\nl%S04
 The first 3D-printed car in production\\%S19
\midrule
2023 & The first implantable mobile phone available commercially\nl%S01
 The first government to replace its census with big-data sources\nl%S11
 \SI{10}{\percent} of reading glasses connected to the internet\nl%S03
 \SI{80}{\percent} of people with a digital presence on the internet\nl%S02
 Tax collected for the first time by a government via a blockchain\nl%S18
 \SI{90}{\percent} of the population using smartphones\\%S06
\midrule
\rowcolor{cellHighlightColor}[6pt][1.5pt] 2024 & \SI{90}{\percent} of the population with regular access to the internet\nl%S05
The first transplant of a 3D-printed liver\nl%S20
Over \SI{50}{\percent} of internet traffic to homes for appliances and devices\\%S09
\midrule
2025& \SI{5}{\percent} of consumer products printed in 3D\nl%S21
 \SI{30}{\percent} of corporate audits performed by AI\nl%S14
 Globally more trips/journeys via car sharing than in private cars\\%S17
\midrule
\rowcolor{cellHighlightColor}[6pt][1.5pt] 2026 & Driverless cars equalling \SI{10}{\percent} of all cars on US roads\nl%S12
The first AI machine on a corporate board of directors\nl%S13
The first city with more than 50,000 people and no traffic lights\\%S10
\midrule
2027& \SI{10}{\percent} of global gross domestic product stored on blockchain technology\\%S16
\bottomrule
\end{tabular}
\end{table}

\end{document} 

enter image description here

1
  • Thanks so much for this solution, Bernard! It is really simple, indeed! It kind of alters the vertical spacings, but now it does provide an alternative way to solve the issue. Thanks!
    – dontpanic
    Aug 19 '18 at 20:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.