I need to place an icon and text behind each other on one line. The icon is higher than a single text line, and would like to have the icon and text center aligned. How do I do that?
Asked
Active
Viewed 2.1k times
2 Answers
27
The only way I found to do this robustly (well, Scott showed me this...) is to put the figure in a math matrix:
\documentclass{article}
\usepackage{graphics}
\begin{document}
hello here is $
\begin{array}{l}
\includegraphics{icon}
\end{array}
$ my line.
\end{document}
resulting in 
Yossi Farjoun
- 13,274
- 10
- 74
- 96
25
You can use a \parbox.
\documentclass{minimal}
\usepackage{graphicx}
\newcommand{\vcenteredinclude}[1]{\begingroup
\setbox0=\hbox{\includegraphics{#1}}%
\parbox{\wd0}{\box0}\endgroup}
\begin{document}
I need to place an icon \vcenteredinclude{test.png}
and text behind each other on one line. The icon is
higher than a single text line, and would like to have the icon and text
center aligned. How do I do that?
\end{document}
and the outcome is:

101 010image, right next to the colourful little picture. – Konrad Rudolph Jul 28 '10 at 09:43\vcenterand\raisebox. – Stefan Kottwitz Dec 16 '10 at 15:08