在多列中枚舉

在多列中枚舉

下圖說明了我正在尋找的內容:

在此輸入影像描述

本質上,我希望編號如上所示,但使用multicolandenumitem包。但是當我使用以下程式碼嘗試時:

\documentclass{article}
\usepackage{amsmath,amssymb}
\usepackage{enumitem,multicol}
\begin{document}
\begin{enumerate}
\item Evaluate each of the following if $x$ is a non-zero real number.
    \begin{multicols}{2}
    \begin{enumerate}[itemsep=1cm]% The item sep is my choice here.
    \item $\dfrac{|x|}{x}$
    \item $\dfrac{x}{|x|}$
    \item $\dfrac{|-x|}{-x}$
    \item $|x|-|-x|$
    \end{enumerate} 
    \end{multicols}
\end{enumerate}
\end{document}

我得到:

在此輸入影像描述

本質上,我希望它(b)在它所(c)在的地方。我知道這已經完成了,但我似乎找不到它。

答案1

這是使用定義命令的選項\newitem。內容設定為\parbox自然從左到右流動,以您所追求的樣式提供枚舉:

在此輸入影像描述

\documentclass{article}
\usepackage{amsmath,amssymb}% http://ctan.org/pkg/{amsmath,amssymb}
\usepackage{enumitem,multicol,setspace}% http://ctan.org/pkg/{enumitem,multicol,setspace}
\newcounter{subenum}[enumi]
\renewcommand{\thesubenum}{\alph{subenum}}
\newcommand{\newitem}[1]{%
  \refstepcounter{subenum}%
  \parbox{\dimexpr.5\linewidth-.5\columnsep}{%
    \makebox[\labelwidth][r]{(\thesubenum)\hspace*{\labelsep}}%
    #1}\hfill%
}
\begin{document}
\begin{enumerate}[start=8]
  \item Evaluate each of the following if $x$ is a non-zero real number.
    \begin{multicols}{2}
      \begin{enumerate}[itemsep=1cm]% The item sep is my choice here.
        \item $\dfrac{|x|}{x}$
        \item $\dfrac{x}{|x|}$
        \item $\dfrac{|-x|}{-x}$
        \item $|x|-|-x|$
      \end{enumerate} 
    \end{multicols}
  \item Evaluate each of the following if $x$ is a non-zero real number.\par
    \setstretch{3}%
    \newitem{$\dfrac{|x|}{x}$}
    \newitem{$\dfrac{x}{|x|}$}
    \newitem{$\dfrac{|-x|}{-x}$}
    \newitem{$|x|-|-x|$}
\end{enumerate}
\end{document}

間距考慮因素由下式提供setspace並且可以進行調整(\topsep如果需要,還可以刪除一些額外的“”空白)。


對於更改列數的稍微自動化的方法,請添加

\usepackage[nomessages]{fp}% http://ctan.org/pkg/fp

到您的文件序言,並使用

\FPeval\thecolwidth{round(1/4:4)}% Specify number of columns -> column width
\newcommand{\newitem}[1]{%
  \refstepcounter{subenum}%
  \parbox{\dimexpr\thecolwidth\linewidth-.5\columnsep}{%
    \makebox[\labelwidth][r]{(\thesubenum)\hspace*{\labelsep}}%
    #1}\hfill%
}

作為您對 的定義\newitem。修改1/41/<col nums>以增加列數。

答案2

在此輸入影像描述

\documentclass{article}
\usepackage{amsmath,amssymb}
%\tracingall
\def\horizlist#1#2#3{%
  \setcounter{enumi}{0}%
  #3%
  \flushleft
  \dimen0 \linewidth
  \divide\dimen0 by #1\relax
  \advance\dimen0 -#2\relax
  \def\item{\hfil\egroup\penalty50 \hfill
  \refstepcounter{enumi}%
  \leavevmode\hbox to \dimen0 \bgroup\space(\theenumi)\space}%
  \leavevmode\bgroup\hskip 0pt plus -1fill }

\def\endhorizlist{\hfil\egroup\endflushleft}

\begin{document}
\begin{enumerate}
\item Evaluate each of the following if $x$ is a non-zero real number.
    \begin{horizlist}{2}{1cm}{\renewcommand\theenumi{\alph{enumi}}}
    \item $\dfrac{|x|}{x}$
    \item $\dfrac{x}{|x|}$
    \item $\dfrac{|-x|}{-x}$
    \item $|x|-|-x|$
    \end{horizlist}
\end{enumerate}
\end{document}

要看看這裡發生了什麼,如果您希望編號在向下之前從右到左,這是正常的段落詞序,所以要做的就是製作一系列固定寬度的框,如果它們是(比如說)的1 /3文字寬度,並且您在左齊平的段落中創建了這樣的框的段落,那麼 Tex 會自然地將三個框包裹在一行中,並且它們將垂直對齊,因為它們的寬度都相同。程式碼的其餘部分只是增加一個計數器並將 (\the...) 放在框的前面,並隱藏語法\makebox[0.3\textwidth]{...}以使用標準\item語法,以便可以輕鬆地在清單類型之間切換。

換句話說,與以下內容進行比較,除了修飾語法變更之外,其他內容都是相同的。

在此輸入影像描述

\documentclass{article}

\begin{document}
\begin{flushleft}

\makebox[.3\textwidth][l]{one one}
\makebox[.3\textwidth][l]{two 2 two 2 two}
\makebox[.3\textwidth][l]{three three 3}
\makebox[.3\textwidth][l]{4 4 4 4 4 }
\makebox[.3\textwidth][l]{fifth box}
\makebox[.3\textwidth][l]{number 6}
\makebox[.3\textwidth][l]{7 7 7 7 }
\makebox[.3\textwidth][l]{eight}
\makebox[.3\textwidth][l]{nine nine}
\makebox[.3\textwidth][l]{10}

\end{flushleft}
\end{document}

儘管結果看起來是三列,但它只是一個排版段落,自動對齊,因為段落中的每個「單字」都是一個大小相等的方塊。

答案3

這很容易與exsheets包和tasks包裹。希望以下範例是不言自明的:

\documentclass{article}
\usepackage[T1]{fontenc}

\usepackage{mathtools}
\DeclarePairedDelimiter\abs{\lvert}{\rvert}

\usepackage{exsheets}% loads the `tasks' package
\SetupExSheets{
  headings = runin-nr
}
\settasks{
  counter-format = tsk[a]. ,
  label-format = \sffamily\itshape\bfseries
}

\setcounter{question}{43}% only for this example

\begin{document}

\begin{question}
  Evaluate each of the following if $x$ is a non-zero real number.
  \begin{tasks}(2)
    \task $\dfrac{\abs{x}}{x}$
    \task $\dfrac{x}{\abs{x}}$
    \task $\dfrac{\abs{-x}}{-x}$
    \task $\abs{x}-\abs{-x}$
  \end{tasks}
\end{question}

\end{document}

在此輸入影像描述

答案4

這是一個無聊的例子,它使用了resume以下功能enumitem包裹。這不是最有效的,因為程式碼開始enumerate過度停止環境。但結果在視覺上是可以接受的。您可以引入各種額外的調整,因為它只是一個表格環境。

\documentclass{article}
\usepackage{amsmath,amssymb}
\usepackage{enumitem}
\newcommand{\Choices}[4]{\begin{tabular}{p{0.5\textwidth} p{0.5\textwidth}} 
\begin{enumerate*}[series=lafter]
    \item #1
\end{enumerate*} &%
\begin{enumerate*}[resume=lafter]
    \item #2
\end{enumerate*} \\[2\baselineskip]
\begin{enumerate*}[resume=lafter]
    \item #3
\end{enumerate*} &%
\begin{enumerate*}[resume=lafter]
    \item #4
\end{enumerate*}
\end{tabular}}

\begin{document}
\begin{enumerate}
\item Evaluate each of the following if $x$ is a non-zero real number.

\Choices{$\dfrac{|x|}{x}$}{$\dfrac{x}{|x|}$}{$\dfrac{|-x|}{-x}$}{$|x|-|-x|$}

\item Evaluate each of the following if you can.

\Choices{This question is not answerable (is that a real word?)}
{This question does not have any correct answer}
{$\int_0^\pi{\tan\sqrt\theta d\theta}$}
{Whatever is a valid answer!}
\end{enumerate}
\end{document}

在此輸入影像描述

相關內容