在 tabularx 环境中,当 multicol 中的内容超过一行时,如何添加垂直行间距?

在 tabularx 环境中,当 multicol 中的内容超过一行时,如何添加垂直行间距?

我正在尝试使用 xltabular 环境手动添加垂直行间距。但是当我尝试使用 multicol 编写一个长达 2 或 3 行的段落时,我手动添加垂直空间的方法不起作用,并且我的条目中的间距不均匀。有什么解决方案吗?

\begin{center}

    \begin{xltabular}{\textwidth}{|@{}>{\hsize=.6\hsize}X| >{\raggedleft\arraybackslash\hsize=.4\hsize}X@{}|} 

        \hline
        \textbf{Entry 1} & {Entry 2} \\[10pt] \hline
        {Entry 3} & {Entry 4} \\[10pt]  \hline
        \multicolumn{2}{|@{}X|}{
        This is a long paragraph, which spans over more than two lines to highlight the problem which I am facing} \\[10pt]
        
        \hline
        \textbf{Entry 5} & {Entry 6} \\[10pt] \hline
        {Entry 7} & {Entry 8} \\[10pt] \hline
        \multicolumn{2}{|@{}X|}
        {This is a long paragraph, which spans over more than two lines to highlight the problem which I am facing} \\[10pt]
        \hline
        

    \end{xltabular}

\end{center}

在此处输入图片描述

答案1

我建议您插入“底部”印刷支柱以实现您的格式化目标。

在此处输入图片描述

\documentclass{article}
\usepackage{xltabular}
\usepackage{ragged2e} % for \RaggedRight and \RaggedLeft macros
% Create a "bottom strut" with a default depth of 14pt
\newcommand\Bstrut[1][14pt]{\rule[-#1]{0pt}{0pt}} 

\begin{document}

\begin{center}
\setlength\tabcolsep{1pt} % default: 6pt
\begin{xltabular}{\textwidth}{| 
      >{\RaggedRight\hsize=0.6\hsize}X | 
      >{\RaggedLeft\hsize =0.4\hsize}X |} 
  \hline
  \textbf{Entry 1} & Entry 2\Bstrut \\  \hline
  Entry 3          & Entry 4\Bstrut \\  \hline
  \multicolumn{2}{|>{\RaggedRight}X|}{%
  This is a long paragraph, which spans two or more lines 
  to highlight the problem which I am facing.\Bstrut} \\
  \hline
  \textbf{Entry 5} & Entry 6\Bstrut \\  \hline
  Entry 7          & Entry 8\Bstrut \\  \hline
  \multicolumn{2}{|>{\RaggedRight}X|}{%
  This is a long paragraph, which spans two or more lines 
  to highlight the problem which I am facing. 
  This is a long paragraph, which spans two or more lines 
  to highlight the problem which I am facing.
  This is a long paragraph, which spans two or more lines 
  to highlight the problem which I am facing.\Bstrut[28pt]} \\ % override the default
  \hline
\end{xltabular}
\end{center}

\end{document}

答案2

我不确定是否理解了您的确切需要,但tabularray您可以设置一行的上方和下方空间(如果您愿意,甚至可以对任何行采用不同的方式)。

\documentclass{article}
\usepackage{tabularray}

\begin{document}
\begin{longtblr}[
  caption={My table}
  ]{
  width=\textwidth, colspec={XX[r]},
  hlines, vlines,
  hspan=minimal,
  abovesep=6pt,
  belowsep=10pt
  } 
  \textbf{Entry 1} & Entry 2 \\  
  Entry 3 & Entry 4 \\ 
  \SetCell[c=2]{j} This is a long paragraph, which spans two or more lines 
  to highlight the problem which I am facing. \\
  \textbf{Entry 5} & Entry 6 \\  
  Entry 7 & Entry 8 \\  
  \SetCell[c=2]{j} This is a long paragraph, which spans two or more lines 
  to highlight the problem which I am facing. 
  This is a long paragraph, which spans two or more lines 
  to highlight the problem which I am facing.
  This is a long paragraph, which spans two or more lines 
  to highlight the problem which I am facing. & n\\
\end{longtblr}
\end{document}

在此处输入图片描述

相关内容