Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to align \includegraphics vertically centered?

5,321 views
Skip to first unread message

L.J. Wischik

unread,
Mar 23, 1999, 3:00:00 AM3/23/99
to
In the equation \includegraphics{.} = \includegraphics{.},
I want the equals to be vertically centered between the two pictures. I
guess that this should actually be done by having everything centered
vertically on the baseline.

I notice that
\parbox{2cm}{.} \mbox{\hfill = \hfill} \parbox{2cm}{.}
appears to do the trick. But this doesn't help me, because I don't know
the widths of the graphics! I was not able to find any other way of
telling it to vertically center an arbitrary thing on the baseline.

Chris Dams suggested to use math mode, 'since tex is quite good at placing
equals signs in math mode :)', like this:
\[ \vcenter{\includegraphics{.}} = \vcenter{\includegraphics{.}} \]
but that doesn't work at all! It gives the first figure about five times
too much horizontal spacing, so I get the first picture to the left
of the page, an equals symbol at the right hand side, and the second
picture disappears off the right hand edge of the paper. (I wasn't
actually able to find an explanation of \vcenter in my book, 'A Guide to
Latex2e', and didn't know how to investigate further).

Someone suggested using Paul Taylor's Commutative Diagrams Package and
having one figure 'commute' into the other figure using an equals sign as
the arrow, but this seemed like the wrong way to go about it. (And I find
it hard enough installing packages as it is!) The other people I asked
said: "forget it! you can't do it! put the equals sign into your drawing
package and export both figures together with equals sign as a single
.eps!" but that would be terribly troublesome and I have a vague
ill-formed conceptual objection to this strategy.

Please! I'd be extremely grateful if anyone could tell me an answer!

--
Lucian Wischik, Queens' College, Cambridge CB3 9ET. www.wischik.com/lu

Karsten Tinnefeld

unread,
Mar 23, 1999, 3:00:00 AM3/23/99
to
> In the equation \includegraphics{.} = \includegraphics{.},
> I want the equals to be vertically centered between the two pictures.

> Chris Dams suggested to use math mode, 'since tex is quite good at > placing


> equals signs in math mode :)', like this:
> \[ \vcenter{\includegraphics{.}} = \vcenter{\includegraphics{.}} \]
> but that doesn't work at all! It gives the first figure about five times
> too much horizontal spacing, so I get the first picture to the left
> of the page, an equals symbol at the right hand side, and the second
> picture disappears off the right hand edge of the paper.

TeXbook documents \vcenter. Since \includegraphics produces raw
material, it is typeset as a paragraph---with normal indentation and
page width. Boxing it is the solution:
\[
\vcenter{\hbox{\includegraphics{.}}}\quad=\quad
\vcenter{\hbox{\includegraphics{.}}}
\]

--
Karsten Tinnefeld
Silence is the perfectest herald of joy:
I were but little happy, if I could say how much.

L.J. Wischik

unread,
Mar 23, 1999, 3:00:00 AM3/23/99
to
L.J. Wischik <ljw...@cus.cam.ac.uk> wrote:
>In the equation \includegraphics{.} = \includegraphics{.},
>I want the equals to be vertically centered between the two pictures. I
>guess that this should actually be done by having everything centered
>vertically on the baseline.

No I don't! In fact I want the same sort of control over vertical placement
as I do over a parbox: either centered, or top-aligned, or bottom-aligned,
depending on which picture I want.

Mark Perks

unread,
Mar 23, 1999, 3:00:00 AM3/23/99
to
In article <7d8r6q$977$1...@pegasus.csx.cam.ac.uk>,

L.J. Wischik <ljw...@cus.cam.ac.uk> wrote:
>L.J. Wischik <ljw...@cus.cam.ac.uk> wrote:
>>In the equation \includegraphics{.} = \includegraphics{.},
>>I want the equals to be vertically centered between the two pictures. I
>>guess that this should actually be done by having everything centered
>>vertically on the baseline.
>
>No I don't! In fact I want the same sort of control over vertical placement
>as I do over a parbox: either centered

\raisebox{-.5\height}{\includegraphics{.}}

>, or top-aligned,

\raisebox{-\height}{\includegraphics{.}}

> or bottom-aligned,

\includegraphics{.}

>depending on which picture I want.
>
>--
>Lucian Wischik, Queens' College, Cambridge CB3 9ET. www.wischik.com/lu


--

*,,,,/\o__ H. Mark Perks Dept of Chem, UMBC 9,
pe...@umbc.edu 410 455-2789 Baltimore, MD 21250 <\

Donald Arseneau

unread,
Mar 23, 1999, 3:00:00 AM3/23/99
to
In article <7d8hne$nf$1...@pegasus.csx.cam.ac.uk>, ljw...@cus.cam.ac.uk (L.J. Wischik) writes...

>In the equation \includegraphics{.} = \includegraphics{.},
>I want the equals to be vertically centered between the two pictures.

In raw TeX there is \vcenter{\hbox{...}}.
In LaTeX there is \begin{tabular}{l}...\end{tabular}.

>guess that this should actually be done by having everything centered
>vertically on the baseline.

Centered vertically on the "vertical center" line.

Donald Arseneau as...@triumf.ca

Axel Reichert

unread,
Mar 24, 1999, 3:00:00 AM3/24/99
to
ljw...@cus.cam.ac.uk (L.J. Wischik) writes:

> In fact I want the same sort of control over vertical placement

> as I do over a parbox: either centered, or top-aligned, or bottom-aligned,

> depending on which picture I want.

Read epslatex.ps about the alignment of minipages/parboxes.

Happy TeXing!

--
Axel Reichert -- http://mt.mpie-duesseldorf.mpg.de/people/reich/

Alain Ketterlin

unread,
Mar 24, 1999, 3:00:00 AM3/24/99
to
ljw...@cus.cam.ac.uk (L.J. Wischik) writes:

> L.J. Wischik <ljw...@cus.cam.ac.uk> wrote:
> >In the equation \includegraphics{.} = \includegraphics{.},
> >I want the equals to be vertically centered between the two pictures. I

> >guess that this should actually be done by having everything centered
> >vertically on the baseline.

\raisebox{-0.5\totalheight}{\includegraphics{.}}

> No I don't! In fact I want the same sort of control over vertical placement


> as I do over a parbox: either centered, or top-aligned, or bottom-aligned,
> depending on which picture I want.

It could be hard to find the baseline of the first (or last) line of
the picture... :-) which is, I think, what top-aligned (or
bottom-aligned) mean.

But you can change -0.5 above to -1 (and add 1ex perhaps) to get some
kind of top-aligned picture. Bottom alignment is the default, IIRC.

-- Alain.

0 new messages