3

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.

Arun Debray
  • 7,126
  • 2
  • 30
  • 54

1 Answers1

5

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[export]{adjustbox}
\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}

enter image description here

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.

egreg
  • 1,121,712