# [OS X TeX] Loop in tabular environment

Ross Moore ross at ics.mq.edu.au
Sat Apr 17 09:15:37 EDT 2004

Hi Œistein

On 17/04/2004, at 10:34 PM, Œistein Andersen wrote:

> A possibility is to create the table using \vbox’es rather than a
> specific LaTeX environment. This seems to solve my problem, as the
> table itself is quite simple, but rather long (about 40 pages, so I
> would have had to use supertabular or something of the like). However,
> I have (re)discovered a ‘feature’ which I do not quite understand. In
> the following piece of code, the \vbox’es (or rather \vtop’s, but that
> changes nothing) line up horizontally:
>
> \hsize=12cm
> \hfil
> \vtop{\hsize = 4cm 1st LINE\\ 2nd LINE}%
> \vtop{\hsize = 4cm TEXT}%
> \vtop{\hsize = 4cm TEXT}
>
> Here, the \hfil will have zero width. However, if I remove the \hfil
> (and put nothing before the first \vbox), the \vbox’es will stack
> vertically. Could anyone explain the logic behind this behaviour?

\vbox, \vtop, \hbox
all create boxes, but do not say how the boxes will stack.
The 'v' or 'h' refers to the way things stack *inside* the box,
and say nothing about how the box itself fits with surrounding
boxes.

Normally when you start collecting material for a page,
or for paragraphs, the "mode" is *vertical*,
so that things stack vertically.
(This is what happens in your example, when you don't
have the \hfil .)

Various things switch automatically to "horizontal" mode:

1.  a simple letter or symbol, starting a word
2.  \hskip, \hglue, \hfil
3.  \leavevmode, \indent, \noindent
4.  being inside an \hbox
5.  maybe a few other things... (consult the TeXbook)

> (A \hfil is not always a good idea, either.)

>
> Thank you for your help.

Hopefully this clarifies the situation for you.

Best regards,

Ross

>
> --
> Øistein Andersen
>
------------------------------------------------------------------------
Ross Moore                                         ross at maths.mq.edu.au
Mathematics Department                             office: E7A-419
Macquarie University                               tel: +61 +2 9850 8955
Sydney, Australia                                  fax: +61 +2 9850 8114
------------------------------------------------------------------------

-----------------------------------------------------