[Tex/LaTex] Align text at the bottom of the table cell

table of contentstablestabularx

I need to create table of content in a table format with text wrapping in the subject titles. The page number is currently at the top of each cell. In the rows where the title is wrapped, I need the page number aligned at the bottom. This is my code:

\begin{tabularx}{\linewidth}{ l X l }

  Figure & & Page \\

  1.1.1  &  test text text  text  text  text  text  text  text  text  text  text  text  text  text  text  text  text  text  \dotfill &  10 \\
  1.1.2 & line \dotfill & 12 \\

\end{tabularx}

Best Answer

This may be the solution you are looking for, although it is a bit clumsy. You have to include array package to get option b{} for table alignement.

\documentclass{article}
\usepackage{array}

\begin{document}

\begin{tabular}{b{0.1\linewidth}b{0.8\linewidth}p{0.1\linewidth}}

  Figure & & Page \\

  1.1.1 & test text text  text  text  text  text  text  text  text  text  text  text  text  text  text  text  text  text  \dotfill & 10 \\
  1.1.2 & line \dotfill & 12 \\
  1.1.3  &  a lot of text text text text text text text text text text text text text text text text  text  text  text  text  text  text  text  text  text  text  text  text  text  text  text  text  \dotfill &  15 \\

\end{tabular}

\end{document}

The thing you have to do is compile the code above, and look for the lines, where the middle column is on multiple lines:

First compilation

Then insert \newline after the Figure number, so it will move up a line. So in this case the table will look like:

\begin{tabular}{b{0.1\linewidth}b{0.8\linewidth}p{0.1\linewidth}}

  Figure & & Page \\

  1.1.1\newline & test text text  text  text  text  text  text  text  text  text  text  text  text  text  text  text  text  text  \dotfill & 10 \\
  1.1.2 & line \dotfill & 12 \\
  1.1.3\newline\newline  &  a lot of text text text text text text text text text text text text text text text text  text  text  text  text  text  text  text  text  text  text  text  text  text  text  text  text  \dotfill &  15 \\

\end{tabular}

And the final result:

Final

Related Question