[Tex/LaTex] Creating a special table with different row lengths in latex

tablestabularx

How can I have a table like the following picture in latex?
enter image description here

Best Answer

A possible solution. I suggest not using the vertical lines, but rather the booktabs package. For horizontal alignment of 20 you can exploit the multirow package, while for vertically alignment you can compute the width of the largest entry of the first columns via the calc package.

enter image description here

\documentclass{article}
\usepackage{booktabs,calc,multirow}

\newlength\wdx% for vertical alignment
\setlength{\wdx}{\widthof{66}}

\begin{document}

\begin{table}
\centering
\addtolength{\tabcolsep}{10pt}% increase distance between cells 
\begin{tabular}{cccccc}
\toprule
\textsf{x} & \multicolumn{5}{c}{\textsf{y}}\\
\cmidrule(l{\wdx}r{\wdx}){1-1}\cmidrule(l){2-6}
10 & 22 & 33 \\
\multirow{2}[2]{\wdx}{20} & 45 & 34 & 88 & 77 & 80 \\
 & 34 & 67\\
66 & 12 & 10 & 45 & 66\\ 
\bottomrule
\end{tabular}
\end{table}

\end{document}
Related Question