Images appearing inline aren't always ideally placed relative to the baseline and risers of the text itself, so I frequently find myself doing manual adjustment, by eye, using \raisebox{}{} with a negative first parameter.

My question is whether there is a simple way to get a comparable effect without adjusting the parameter manually against the output in each case.

  • What kind of inline images are you using in what kind of situations? Are you maybe use images for symbols? – Martin Scharrer Apr 14 '11 at 21:15
  • 1
    Finishing typesetting a Manchu-English dictionary. The dictionary is in romanization, but in a few places it is useful to cite the original Manchu script. However, images of actual handwritten Manchu look better than the Manchu fonts (accessible though MonTex). – brannerchinese Apr 14 '11 at 23:45

Images are added with a zero depth, i.e. they sit on the baseline. It depends very much on the situation (and personal taste) what the "ideal" placement of a particular image is. So no, there is no way to automatically get-it-just-right (TM).

Note that \raisebox allows the use of \height, \depth, \width and \totalheight (=height+depth) which represent the original dimension of the to be raised box. As said, \depth is zero and so \totalheight is identical to \height for images. So if you want all you images to be 10% below the baseline you can use \raisebox{-.1\height}{\includegraphics[...]{...}}.

If you want the images to be as deep as the normal text you can use \dp\strutbox as a reference. The \strutbox contains the depth and height of a \strut. Both together are equal to \baselineskip so about 20% larger than the actual font size. Therefore you might want to use -.8\dp\strutbox. Alternatively you can use a font size relative length in ex. 1ex is about the height of an x.

As always you might want to make a macro for this if you need this more often.

  • Ah, very nice -- the use of \height always makes me happy. Thank you! – brannerchinese Apr 14 '11 at 23:45
  • Another comment: If you want top-aligned images in the figure environment, you can use \begin{figure}\raisebox{-\height}{\includegraphics{img1.png}}\qquad\raisebox{-\height}{\includegraphics{img2.png}}\end{figure} – yo' May 10 '12 at 16:34
  • 4
    @tohecz: In the meantime since my answer I published adjustbox which can export the valign key to \includegraphics. It allows for easy vertical alignment and uses the the same internal macros as \raisebox. – Martin Scharrer May 10 '12 at 22:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.