# Color in a multirow cell with extra vertical space

I am using colortbl and booktabs to make the following table with tcolorbox

\documentclass{standalone}
\usepackage[utf8]{inputenc}
\usepackage[many]{tcolorbox}
\usepackage{booktabs}
\usepackage{colortbl}
\usepackage{multirow}

\tcbset{
enhanced,
title=Factorización,
colbacktitle=black,
coltitle=white,
fonttitle=\sffamily\bfseries\Large,
attach boxed title to top right={yshift=-8pt},
boxed title style={
enhanced,
boxrule=0.4mm,
frame code={ \path[tcb fill frame,black] (frame.south west) -- ([yshift=-7pt]frame.north west) -- ([xshift=7pt]frame.north west) -- (frame.north east) -- ([yshift=7pt]frame.south east) -- ([xshift=-7pt]frame.south east);},
interior code={ \path[tcb fill interior,black!75] (interior.south west) -- ([yshift=-7pt]interior.north west) -- ([xshift=7pt]interior.north west) -- (interior.north east) -- ([yshift=7pt]interior.south east) -- ([xshift=-7pt]interior.south east);} },
leftrule=0mm,
toprule=0mm,
colframe=black,
colback=white,
coltext=black,
arc=0pt,
boxsep=0mm,
left=0mm,
right=0mm,
bottom=0mm,
width=12cm,
}

