5

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}
Bordaigorl
  • 15,135
Hussain
  • 53
  • Welcome to the site. It helps those trying to help you if you post a complete Minimum Working Example (MWE), starting with \documentclass and ending with \end{document}. – Steven B. Segletes Sep 27 '14 at 12:17
  • See http://tex.stackexchange.com/questions/116225/vertical-alignment-top-center-bottom-of-figure-and-two-texts-in-tabular – John Kormylo Sep 27 '14 at 13:15
  • You need to know how high the X column entry is, which you could do with a \parbox the same width, but you don't know what the width is/will be with tabularx. – John Kormylo Sep 27 '14 at 13:21

3 Answers3

3

table with page numbers

\documentclass{article}
\usepackage{tabularx}

\newcommand\DotsPage [1]{\dotfill\rlap{\kern2\tabcolsep #1}&}

\begin{document}
\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\DotsPage{10}\\
  1.1.2 & line test text text  text  text  text  text  text  text  text  text
  text  text  text  text  text  text  text  text\DotsPage {12}\\
  1.1.3 & line for comparison\dotfill & 13 
\end{tabularx}
\end{document}
1

Such things are almost always better set as a list than as a table, here just using enumerate but you may want a custom list format (enumitem package might help)

enter image description here

\documentclass{article}

\begin{document}
\def\Dotfill{{\def\hfill{\hskip4em plus 1fill}\dotfill}}



\begin{enumerate}

  \item[1.1.1] test text text  text  text  text  text  text  text  text  text  text  text  text  text  text  text  text  text  \Dotfill  10 
  \item[1.1.2] line \Dotfill  12 
\end{enumerate}

\end{document}
David Carlisle
  • 757,742
1

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

Václav Pavlík
  • 1,353
  • 11
  • 18