Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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.

share|improve this question
    
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

1 Answer 1

up vote 19 down vote accepted

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.

share|improve this answer
    
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
2  
@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

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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