\usepackage{array}
\newcolumntype{P}[1]{>{\centering\arraybackslash}p{#1}}

\renewcommand{\familydefault}{\sfdefault}

\begin{document}

\begin{tcolorbox}
\begin{tabular}{
>{\columncolor{gray!50}}P{5cm}|
P{7cm}
}
& $a^{2}+2ab+b^{2}=(a+b)^{2}$ \\
\multirow{2}{*}[12pt]{Trinomio cuadrado perfecto} & $a^{2}-2ab+b^{2}=(a-b)^{2}$ \\
\hline
Diferencia de cuadrados & $a^{2}-b^{2}=(a+b)(a-b)$ \\
\hline
Suma de cubos & $a^{3}+b^{3}=(a+b)(a^{2}-ab+b^{2})$ \\
\hline
Diferencia de cubos & $a^{3}-b^{3}=(a-b)(a^{2}+ab+b^{2})$ \\
\end{tabular}
\end{tcolorbox}

\end{document}


Maybe I am very picky but you can see that the exponents in the second, third and fourth row are touching the \hline so in order to solve this I add extra vertical space using \addlinespace in each row but unfortunately I get this

with this code

\begin{tcolorbox}
\begin{tabular}{
>{\columncolor{gray!50}}P{5cm}|
M{7cm}
}
& $a^{2}+2ab+b^{2}=(a+b)^{2}$ \\
\multirow{2}{*}[12pt]{Trinomio cuadrado perfecto} & $a^{2}-2ab+b^{2}=(a-b)^{2}$ \\
\hline
Diferencia de cuadrados & $a^{2}-b^{2}=(a+b)(a-b)$ \\
\hline
Suma de cubos & $a^{3}+b^{3}=(a+b)(a^{2}-ab+b^{2})$ \\
\hline
Diferencia de cubos & $a^{3}-b^{3}=(a-b)(a^{2}+ab+b^{2})$ \\
\end{tabular}
\end{tcolorbox}


How can I solve this vertical and color issue.

• Problematic is not multirow but use of \addlinespace from booktabs. For possible solution see my answer below. – Zarko Dec 16 '15 at 21:58
• That's the way I want the table the problem now is that I get this error Package minted Error: You must have 'pygmentize' installed to use this package. \begin{document} How can I solve this? I've seen all the similars answers to my problem but nothing works – Very23 Dec 16 '15 at 22:01
• Ah, minted .. i have similar problem width it, unfortunately I didn't solve the problem myself ... I need to ask my system administrator, how he managed this problem. Since I'm temporary abroad, I can't ask him for help. I'm sure, that in SE is somewhere answer how to install it. If you cannot find, just ask new question about it. – Zarko Dec 16 '15 at 22:12
• Ok I'll ask a question about it. is there a way to get what a I want without using minted??? – Very23 Dec 16 '15 at 22:33
• Minted is based/use python, and here is problem. Yes, it is posible, I hope that I will upgrade my answer with (less elegant) solutuion. Anyway, for use all capability of tcolorbox, mdframed, coloring of listings is good idea to install python and activate minted is worth of effort. – Zarko Dec 16 '15 at 22:40

Do you looking for something like this:

For above image I omit package booktabs, for more space above equations I use a trick $\vskip-1ex$ but main point is use tabularx capability of tcolorbox:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[dvipsname,table]{xcolor}
\usepackage{array,tabularx}
\usepackage[all]{tcolorbox}
\usepackage{minted}

\newcolumntype{P}[1]{>{\raggedright\arraybackslash}m{#1}}

\begin{document}
\tcbset{enhanced,
colbacktitle=black, coltitle=white,
fonttitle=\sffamily\bfseries\Large,
attach boxed title to top right={yshift=-4pt},
boxed title style={enhanced,
boxrule=0.4mm,
frame code = {\path[tcb fill frame,black]
(frame.south west) -- ([yshift=-7pt]frame.north west) --
([xshift=7pt]frame.north west) -- (frame.north east) --
([yshift=7pt]frame.south east) -- ([xshift=-7pt]frame.south east);},
interior code ={\path[tcb fill interior,black!75]
(interior.south west) -- ([yshift=-7pt]interior.north west) -- ([xshift=7pt]interior.north west) -- (interior.north east) -- ([yshift=7pt]interior.south east) -- ([xshift=-7pt]interior.south east);}
},
leftrule=0mm,toprule=0mm,
colframe=black,colback=white,coltext=black,
arc=0pt,
boxsep=0mm,
left=0mm,right=0mm,bottom=0mm,
width=12cm,
tabularx={>{\columncolor{gray!30}}X | >{$}P{66mm}<{$}},
}
\begin{tcolorbox}[title=Factorización]\sffamily
Trinomio cuadrado perfecto  &   $\vskip -1ex$
a^{2}+2ab+b^{2}=(a+b)^{2} \newline
a^{2}-2ab+b^{2}=(a-b)^{2}           \\
\hline
\hline
Suma de cubos               &   a^{3}+b^{3}=(a+b)(a^{2}-ab+b^{2})   \\
\hline
Diferencia de cubos         &   a^{3}-b^{3}=(a-b)(a^{2}+ab+b^{2})
%    \hline
\end{tcolorbox}
\end{document}


Upgrade: Less elegant possible solution, which not required installed python and minted package:

\documentclass[border=3mm]{standalone}
\usepackage[utf8]{inputenc}
\usepackage[many]{tcolorbox}
\usepackage{colortbl}

\tcbset{enhanced,
top=0pt,
boxrule=0.4mm,
%
colbacktitle=black,coltitle=white,
fonttitle=\sffamily\bfseries\Large,
attach boxed title to top right={yshift=-8pt},
boxed title style = {enhanced,
frame code={\path[tcb fill frame,black]
(frame.south west) -- ([yshift=-7pt]frame.north west) -- ([xshift=7pt]frame.north west) -- (frame.north east) -- ([yshift=7pt]frame.south east) -- ([xshift=-7pt]frame.south east);},
interior code={\path[tcb fill interior,black!75]
(interior.south west) -- ([yshift=-7pt]interior.north west) -- ([xshift=7pt]interior.north west) -- (interior.north east) -- ([yshift=7pt]interior.south east) -- ([xshift=-7pt]interior.south east);} },
leftrule=0.4mm,
toprule=0.4mm,
colframe=black,colback=white,coltext=black,
arc=0pt,
boxsep=0mm,
left=0mm,right=0mm,bottom=0mm,width=12cm,
}

\usepackage{array}
\newcolumntype{P}[1]{>{\raggedright\arraybackslash}m{#1}}
\newcommand\rspace{\rule[-5pt]{0pt}{15pt}}
\begin{document}
\begin{tcolorbox}[title=Factorización]\sffamily
\begin{tabular}{>{\columncolor{gray!50}}P{5cm}|>{$}P{6.1cm}<{$}}
Trinomio cuadrado perfecto  &   $\vskip-0.5ex$
a^{2}+2ab+b^{2}=(a+b)^{2}   \newline
a^{2}-2ab+b^{2}=(a-b)^{2}           \\
\hline
\hline
Suma de cubos               &   a^{3}+b^{3}=(a+b)(a^{2}-ab+b^{2})   \rspace\\
\hline
Diferencia de cubos         &   a^{3}-b^{3}=(a-b)(a^{2}+ab+b^{2})   \rspace\\
\end{tabular}
\end{tcolorbox}
\end{document}


It gives the same result as before. However it require more manual adjusting.

• Thanks @Zarko I will use the second one right now but I like to use the first code you gave It will be OK if I ask about this problem with minted? I've been looking similar answers and no one seems to work – Very23 Dec 17 '15 at 4:55
• Recently I didn't search on SE about python, minted ... on SE but I have in memory, that I found here instruction, how to install this. On the end it was simple (words of system administrator, who did this for me). – Zarko Dec 17 '15 at 9:00
• About minted see tex.stackexchange.com/questions/237075/minted-not-working. In answer are instruction, what too do, that it will works. – Zarko Dec 17 '15 at 9:14