I need to create a summary table for a talk. The idea is to have cells with different colours. However, I do not manage to make the colours fill for one cell. Here is a small example of my problem.
Code
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{xcolor}
\usepackage{color, colortbl}
%% How to color the cells
\newcommand{\ResultCell}[1]{%
\cellcolor{red!10}\textcolor{red}{#1}%
}
\newcommand{\SetPackingCell}[1]{%
\cellcolor{blue!10}\textcolor{blue}{#1}%
}
\begin{document}
\begin{table}[]
\begin{tabular}{c|c|c}
& VTT & VTS \\\hline
\begin{tabular}[c]{@{}c@{}}
Approximation\\
ratio
\end{tabular}
& \begin{tabular}[c]{@{}c@{}}
\SetPackingCell{$(4/3+\varepsilon)$}\\
\ResultCell{APX-hard}
\end{tabular}
& \begin{tabular}[c]{@{}c@{}}
\SetPackingCell{$(4/3+\varepsilon)$}\\
\ResultCell{APX-hard}\\
\ResultCell{$(1+\frac{6}{s-1})$}
\end{tabular}
\\\hline
Kernel
& \begin{tabular}[c]{@{}c@{}}
\SetPackingCell{$O(k^{1.5})$-V}\\
\ResultCell{$O(f)$}\\
\ResultCell{no $O(N^{2-\varepsilon})$-bits}
\end{tabular}
& \ResultCell{$O(k)$-V}
\end{tabular}
\end{table}
\end{document}
As you can notice, there is a cell with a bad colour-filling. The goal would be to have something like this
How could I fix this? I tried with multirow, etc.. but nothing worked so far.
Thank you in advance!
Edit - Personal (and ugly) solution
I managed to fix the problem with a multirow based from an answer of user11232, and some ugly phantom text...
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{xcolor}
\usepackage{color, colortbl}
\usepackage{multirow} % https://www.ctan.org/pkg/multirow
%% How to color the cells
\newcommand{\ResultCell}[1]{%
\cellcolor{red!10}\textcolor{red}{#1}%
}
\newcommand{\SetPackingCell}[1]{%
\cellcolor{blue!10}\textcolor{blue}{#1}%
}
\begin{document}
\begin{table}[]
\begin{tabular}{c|c|c}
& VTT & VTS \\\hline
\begin{tabular}[c]{@{}c@{}}
Approximation\\
ratio
\end{tabular}
& \begin{tabular}[c]{@{}c@{}}
\SetPackingCell{$(4/3+\varepsilon)$}\\
\ResultCell{\phantom{iiino $\O(N^{2-\varepsilon})$ bits}}\\%adding some i's to fix the tiny remaining spaces... Better solution ?
\multirow{-2}{*}{\ResultCell{APX-hard}}\\
\end{tabular}
& \begin{tabular}[c]{@{}c@{}}
\SetPackingCell{$(4/3+\varepsilon)$}\\
\ResultCell{APX-hard}\\
\ResultCell{$(1+\frac{6}{s-1})$}
\end{tabular}
\\\hline
Kernel
& \begin{tabular}[c]{@{}c@{}}
\SetPackingCell{$O(k^{1.5})$-V}\\
\ResultCell{$O(f)$}\\
\ResultCell{no $O(N^{2-\varepsilon})$-bits}
\end{tabular}
& \ResultCell{$O(k)$-V}
\end{tabular}
\end{table}
\end{document}
This code gives the following output.
I hope it will be useful, even if I am highly not convinced by my solution. I am pretty sure there is a nicer way to fix my problem, but at least it does the job...






adjustboxon atabularsince this will make the font sizes in your document inconsistent. – leandriis Oct 27 '19 at 11:36