[Tex/LaTex] table overflow page

multicolumnmultirowtablestabularxwidth

I created a table with https://www.tablesgenerator.com/latex_tables

I tried to limit the column width with
|l| p{1cm} |p{2cm} |p{1cm} |p{1cm} |p{2cm} |p{1cm} |p{1cm}|
But it doesn't see to have any effect.

The generated table

\begin{table}[]
\begin{tabular}{llllllll}
\hline
\multicolumn{1}{|l|}{}                           & \multicolumn{1}{l|}{Compute}                                      & \multicolumn{1}{l|}{Pay As  You Go}                                  & \multicolumn{1}{l|}{}                                                & \multicolumn{1}{l|}{Storage}                                      & \multicolumn{1}{l|}{Pay As  You Go}                     & \multicolumn{1}{l|}{}                               & \multicolumn{1}{l|}{Trail}                          \\ \cline{2-3} \cline{5-6} \cline{8-8} 
\multicolumn{1}{|l|}{\multirow{-2}{*}{Provider}} & \multicolumn{1}{l|}{Terminology}                                  & \multicolumn{1}{l|}{Unit}                                            & \multicolumn{1}{l|}{\multirow{-2}{*}{Other Plans*}}                  & \multicolumn{1}{l|}{Terminology}                                  & \multicolumn{1}{l|}{Unit}                               & \multicolumn{1}{l|}{\multirow{-2}{*}{Other Plans*}} & \multicolumn{1}{l|}{Period or Value}                \\ \hline
\multicolumn{1}{|l|}{Windows Azure}              & \multicolumn{1}{l|}{\cellcolor[HTML]{9AFF99}Virtual Server}       & \multicolumn{1}{l|}{\cellcolor[HTML]{9AFF99}/hr}                     & \multicolumn{1}{l|}{\cellcolor[HTML]{9AFF99}1}                       & \multicolumn{1}{l|}{\cellcolor[HTML]{9AFF99}Azure Storage}        & \multicolumn{1}{l|}{\cellcolor[HTML]{9AFF99}/GB  month} & \multicolumn{1}{l|}{\cellcolor[HTML]{9AFF99}1}      & \multicolumn{1}{l|}{\cellcolor[HTML]{9AFF99}90 day} \\ \hline
\end{tabular}
\end{table}

After I removed \multicolumn, I got errors for
\multirow{-2}{p{1cm}}{Other Plans*}

 main.tex, line 37
Missing number, treated as zero.

<to be read again> 
                   p
l.37 ...    & \multirow{-2}{p{1 cm}}{Other Plans*}
                                                                    & Termin...
A number should have been here; I inserted `0'.
(If you can't figure out why I needed to see a number,
look up `weird error' in the index to The TeXbook.)

! Illegal unit of measure (pt inserted).
<to be read again> 
                   p
l.37 ...    & \multirow{-2}{p{1 cm}}{Other Plans*}
                                                                    & Termin...
Dimensions can be in units of em, ex, in, pt, pc,
cm, mm, dd, cc, nd, nc, bp, or sp; but yours is a new one!

See page 2 of the full example
https://www.overleaf.com/read/ywhjzprxmrgj

Best Answer

A couple of possibilities which don't generate an overfull \hbox with a standard article documentclass:

\documentclass{article}
\usepackage{array}
\renewcommand{\arraystretch}{2}
\usepackage{multirow}
\usepackage[table]{xcolor}
\usepackage{makecell}

\begin{document}
\begin{table}\scriptsize\centering
\begin{tabular}{llllllll}
\hline
& Compute & \makecell[l]{Pay As\\ You Go} & & Storage & \makecell[l]{Pay As\\ You Go} &  & Trail \\ 
\cline{2-3} \cline{5-6} \cline{8-8} 
\multirow{-2}{*}{Provider} & Terminology & Unit & \multirow{-2}{*}{\makecell[l]{Other\\ Plans*}} & Terminology & Unit  & \multirow{-2}{*}{\makecell[l]{Other\\ Plans*}} & \makecell[l]{Period\\ or Value} \\ 
\hline
\makecell[l]{Windows\\ Azure} & \cellcolor[HTML]{9AFF99}{\renewcommand{\arraystretch}{1}\begin{tabular}{@{}l@{}}Virtual\\ Server\end{tabular}} & \cellcolor[HTML]{9AFF99}/hr & \cellcolor[HTML]{9AFF99}1 & \cellcolor[HTML]{9AFF99}{\renewcommand{\arraystretch}{1}\begin{tabular}{@{}l@{}}Azure\\Storage\end{tabular}}  & \cellcolor[HTML]{9AFF99}{\renewcommand{\arraystretch}{1}\begin{tabular}{@{}l@{}}/GB\\month\end{tabular}} & \cellcolor[HTML]{9AFF99}1 & \cellcolor[HTML]{9AFF99}90 day \\ 
\hline
\end{tabular}
\end{table}
\begin{table}\tiny\centering
\begin{tabular}{|l|l|l|l|l|l|l|l|}
\hline
& Compute & \makecell[l]{Pay As\\ You Go} & & Storage & \makecell[l]{Pay As\\ You Go} &  & Trail \\ 
\cline{2-3} \cline{5-6} \cline{8-8} 
\multirow{-2}{*}{Provider} & Terminology & Unit & \multirow{-2}{*}{\makecell[l]{Other\\ Plans*}} & Terminology & Unit  & \multirow{-2}{*}{\makecell[l]{Other\\ Plans*}} & \makecell[l]{Period\\ or Value} \\ 
\hline
\makecell[l]{Windows\\ Azure} & \cellcolor[HTML]{9AFF99}{\renewcommand{\arraystretch}{1}\begin{tabular}{@{}l@{}}Virtual\\ Server\end{tabular}} & \cellcolor[HTML]{9AFF99}/hr & \cellcolor[HTML]{9AFF99}1 & \cellcolor[HTML]{9AFF99}{\renewcommand{\arraystretch}{1}\begin{tabular}{@{}l@{}}Azure\\Storage\end{tabular}}  & \cellcolor[HTML]{9AFF99}{\renewcommand{\arraystretch}{1}\begin{tabular}{@{}l@{}}/GB\\month\end{tabular}} & \cellcolor[HTML]{9AFF99}1 & \cellcolor[HTML]{9AFF99}90 day \\ 
\hline
\end{tabular}
\end{table}
\end{document}

Please note that, for colored cells, I've used an appropriate tabular instead of \makecell.

I prefer the first, without vertical rules:

enter image description here

enter image description here

Related Question