我编写了这段代码,用空白行填充 tabularx 直到页面结束。它有效,但有一个问题:当要填充的空间少于一行时(例如 paperwidth=180pt),它会插入一行,并且可以预见的是,savepos 会“循环”,并且其标签在多次编译时不会停止更改。如何改进?
梅威瑟:
\documentclass{article}
\usepackage{tabularx}
\usepackage{zref-savepos}
\usepackage{calc}
\usepackage{geometry}
\newlength{\Start}
\newlength{\End}
\newlength{\Diff}
\newbox{\ParBox}
\geometry{paperheight=300pt,vmargin={0pt,0cm},hmargin={0cm,0cm},footskip=0pt,headsep=0pt,headheight=0pt}
\begin{document}
\setlength{\parindent}{0cm}
\setlength{\Start}{\zposy{start}sp}%
\setlength{\End}{\zposy{end}sp}%
\setlength{\Diff}{\Start-\End}
\savebox{\ParBox}{\parbox[t][\Diff]{2cm}{\mbox{}}}%
\begin{tabularx}{10cm}{|lXl|}\hline
. & start \the\Start{} - end \the\End & . \\
. & filled space \the\dp\ParBox & . \\
.&.&.\\
.&.&.\\
.&.&.\\
.&.&.\\
.&.&.\\
.&.&.\\
.&.&.\\
.&.&.\\
.&.&.\\
.&.&.\\
.&.&.\\
.&.&.\\
& \framebox{\usebox{\ParBox}} &\\
\hline
\end{tabularx}\par
\vspace*{-\Start}
\vspace*{-\End}
\zsaveposy{start}%
\vfill\zsaveposy{end}%
\end{document}
答案1
如果我理解正确的话,您只是想将最后一行延伸到页面底部:
\documentclass{article}
\usepackage{tabularx}
\usepackage{zref-savepos}
\usepackage{calc}
\usepackage{geometry}
\newbox{\ParBox}
\geometry{paperheight=350pt,vmargin={0pt,0cm},hmargin={0cm,0cm},footskip=0pt,headsep=0pt,headheight=0pt}
\begin{document}
\setlength{\parindent}{0cm}
\begin{tabularx}{10cm}{|lXl|}\hline
. & .& . \\
. & .& . \\
.&.&.\\
.&.&.\\
.&.&.\\
.&.&.\\
.&.&.\\
.&.&.\\
.&.&.\\
.&.&.\\
.&.&.\\
.&.&.\\
.&.&.\\
.&.&.\zsaveposy{start}\\[\zposy{start}sp]
\hline
\end{tabularx}
\end{document}