[Tex/LaTex] How to set an Inline figure matching the text height

graphicsheightinline()

I want to put a very small figure inline with text. The figure must have the same height as the line it is positioned in. I have this:

Some text... \includegraphics[height=\baselineskip]{picture.png} ... some more text. 

This, however, makes the figure slightly too large, filling the whole space up to the bottom of the line above. I want the figure to be only as high as the capital letters of my font. What's the right way to do this?

Best Answer

Tell TeX that the figure should be as high as a “B”:

Some text... 
\includegraphics[height=\fontcharht\font`\B]{picture.png} 
... some more text. 

You probably want to define a special command for this:

\newcommand{\mychar}{%
  \begingroup\normalfont
  \includegraphics[height=\fontcharht\font`\B]{picture.png}%
  \endgroup
}

and type your paragraph as

some text \mychar{} some text

If you plan to use this also in titles or captions, it's better to say

\DeclareRobustCommand{\mychar}{%
  \begingroup\normalfont
  \includegraphics[height=\fontcharht\font`\B]{picture.png}%
  \endgroup
}