I don't want to use nested tables. My current code produces the following result.
And I want to get the following output.
And the minimal working example:
\documentclass{article}
\usepackage[a4paper,margin=1cm,showframe]{geometry}
\usepackage{array,multirow,longtable}
\parindent=0pt
\arrayrulewidth=1pt\relax
\tabcolsep=5pt\relax
\newcolumntype{A}[2]{%
>{\minipage{\dimexpr#1\linewidth-2\tabcolsep-#2\arrayrulewidth\relax}\vspace\tabcolsep}%
c<{\vspace\tabcolsep\endminipage}}
\newcommand\x{\centering$\displaystyle\int f(x)\,\textrm{d}x=F(x)+C$}
\begin{document}
\begin{longtable}{
|A{0.2}{1.5} % 0.2 of \linewidth, 1.5 of \arrayrulewidth
|A{0.5}{1} % 0.5 of \linewidth, 1 of \arrayrulewidth
|A{0.3}{1.5} % 0.3 of \linewidth, 1.5 of \arrayrulewidth
|}\hline
%%%%%%%%%%%%%%% FIRST ROW %%%%%%%%%%%%%%%
\x & \multicolumn{2}{
A{0.8}{1.5} % 0.8 of \linewidth, 1.5 of \arrayrulewidth
|}{\x} \tabularnewline\hline
%%%%%%%%%%%%%%% SECOND ROW %%%%%%%%%%%%%%%
\multicolumn{2}{
|A{0.7}{1.5} % 0.7 of \linewidth, 1.5 of \arrayrulewidth
|}{\multirow{2}{*}{\x}} &
\x \tabularnewline\cline{3-3}
%%%%%%%%%%%%%%% THIRD ROW %%%%%%%%%%%%%%%
\multicolumn{2}{
|A{0.7}{1.5} % 0.7 of \linewdith, 1.5 of \arrayrulewidth
|}{} &
\x \tabularnewline\hline
\end{longtable}
\end{document}
How to vertically center a content spanning multiple rows without using nested tables?
I have tried all answers (excluding Aditya's answer) and all don't vertically center the cell spanning multiple rows. Please kindly recheck your answer, or I might be wrong. 🙂
Best Answer
the package
ltablex
is available on CTAN: http://www.ctan.org/tex-archive/macros/latex/contrib/ltablex Three X columns must give 3X when you want to have different columns widths: 0.6+1.5+0.9=3 For the 2nd and 3rd row you have 2X+1X=3X