3

I wrote this code which fills a tabularx with blank lines until the end of the page. It worked but has one problem: When the space to fill is less than one line (e.g. paperwidth=180pt), it inserts one line, and predictably savepos "loops" and its labels don't stop changing when compiling multiple times. How can be improved?

MWE:

\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}
4
  • I'm sorry. I mean "fill the page" not "fit the page"! Thanks. Dec 11, 2013 at 18:40
  • you say you fill with blank tabularx lines, but as far as I can see you have a fixed tabularx table and then fill with an fbox around an empty parbox to the end of the page, I thought you had a loop extending the table adding more rows to the end, and what change exactly do we have to make to show the problem, add paperwidth=180pt to the geometry options? Dec 11, 2013 at 18:50
  • did you mean paperheight=180pt (not width) ??? Dec 11, 2013 at 18:52
  • Yes, sure; I'm sorry again, paperheight=180pt instead of 300pt to test the code trying to fill a space which is smaller than a line; or of course adding more dummy lines (10 in my example) to the tabularx has the same effect I wanted to show. Dec 11, 2013 at 19:22

1 Answer 1

3

If I understand correctly you just want to extend the final row to the bottom of the page:

enter image description here

\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}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .