3

i've got some graphic included within the text like so:

Sounds scary \includegraphics[width=1.2em]{images/zwinker.png}

this is the output:

enter image description here

but i'd like this output instead (graphic moved a bit down to fit nicer in the flow of the text):

enter image description here

how can i achieve this?

nerdess
  • 133

2 Answers2

2

A simple \raisebox{0.3\height} will do:

\documentclass[12pt]{article}
\usepackage{graphicx} 

\begin{document}

Sounds scary \raisebox{-0.3\height}{\includegraphics[scale = 0.08]{zwinkern}}

\end{document}

enter image description here

Bernard
  • 271,350
1

By default, images are set on the baseline of the current line. You can center this vertically by using adjustbox's valign=c option:

enter image description here

\documentclass{article}

\usepackage[export]{adjustbox}

\newcommand{\scarysymbol}[1][]{\includegraphics[width=1.2em,valign=c,#1]{example-image}}

\begin{document}

Something scary \includegraphics[width=1.2em]{example-image}.

Something scary \includegraphics[width=1.2em,valign=c]{example-image}.

Something scary \scarysymbol.

\end{document}

Alternatively, you can "raise" the image into position via \raisebox{<value>}{<stuff>}, where <value> can be a negative dimension and <stuff> is your \includegraphics. However, letting adjustbox sort this out is far simpler.

For consistency, store your scary symbol in a macro (say) \scarysymbol.

Werner
  • 603,163