将图形与项目符号对齐

将图形与项目符号对齐

我想在 itemize 环境中垂直对齐图形。 MWE 是:

\documentclass{article}
\usepackage{graphicx} % Required for inserting images

\begin{document}

I want the bullet vertically aligned with the picture

\begin{itemize}
    \item \includegraphics[scale=0.1]{paris.jpg}
    \item \includegraphics[scale=0.1]{paris.jpg}
\end{itemize}

\end{document}

其输出为:

在此处输入图片描述

但是项目符号位于图形底部。我怎样才能将其置于图形左侧的中心?

答案1

看一下包valign中的选项adjustbox

\documentclass{article}
\usepackage{graphicx} % Required for inserting images
\usepackage[export]{adjustbox}

\begin{document}

I want the bullet vertically aligned with the picture

\begin{itemize}
    \item \includegraphics[valign=c]{example-image-duck}
    \item \includegraphics[valign=c]{example-image-duck}
\end{itemize}

\end{document}

答案2

您可以\hbox在里面使用\vcenter。将其放入宏中以方便使用。

在此处输入图片描述

\documentclass{article}
\usepackage{graphicx} % Required for inserting images
\newcommand{\igcenter}[2][1]{$\vcenter{\hbox{\includegraphics[scale=#1]{#2}}}$}

\begin{document}

I want the bullet vertically aligned with the picture

\begin{itemize}
    \item \igcenter[0.1]{example-image-a}
    \item \igcenter[0.1]{example-image-b}
\end{itemize}

\end{document}

相关内容