[Tex/LaTex] insert a vertically centered image in math mode

graphicsmath-modevertical alignment

In Mikael Öhman's answer to this question, he provides some code for placing an image in math mode as a symbol using the \mathord declaration. I can define a new command in the preamble using this, and it works, but the image is placed on the baseline of the equation.

I want it to be a good deal taller than typical text, so ideally I could use \vcenter to center it vertically. When I do include the centering, the image is treated as if it were as wide as the page, i.e. there are about 6 inches of white space following it. (The image is closely cropped, so the white space is certainly created by LaTeX.

Where is the glitch in my code?

\newcommand{\bone}{\mathord{\includegraphics[scale=0.5]{../images/dog_bone.pdf}}}

Best Answer

Use \hbox within \vcenter:

\vcenter{\hbox{\includegraphics{filename}}}

You could add \vcenter{\hbox{...}} to your macro definition if you always use it vertically centered.

Btw. generally you could simply use additional braces instead of \mathord to get the normal spacing.

Related Question