如何垂直合并由 \parbox 创建的单元格

如何垂直合并由 \parbox 创建的单元格
\documentclass[a4paper]{article}
\usepackage{xcolor,pgf,etoolbox}
\usepackage{geometry}
\geometry{showframe}
\geometry{left=1cm,right=1cm,top=1cm,bottom=1cm}
\parindent0pt
\begin{document}
\fboxsep0pt
\sbox0{\parbox{1in}{a\\a\\a\\a\\a\\a\\a}}
\fbox{\parbox{1in}{a\\a\\a\\a\\a\\a\\a}}%the first \parbox
\fbox{\parbox[c][\dimexpr \ht0+\dp0]{1in}{\offinterlineskip%the second \parbox
    \fbox{\parbox{1in}{a\\a\\a}}\\%the third \parbox
    \fbox{\parbox{1in}{a\\a}}\\%the fouth \parbox
    \fbox{\parbox{1in}{a}}%the fifth \parbox
  }}
\par

My question: How to fully fill the second \verb|\parbox| in vertical direction by the third, the fourth, and the fifth \verb|\parbox|s so that they have the same height with the first \verb|\parbox|?(seem like to merge cells vertically)
\vskip 3em

Another question: How to eliminate the "gap" as shown on the attatched figure 2?
\fboxsep0pt
\sbox0{\parbox{1in}{a\\a\\a\\a\\a\\a\\a}}
\fbox{\parbox[c]{1in}{a\\a\\a\\a\\a\\a\\a}}%the first \parbox
\fbox{\parbox[c][\dimexpr \ht0+\dp0][t]{1in}{%the second \parbox
    \parbox{1in}{a\\a\\a}\hrule%the third \parbox
    \parbox{1in}{a\\a\\}\hrule%the fouth \parbox
    \colorbox{green}{\parbox{1in}{a\vfill\smash{\mbox{}}}}%the fifth \parbox
  }}
\end{document}

在此处输入图片描述

在此处输入图片描述

答案1

正如评论中提到的:

\documentclass[a4paper]{article} 
\usepackage{multirow,
            tabularray} 
\parindent0pt  

\begin{document} 
\section*{First question}
\begin{tabular}{|*{2}{p{1em}|}}     
    \hline 
\multirow{8}{=}{a a a a a a a}     
    &           \\     \cline{2-2}     
    & a a a     \\     \cline{2-2}
    & a a       \\     \cline{2-2}
    & a         \\     \cline{2-2}
    &           \\
    \hline 
\end{tabular} 

\section*{Second question}
\begin{tblr}{hlines, vlines,
             colspec={*{2}{Q[l,wd=1em]}},
             }
\SetCell[r=3]{l}    a a a a a a a   
    &   a a a       \\ 
    &   a a         \\
    &   a           \\
\end{tblr}
\end{document}

在此处输入图片描述

第二个例子也可以用来解决tabular,但比较棘手。更简单的方法是使用tabularray包,就像上面的 MWE 中所做的那样。

用同样的方法tabularray也可以解决第一个问题,但是结果有点不同:

\begin{tblr}{hlines, vlines,
             colspec={*{2}{Q[l,wd=1em]}},
             rowsep=0pt
             }
\SetCell[r=5]{l}    a a a a a a a
    &           \\     
    & a a a     \\     
    & a a       \\     
    & a         \\     
    &           \\
\end{tblr} 

在此处输入图片描述

相关内容