將圖形與項目符號對齊

將圖形與項目符號對齊

我想在 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}

相關內容