GeneralTop-aligned parboxes with rules

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
jazzgossen
Posts: 26
Joined: Mon Mar 09, 2009 3:19 pm

Top-aligned parboxes with rules

Post by jazzgossen »

I'm trying to make am index page for a binder with some articles in it. The output should be something like

Code: Select all

article 1       |
bibentry stuff  |
                |

article 2       |
much bibentry   |
stuff           |

article 3       |
                |
                |
In essence, I want a table with fixed row heights (45 mm) and the text at the top of each cell. I tried to make some parboxes with a rule that pushes the box to the right height, but I can't get them to align at the top.

The following example shows my problem. As it stands, it looks as I want it to (except that the line of Is should be replaced by a rule). But if the (now commented) rule is used instead, the boxes don't align at the top anymore.

Why is this?

Code: Select all

\documentclass{report}
\begin{document}

\parbox[t]{76ex}{
  a little bit of reference text a little bit of reference text a
  little bit of reference text a little bit of reference text a little
  bit of reference text a little bit of reference text a little bit of
  reference text a little bit of reference text
}
\parbox[t]{2mm}{
  %\rule{1mm}{45mm}
  I I I I I I I I I I I I I I 
}

\end{document}

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Top-aligned parboxes with rules

Post by gmedina »

Hi,

perhaps you could use a tabular environment and define a new command to achieve the desired result. Please, take a look at the following example:

Code: Select all

\documentclass{report}
\usepackage{array}

\newcommand\mybox[1]{%
  \setlength\tabcolsep{0pt}%
  \noindent\begin{tabular}{p{78ex}>{\centering}p{3mm}}
  #1 & \rule[-43mm]{1mm}{45mm}
  \end{tabular}\vspace*{2em}}

\begin{document}

\mybox{a little bit of reference text a little bit of reference text a little
bit of reference text a little bit of reference text a little bit of reference
text a little bit of reference text a little bit of reference text a little
bit of reference text}

\mybox{some other little bit of reference text reference text reference text
reference text reference text reference text reference text reference text
reference text}

\end{document}
Of course, adapt my example to suit your needs.
1,1,2,3,5,8,13,21,34,55,89,144,233,...
Post Reply