Putting together TeX boxes

Putting together TeX boxes

Hi,

I am facted with the following problem: I have to vertical boxes
(\vbox) of different height. No I want to glue them together in a
horizontal box (\hbox) such that the top lienes of the two boxes are
on the same line (see figure below). Who can I do this, preferably in
plain TeX (but*is OK too)?

Figure

+----------------------------+ +-----------------+
|            Box 1           | |                 |
+----------------------------+ |      Box 2      |
|                 |
+-----------------+

Claude

-----------------------------------------------------------------------------
Claude G. Diderich                              PGP V2.3 public key available
Swiss Federal Institute of Technology, Lausanne -----------------------------
Department of Computer Science                  Fields of interest:
Computer Science Theory Laboratory              - Complexity theory
CH-1015 Lausanne (Switzerland - Europe)         - Combinatorial optimization
Phone: (021)/693-52-86                          - Parallel computations

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

Putting together TeX boxes

Some time ago I posted the following question to the TeX net.

Quote:> I am faced with the following problem: I have to vertical boxes
> (\vbox) of different height. No I want to glue them together in a
> horizontal box (\hbox) such that the top lienes of the two boxes are
> on the same line (see figure below). Who can I do this, preferably in
> plain TeX (but*is OK too)?

>                          Figure

> +----------------------------+ +-----------------+
> |            Box 1           | |                 |
> +----------------------------+ |      Box 2      |
>                                |                 |
>                                +-----------------+

Here are some of the repies I received:

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

If you want an easy*solution, try

\parbox[t]{3in}{ First box here } \hspace{ a little space if needed }%
\parbox[t]{3in}{ Second box here }\\
---------------------------------------------------------------------------

Did you try \hbox{\vtop{stuff}\vtop{stuff}} ?

\vbox aligns with the bottom baseline rather than the top.
---------------------------------------------------------------------------

\line{\vtop{ ... Box 1 ...}\hfill\vtop{... Box 2 ...}}

should do what you want: if the boxes are \vbox's their bottoms
are lined up, but if they are \vtop's their tops are aligned.
---------------------------------------------------------------------------

The best thing to do is use \vtop rather than \vbox.  \vtop is exactly
like \vbox, except the reference point is always one line from the top
of the box (off hand, I think it's really at the reference point of the
first box it encloses).  When I have this problem, I usually have text
in the \vboxes, so \vtop does what I want.

The second best thing is to use \setbox and fiddle with heights:

% first use the scratch boxes \box0 and \box2 to hold the
% contents of the two boxes in your figure
\setbox0=\vbox{<whatever's in Box 1>}
\setbox2=\vbox{<whatever's in Box 2>}
% then fiddle with the height of box 2
\skip2=\ht 2 % skip 2 has the height of box 2
\ht 2=\ht 0  % set height of box 2 to be the same as box 1
% and finally adjust the depth of box 2 to take up the
% slack.  We can't \advance \dp2 by \skip2, incidentally
\dp 2=\skip2
% you need to be careful that you don't do anything with
% \box0, \box2, or \skip2 while this is going on.  If in
% doubt, define registers with \newbox and \newskip
% oh -- assemble in an \hbox
\hbox{\box 0 \hskip 4 pt \box 2}

Hope this helps.
---------------------------------------------------------------------------

In fact only the last reply solved my problem. In fact the two boxes I want
to align contain figures. Therefore aligning on the top baseline doesn't
change the problem.

Claude

-----------------------------------------------------------------------------
Claude G. Diderich                              PGP V2.3 public key available
Swiss Federal Institute of Technology, Lausanne -----------------------------
Department of Computer Science                  Fields of interest:
Computer Science Theory Laboratory              - Complexity theory
CH-1015 Lausanne (Switzerland - Europe)         - Combinatorial optimization
Phone: (021)/693-52-86                          - Parallel computations

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

In summary: I seek a style file for use with TeX which will allow me to
put incidental text in a framed box, perhaps with a slightly shaded
background, and allow the box to float to an appropriate position close
to the text it complements.  If in addition the boxes could be numbered
then you would make my day.

Dear all,

I am currently in the process of writing up my thesis.
I would like to include some little pieces of additional
information which is aside to the main text. For example,
it would be nice to have a little biography of James Clerk Maxwell
beside his equations.

I particularly like the way that this sort of thing has been done by
Aki and Richards (seismologists know who these are) but if you read
the NewScientist you will also be familiar with the little boxes
containing extra information.

I could probably just about write a tex style file to do this, but I'd
rather not re-invent the wheel and so I am hoping someone out there will
be able to help me.  If someone has a partially working style file I
would be happy to try help make it complete.

Many thanks,

University of Edinburgh        |  mathematicians and all those who make
Dept of Geology and Geophysics |  empty prophecies.  The danger already
http://www.glg.ed.ac.uk/~ajsw  |  exists that mathematicians have made a
phone +44 131 650 8533         |  covenant with the devil to darken the
fax   +44 131 668 3184         |  spirit and confine man in the bonds of
|  Hell."                -- St. Augustine