8

As part of a document I'm writing, I'm trying to include an image as part of an equation, I have managed to get this to work, however the image's bottom is set to the same height as the bottom of the equation rather then the image's centre.

example code:

\begin{equation}
P_{i} = \includegraphics[scale = 0.4]{figure.pdf}
\end{equation}

I am wondering how to adjust this so that the centre line of the image is aligned with the equals sign.

2
  • 6
    Welcome to TeX.SE! Try \vcenter{\hbox{\includegraphics[scale = 0.4]{figure.pdf}}} instead of \includegraphics[scale = 0.4]{figure.pdf}.
    – user121799
    Commented Aug 7, 2018 at 4:44
  • 1
    Consider accepting the excellent provided answer, Commented May 23, 2021 at 23:52

1 Answer 1

7

Two solutions:

\documentclass{article}
\usepackage{amsmath}
\usepackage{graphicx}
\usepackage[export]{adjustbox}% for the second solution

\usepackage{duckuments}% for the images

\begin{document}

\begin{equation}
P_{i} =
\begin{gathered}
\includegraphics[height=3cm]{example-image-duck}
\end{gathered}
\end{equation}

\begin{equation}
P_{i} =
\includegraphics[height=3cm,valign=c]{example-image-duck}
\end{equation}

\end{document}

You can see that the centering is not “perfect” for the first case.

enter image description here

You must log in to answer this question.

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