让图像与列表并排放置的推荐方法是什么?

让图像与列表并排放置的推荐方法是什么?

下面我的做法应该足够了,但我欢迎任何其他更好的方法。还有其他更好的方法吗?

\documentclass[preview,border=12pt,12pt]{standalone}
\usepackage{enumitem,graphicx}
\begin{document}
\begin{enumerate}
    \item Consider the following image.\\
    \begin{minipage}{.5\linewidth}
    \includegraphics[width=\linewidth]{example-image-a}
    \end{minipage}
    \begin{minipage}{.5\linewidth}
    \begin{enumerate}
    \item What is your name?
    \item What time is it?
    \item Who am I?
    \item Do you love me?
    \end{enumerate}
    \end{minipage}
\end{enumerate}
\end{document}

在此处输入图片描述

答案1

您可以将两个小页面对齐到顶部:

\documentclass[preview,border=12pt,12pt]{standalone}
\usepackage{enumitem,graphicx}
\begin{document}
\begin{enumerate}
    \item Consider the following image.

    \begin{minipage}[t]{.5\linewidth}\vspace{0pt}
    \includegraphics[width=\linewidth]{example-image-a}
    \end{minipage}
    \begin{minipage}[t]{.5\linewidth}\vspace{0pt}
    \begin{enumerate}
    \item What is your name?
    \item What time is it?
    \item Who am I?
    \item Do you love me?
    \end{enumerate}
    \end{minipage}
\end{enumerate}
\end{document}

并且你可以使用adjustbox省略第一个小页面:

\documentclass[preview,border=12pt,12pt]{standalone}
\usepackage{enumitem,graphicx}
\usepackage[export]{adjustbox}
\begin{document}
\begin{enumerate}
    \item Consider the following image.\par
    \includegraphics[valign=t,width=.5\linewidth]{example-image-a}
    \begin{minipage}[t]{.5\linewidth}
    \begin{enumerate}
    \item What is your name?
    \item What time is it?
    \item Who am I?
    \item Do you love me?
    \end{enumerate}
    \end{minipage}
\end{enumerate}
\end{document}

或者不使用任何小页面,使用multicol(但不使用standalone):

\documentclass[border=12pt,12pt]{article}
\usepackage{enumitem,graphicx}
\usepackage{multicol}
\begin{document}
\begin{enumerate}
    \item Consider the following image.
    \begin{multicols}{2}
    \includegraphics[width=\linewidth]{example-image-a}
    \begin{enumerate}
    \item What is your name?
    \item What time is it?
    \item Who am I?
    \item Do you love me?
    \end{enumerate}
    \end{multicols}
\end{enumerate}
\end{document}

或者使用\parboxminipage 代替(更简单的语法):

\documentclass{article}
\usepackage{graphicx}
\usepackage[export]{adjustbox}
\begin{document}
\begin{enumerate}
    \item Consider the following image.\par
    \includegraphics[valign=t,width=.5\linewidth]{example-image-a}
    \parbox[t]{.5\linewidth}{
    \begin{enumerate}
    \item What is your name?
    \item What time is it?
    \item Who am I?
    \item Do you love me?
    \end{enumerate}} 
\end{enumerate}
\end{document}

对于中心或底部对齐,可以使用或列简单tabular完成工作:mb

\documentclass{article}
\usepackage{graphicx,array}
\begin{document}
\begin{enumerate}
    \item Consider the following image.\par
    \begin{tabular}{m{.5\linewidth}m{.5\linewidth}}
    \includegraphics[width=\linewidth]{example-image-a} &
    \begin{enumerate}
    \item What is your name?
    \item What time is it?
    \item Who am I?
    \item Do you love me?
    \end{enumerate}\\
    \end{tabular}
\end{enumerate}
\end{document}

咳咳!也可以用于与经典p列进行顶部对齐(不需要该array包,但需要 似曾相识 肮脏的伎俩):

\documentclass{article}
\usepackage{graphicx,array}
\begin{document}
\begin{enumerate}
    \item Consider the following image.\par
    \begin{tabular}{p{.5\linewidth}p{.5\linewidth}}\vspace{0pt}
    \includegraphics[width=\linewidth]{example-image-a} &
    \begin{enumerate}
    \item What is your name?
    \item What time is it?
    \item Who am I?
    \item Do you love me?
    \end{enumerate}\\
    \end{tabular}
\end{enumerate}
\end{document}

虽然对于其他目的可能有些可疑,但这对于拖延来说是一种很好的方法::)

\documentclass{article}
\usepackage{graphicx,tabto}
\begin{document}
\begin{enumerate}
    \item Consider the following image.\par
    \vbox to -0pt{
    \includegraphics[height=5cm]{example-image-a}}
    \tab
    \vbox to 2\baselineskip{
    \begin{enumerate}
    \item What is your name?
    \item What time is it?
    \item Who am I?
    \item Do you love me?
    \end{enumerate}}
\end{enumerate}
\end{document}

答案2

仅举一些带有盒子的例子tcbsidebyside(来自tcolorbox包装):

\documentclass{article}
\usepackage[most]{tcolorbox}
\begin{document}
\begin{enumerate}
    \item Consider the following image.\par
    \tcbsidebyside[blanker, sidebyside gap=5mm]{
    \includegraphics[width=\linewidth]{example-image-a}}{%
    \begin{enumerate}
    \item What is your name?
    \item What time is it?
    \item Who am I?
    \item Do you love me?
    \end{enumerate}}
\end{enumerate}

\begin{enumerate}
    \item Consider the following image.\par
    \tcbsidebyside[righthand ratio=.4, sidebyside align=top seam, blanker, sidebyside gap=5mm]{%
    \includegraphics[width=\linewidth]{example-image-a}}{%
    \begin{enumerate}
    \item What is your name?
    \item What time is it?
    \item Who am I?
    \item Do you love me?
    \end{enumerate}}
\end{enumerate}

\begin{enumerate}
    \item Consider the following image.\par
    \tcbsidebyside[righthand ratio=.6, sidebyside align=bottom seam, blanker, sidebyside gap=5mm]{%
    \includegraphics[width=\linewidth]{example-image-a}}{%
    \begin{enumerate}
    \item What is your name?
    \item What time is it?
    \item Who am I?
    \item Do you love me?
    \end{enumerate}}
\end{enumerate}
\end{document}

在此处输入图片描述

相关内容