如何并排显示项目?

如何并排显示项目?

我有三个itemize要并排显示的列表。目前,列表彼此叠在一起显示。我的代码(略微简化)如下所示:

   \begin{itemize}
        \item [\textbf{*A:}]
        \item 1: Some text
        \item 2: Some text
        \item 3: Some text
        \item 4: Some text
    \end{itemize}

    \begin{itemize}
        \item [\textbf{*B:}]
        \item Some text
        \item Some text
        \item Some text
        \item Some text
        \item Some text
        \item Some text
        \item Some text
        \item Some text
    \end{itemize}

    \begin{itemize}
        \item [\textbf{*C:}]
        \item Some text
        \item Some text
        \item Some text
    \end{itemize}

问题:我怎样才能并排显示三个列表(类似 CSS float:right;

答案1

有很多不同的方法可以做到这一点,例如

使用minipage环境,顶部对齐

\begin{minipage}[t]{.33\textwidth}
    \begin{itemize}
        \item [\textbf{*A:}]
        \item 1: Some text
        \item 2: Some text
        \item 3: Some text
        \item 4: Some text
    \end{itemize}   
\end{minipage}%
\begin{minipage}[t]{.33\textwidth}
        \begin{itemize}
        \item [\textbf{*B:}]
        \item Some text
        \item Some text
        \item Some text
        \item Some text
        \item Some text
        \item Some text
        \item Some text
        \item Some text
    \end{itemize}
\end{minipage}%
\begin{minipage}[t]{.33\textwidth}
       \begin{itemize}
        \item [\textbf{*C:}]
        \item Some text
        \item Some text
        \item Some text
    \end{itemize}
\end{minipage}

使用tabularp{<width>}

\begin{tabular}{p{.33\textwidth}p{.33\textwidth}p{.33\textwidth}}
    \begin{itemize}
        \item [\textbf{*A:}]
        \item 1: Some text 
        \item 2: Some text
        \item 3: Some text
        \item 4: Some text
    \end{itemize}   
&
        \begin{itemize}
        \item [\textbf{*B:}]
        \item Some text
        \item Some text
        \item Some text
        \item Some text
        \item Some text
        \item Some text
        \item Some text
        \item Some text
    \end{itemize}
&
       \begin{itemize}
        \item [\textbf{*C:}]
        \item Some text
        \item Some text
        \item Some text
    \end{itemize}
\end{tabular}

使用parbox

\parbox[t]{.33\textwidth}{%
    \begin{itemize}
        \item [\textbf{*A:}]
        \item 1: Some text 
        \item 2: Some text
        \item 3: Some text
        \item 4: Some text
    \end{itemize}   
    }%
\parbox[t]{.33\textwidth}{%
        \begin{itemize}
        \item [\textbf{*B:}]
        \item Some text
        \item Some text
        \item Some text
        \item Some text
        \item Some text
        \item Some text
        \item Some text
        \item Some text
    \end{itemize}
    }%
\parbox[t]{.33\textwidth}{%
       \begin{itemize}
        \item [\textbf{*C:}]
        \item Some text
        \item Some text
        \item Some text
    \end{itemize}
}%

答案2

如果您碰巧写了一份考试表,您可以使用exsheetstasks包。

vingtoft任务

\documentclass{article}
\usepackage{exsheets}
\usepackage{tasks}
\SetupExSheets{counter-format=qu[A]:}
\begin{document}
\begin{question}
    Which animal is the best?
    \begin{tasks}(3)
        \task Wombat 
        \task Duck
        \task Capybara
        \task Mara
        \task Why make a difference? They are all equally great
    \end{tasks}
\end{question}
\begin{question}
    What to not drink in the morning? 
    \begin{tasks}(3)
        \task Coffee
        \task Orange juice
        \task Water
        \task Milk
        \task Beer
    \end{tasks}
\end{question}
\begin{question}
    Which animal is the best?
    \begin{tasks}(3)
        \task Wombat 
        \task Duck
        \task Capybara
        \task Mara
        \task*(2) Why make a difference? They are all equally great
    \end{tasks}
\end{question}
\end{document}

答案3

如果您愿意使用多列...

\documentclass{article}
\usepackage{multicol}
\setlength{\columnsep}{5pt} %space between columns 

\raggedcolumns % for NOT stretching the columns with manual columnbreak
\begin{document}

\begin{multicols}{3}
       \begin{itemize}
        \item [\textbf{*A:}]
        \item 1: Some text
        \item 2: Some text
        \item 3: Some text
        \item 4: Some text
    \end{itemize}
    \columnbreak %% end of a column
    \begin{itemize}
        \item [\textbf{*B:}]
        \item Some text
        \item Some text
        \item Some text
        \item Some text
        \item Some text
        \item Some text
        \item Some text
        \item Some text
    \end{itemize}
    \columnbreak

    \begin{itemize}
        \item [\textbf{*C:}]
        \item Some text
        \item Some text
        \item Some text
    \end{itemize}
\end{multicols}

\end{document}

在此处输入图片描述

相关内容