填充单元格中的垂直空白区域

填充单元格中的垂直空白区域

我正在尝试填充同一行中另一个具有更高高度的单元格所留下的空间。

\documentclass[a4paper]{report}
\usepackage{longtable}
\begin{document}
\begin{longtable}{|p{0.3\linewidth}|p{0.3\linewidth}|}
\hline \textbf{Original Contract} & \textbf{Modification} \\
\hline
\endfirsthead
\hline \textbf{Original Contract} & \textbf{Modification} \\
\hline
\endhead

8.7 This is some contractual boring text that people read literally &
8.7 This is a modification of the boring text that people also read literally. This is new text without usefull information. \\
8.8 This is some contractual boring very very very very very very very very very very very very long text that people read literally &
8.8 This is a modification of the very long text. \\
\hline
\end{longtable}
\end{document}

例子

类似颜色,或者用点或线填充第 1 列中“..literally”和“8.8 This..”之间的空格,以及第 2 列中“..long text.”和表格末尾之间的空格。

我尝试使用、、\rule和,但只填满了第一行...有什么想法吗?\vspace\vfill\hrulefill

答案1

但是,手动解决方案可以提供帮助!

\documentclass[a4paper]{report}
\usepackage{longtable,array}
\begin{document}
\begin{longtable}{|p{0.3\linewidth}|p{0.3\linewidth}|}
\hline \textbf{Original Contract} & \textbf{Modification} \\
\hline
\endfirsthead
\hline \textbf{Original Contract} & \textbf{Modification} \\
\hline
\endhead

8.7 This is some contractual boring text that people read literally \dotfill\par\dotfill\par\dotfill\par &
8.7 This is a modification of the boring text that people also read literally. This is new text without usefull information. \\
8.8 This is some contractual boring very very very very very very very very very very very very long text that people read literally &
8.8 This is a modification of the very long text. \dotfill\par\dotfill\par\dotfill\par\dotfill\par\dotfill\par\\
\hline
\end{longtable}
\end{document}

在此处输入图片描述

这是通过添加多个\dotfill\pars 直到两个单元格的高度相同来完成的。par如果您不需要单元格底部的额外空间,则可以删除最后一个。当然,这不是一个自动解决方案,但当单元格内容发生变化时,它几乎不需要任何努力。

答案2

这里有一个选项,使用一些标记tikzmark库来绘制填充矩形(元素需要运行两到三次才能到达最终位置):

\documentclass[a4paper]{report}
\usepackage{longtable}
\usepackage{tikz}
\usetikzlibrary{tikzmark}

\begin{document}

\begin{longtable}{|p{0.3\linewidth}|p{0.3\linewidth}|}
\hline \textbf{Original Contract} & \textbf{Modification} \\
\hline
\endfirsthead
\hline \textbf{Original Contract} & \textbf{Modification} \\
\hline
\endhead

\begin{tikzpicture}[remember picture,overlay]
\fill[gray!30]
  ([yshift=-3pt]{{pic cs:enda}|-{pic cs:starta}}) 
    rectangle 
  ([yshift=10pt]{{pic cs:middlea}|-{pic cs:enda}});
\fill[gray!30]
  ([yshift=-3pt]{pic cs:middleb}) 
    rectangle 
  ({{pic cs:endb}|-{pic cs:startb}});
\end{tikzpicture}

8.7 This is some contractual boring text that people read literally\tikzmark{starta}\hfill\tikzmark{middlea} &
8.7 This is a modification of the boring text that people also read literally. This is new text without usefull information. \\
\tikzmark{enda}8.8 This is some contractual boring very very very very very very very very very very very very long text that people read literally\tikzmark{startb} &
8.8 This is a modification of the very long \tikzmark{endb}text.\hfill\tikzmark{middleb} \\
\hline
\end{longtable}

\end{document}

在此处输入图片描述

相关内容