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.

2
  • \begin{tabular}{@{}c@{}}\includegraphics{...}\end{tabular}
    – egreg
    Commented Feb 27, 2016 at 18:24
  • 1
    or use adjustbox package which adds keys to \includegraphics for vertical alignement Commented Feb 27, 2016 at 18:31

1 Answer 1

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.

1
  • Thanks for the answer! Commented Jun 19, 2020 at 14:53

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .