Insert a graphic within a sentence nicely?

I am using string diagrams that I draw in Illustrator a lot, and I would like to draw them within a sentence.

When I just put \includegraphics{...} in the text, the image appears but its bottom is aligned with the text. I would like the center of the image aligned with the text, analogous to how in \displaystyle the center of the sum or integral is aligned with the text rather than its bottom.

• \begin{tabular}{@{}c@{}}\includegraphics{...}\end{tabular} – egreg Feb 27 '16 at 18:24
• or use adjustbox package which adds keys to \includegraphics for vertical alignement – David Carlisle Feb 27 '16 at 18:31

The simplest way is

\begin{tabular}{@{}c@{}}\includegraphics{...}\end{tabular}


More complex, but perhaps handier,

\usepackage[export]{adjustbox}


and then

\includegraphics[valign=M]{...}


Example:

\documentclass{article}
\usepackage{graphicx}

\begin{document}

Some text \includegraphics[height=3ex]{example-image-1x1} some text

\bigskip

Some text
\begin{tabular}{@{}c@{}}\includegraphics[width=3ex]{example-image-1x1}\end{tabular}
some text

\bigskip

Some text \includegraphics[height=3ex,valign=M]{example-image-1x1} some text

\bigskip

Some text \includegraphics[height=3ex,valign=m]{example-image-1x1} some text

\end{document}


If you want full control on the amount of raising or lowering, use \raisebox:

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


Instead of \height or a multiple thereof, you can use an explicit length.