Putting together TeX boxes

Putting together TeX boxes

Post by Claude Dideri » Sat, 05 Mar 1994 18:17:52



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)?

Please reply by e-mail. I will summarize to the net!

                         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

Post by Claude Dideri » Wed, 09 Mar 1994 00:40:06


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)?

> Please reply by e-mail. I will summarize to the net!

>                          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
 \advance\skip2 by -\ht 2
 \advance\skip2 by \dp 2
 \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

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

 
 
 

1. putting info in box alongside main text using TeX

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

2. SHFullScreen

3. Any package put both word and phonetic symbol together?

4. Shadow of the Beast III help

5. Putting together column matrices

6. Device Driver Development

7. how to put two graph together parallelly(left graph + right graph)?

8. Movies on Xbox.com

9. Q: align and boxed together?

10. how to put a frame/box around a figure and table?

11. how to put a box around a paragraph

12. pstricks question: how to put a box around the page?

13. Q: How can I put a box around a multiline formula ?