Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I am currently trying to make an invoice from a template which requires a table to extend to the end of the page regardless of the content. I tried using \fill as below (in \tabularnewline[\fill]), but instead of extending the row height to the end of the page, it does nothing. Is there some way to extend the table, as you'd naively expect this code to? I've the majority of the formatting in as I'm not sure if they would interfere with any possible solution.

\documentclass{article}
\usepackage{array}

\begin{document}
Front matter (name, address, etc.)

\noindent
\begin{tabular}{|>{\raggedright}p{0.2\linewidth}|>{\raggedright}p{0.3\linewidth}|>{\raggedright}p{0.3\linewidth}|>{\raggedright}p{0.2\linewidth}|}\hline
    Quantity & Description & Unit Price & Amount \tabularnewline\hline
     &  &  & \tabularnewline[\fill]\hline
    \multicolumn{2}{>{\raggedright}p{0.4\linewidth}|}{Bank Details} & Total & \tabularnewline\cline{3-4}
\end{tabular}
\end{document}

The not expanded table

share|improve this question
    
You need to find the position of the element you want to extend and then insert a strut. See tex.stackexchange.com/a/10345/963. I would rather redesign the invoice two parts and insert \vfill between them. What about if the invoice is longer than a page? –  Yiannis Lazarides Jan 29 '13 at 14:44
add comment

1 Answer

up vote 4 down vote accepted

enter image description here

The tabular spacing is inside (several) boxes so does not stretch, just as \mbox{\hfill} will always have width 0pt. However you can measure the output position and add a suitable fixed length. This takes a couple of latex runs and is _unstable) as written: if you edit the file you may have to delete the aux file otherwise it will always try to force an inappropriate size based on the old version of the file.

\documentclass{article}
\usepackage{array}


\begin{document}
Front matter (name, address, etc.)

a
\vspace{1in}

\noindent
\begin{tabular}{|>{\raggedright}p{0.2\linewidth}|>{\raggedright}p{0.3\linewidth}|>{\raggedright}p{0.3\linewidth}|>{\raggedright}p{0.2\linewidth}|}\hline
    Quantity & Description & Unit Price & Amount \tabularnewline\hline
\makeatletter\pdfsavepos\write\@auxout{\gdef\string\tmppos{\the\pdflastypos}}%
\ifx\tmppos\@undefined\gdef\tmpheight{0pt}\else\gdef\tmpheight{\dimexpr\tmppos sp - 190pt\relax}\fi
     &  &  & \tabularnewline[\tmpheight]\hline
    \multicolumn{2}{>{\raggedright}p{0.4\linewidth}|}{Bank Details} & Total & \tabularnewline\cline{3-4}
\end{tabular}

\end{document}
share|improve this answer
    
Just curious, why is there no \makeatother in this solution. Is it not always needed? –  Nathanael Farley Jan 30 '13 at 8:03
1  
Actually it's virtually never needed \makeatother stops you using @ in command names in the main document but when testing and debugging code with @ in, preventing yourself from doing that isn't always a good idea. Of course when you've finished debugging it's good style to close the door after you but if you don't you have to try quite hard to find a (natural) construct where things fail. –  David Carlisle Jan 30 '13 at 9:26
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.