如何使文本在项目中居中显示在图像附近

如何使文本在项目中居中显示在图像附近

我需要写一些注意标志并附上解释,例如:

|-----|
| pic |- this is text about picture.
|_____|

|-----|
| pic |- this is text about picture.
|_____|

|-----|
| pic |- this is text about picture.
|_____|

也许有什么建议?因为我尝试的不是将文本正确居中。我尝试这样做,例如:

\begin{itemize}
\item[]\includegraphics[width=2cm,height=2cm]{pic1} -- this is text about picture
\item[]\includegraphics[width=2cm,height=2cm]{pic4} -- this is text about picture
\item[]\includegraphics[width=2cm,height=2cm]{pic3} -- this is text about picture
\end{itemize}

我变得像这样:

|-----|
| pic |
|_____|- this is text about picture.

|-----|
| pic |
|_____|- this is text about picture.

|-----|
| pic |
|_____|- this is text about picture.

提前感谢你的帮助。

|-----|
| pic |-blaaaaaaaaaaaaaaaaaaaaaablaaaaaaaaaaaaaaaaaaaaaablaaaaaaaaaaaaaaaaaa
|_____|(huge space here)

啦啦啦啦....................

答案1

您可以使用adjustbox

\documentclass{article}
\usepackage[export]{adjustbox}

\newcommand{\figureitem}[3][]{%
  \item[]%
  \sbox0{\includegraphics[#1]{#2}\ --\ }%
  \makebox[\wd0][l]{\includegraphics[#1,valign=m]{#2}}%
  \parbox{\dimexpr\linewidth-\wd0}{%
    \makebox[0pt][r]{\ --\ }\ignorespaces#3%
  }%
}

\begin{document}

\begin{itemize}
\figureitem[width=2cm,height=2cm]{donald-duck}{
  this is text about picture
}

\figureitem[width=2cm,height=2cm]{donald-duck}{
  this is text about picture which is quite long and wraps across
  lines; let's see what happens
}

\figureitem[width=2cm,height=2cm]{donald-duck}{
  this is text about picture
}
\end{itemize}

\end{document}

在此处输入图片描述

相关内容