# How to use the equivalent of a vfill in a tabular environment?

I have a table with two columns and one row. The first one is long and determines the overall height of the table (if need be it can be fixed to \textheight). In the second column I have two images. I would like one of them to be aligned to the top of the first column and the other to the second - an effect similar to a \vfill on a normal page - see example below.

The \vfill doesn't seem to work, presumably because the table's height is not defined when that column is set?

I have tried:

1. Calculating the remaining space on the page using the \measurepage macro from this question and inserting this using \vspace - unfortunately this seems to produce lengths much greater than the real available space

2. putting in a 0 width (invisible) rule of \textheight to fix the column height and then using \raisebox to move the column contents back up. (this fails miserably)

Is there another way of

Here is a minimal example

%% LyX 2.0.3 created this file.  For more info, see http://www.lyx.org/.
%% Do not edit unless you really know what you are doing.
\documentclass[10pt,a4paper,oneside,english,oldfontcommands,a4paper]{memoir}
\usepackage{fontspec}
\setcounter{secnumdepth}{2}
\setcounter{tocdepth}{2}

\makeatletter

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% LyX specific LaTeX commands.
\pdfpageheight\paperheight
\pdfpagewidth\paperwidth

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% User specified LaTeX commands.
%packages
\usepackage{calc}
\usepackage{graphicx}
\usepackage{xcolor}
\usepackage{colortbl}
\usepackage{multirow}
\usepackage{lipsum}

\newcommand\measurepage{\dimexpr\pagegoal-\pagetotal-\baselineskip\relax}

\makeatother

\usepackage{babel}
\begin{document}
\renewcommand{\tabularxcolumn}[1]{m{#1}}

\noindent\begin{tabularx}{\linewidth}{@{}X|p{0.2\linewidth}@{}}

\rule{\TX@col@width}{\textheight-\baselineskip}

&
\begingroup\rule{\linewidth}{0.15\textheight} \newline Some text \vfill \rule{\linewidth}{0.15\textheight}\endgroup \tabularnewline

\end{tabularx}

\end{document}


Edit:

Here is a picture showing what I am trying to acheive. Two column table, the left one determines the overall height. The two images on the right should be aligned with the top and bottom of the content of the left column. There will be some text between these images in the right column, of variable length.

So far I can get the images either bottom aligned or top aligned, but not one at the top and one at the bottom.

-
I don't have lyx installed (unable to compile). However I would try using the minipage environment. Then you can use \vspace* –  R. Schumacher Mar 26 '12 at 14:20
It is a bit unclear what you want to achieve. Could you make a picture? (Measuring the page is certainly not the way to go). –  Ulrike Fischer Mar 26 '12 at 14:24

It seems simpler to do this without a tabular environment and just use the minipage environment. Below I used the showframe package to display the location of the margins:

\documentclass{memoir}

\usepackage[demo]{graphicx}
\usepackage{showframe}

\newcommand{\DesiredHeight}{10.0cm}%
\begin{document}
\noindent
\begin{minipage}[b][\DesiredHeight]{0.8\linewidth}
\includegraphics[height=\DesiredHeight, width=0.8\textwidth]{leftImage}
\end{minipage}%
\begin{minipage}[b][\DesiredHeight]{0.2\linewidth}\noindent
\includegraphics[width=\linewidth]{topImage}
\par\noindent
Some text and some more text.
\vfill
\includegraphics[width=\linewidth]{bottomImage}
\end{minipage}%
\end{document}

-
Excellent, thank you. Works perfectly. You don't know how many hours I spent trying to make this work... –  user8786 Mar 26 '12 at 19:47
\documentclass{memoir}
\usepackage{calc}
\usepackage{tabularx}
\renewcommand{\tabularxcolumn}[1]{m{#1}}

\begin{document}
\noindent
\begin{tabularx}{\linewidth}{@{} X | p{0.2\linewidth} @{} }
\rule{\linewidth}{\textheight-\baselineskip}
&\vspace*{-3pt}%%%%%
\parbox[s][\textheight-\baselineskip]{\linewidth}{%
\rule{\linewidth}{0.15\textheight} \\
Some text \par\vfill
\rule{\linewidth}{0.15\textheight}} \tabularnewline
\end{tabularx}

\end{document}


-
Hi Herbert, This is great. There is a small difference in alignment between the small and big rules though, presumably due to "padding" inside the parbox? Is there a variable for that space that I can include into the calculation of the parbox dimensions? –  user8786 Mar 26 '12 at 19:38
@user8786: see my edit (%%%%). It is a hack, because I have no real time for a closer look. –  Herbert Mar 26 '12 at 19:57
Thanks. I worked out that putting the contents of the first column in a parbox as well sorts it so they have identical spacing. –  user8786 Mar 26 '12 at 20:34