如何在Latex中为枚举设置自己的订单?

时间:2014-11-05 23:59:41

标签: enums latex customization enumeration items

我希望每次在第二级别的枚举中的项目按此顺序显示为:

Binary:                                                  i)
Decimal:                                                ii)
Hex:                                instead of:        iii)
Subtraction:                                            iv)
Addition:                                                v)

(我不在乎他们在第5 \item之后如何继续,因为我无论如何都不会使用超过5个。)

我不确定它是否可能我只是用Google搜索,似乎只能使用它来更改项目名称:\renewcommand{\labelenumii}{\labelenumi\roman{enumii}: }但这仅适用于标准订单...好吧,我不会谈论太多,因为我对Latex很新,所以这里是我的代码:

\begin{document}
\begin{enumerate}
\item Question 1
    \begin{enumerate}
        \item
        \item
        \item 
        \item 
        \item 
    \end{enumerate}
\item Question 2
    \begin{enumerate}
        \item
        \item
        \item 
        \item 
        \item 
    \end{enumerate}
\end{enumerate}
\end{document}

1 个答案:

答案 0 :(得分:2)

我建议使用description环境:

enter image description here

\documentclass{article}

\begin{document}
\begin{enumerate}
  \item Question 1
  \begin{enumerate}
    \item first
    \item second
    \item third
    \item fourth
    \item fifth
  \end{enumerate}

  \item Question 2
  \begin{description}
    \item[Binary:] first
    \item[Decimal:] second
    \item[Hex:] third
    \item[Subtraction:] fourth
    \item[Addition:] fifth
  \end{description}

\end{enumerate}
\end{document}

使用名为qlist的新环境的自动方式:

enter image description here

\documentclass{article}
\newcounter{qlist}
\newenvironment{qlist}
  {\setcounter{qlist}{0}% Restart qlist counter
   \renewcommand{\descriptionlabel}[1]{% Update \descriptionlabel
     \hspace{\labelsep}\normalfont% Taken from article.cls
     \stepcounter{qlist}% Increment counter
     \ifcase\value{qlist}\relax\or% 0
       \textbf{Binary:}\or% 1
       \textbf{Decimal:}\or% 2
       \textbf{Hex:}\or% 3
       \textbf{Subtraction:}\or% 4
       \textbf{Addition:}\else% 5
       Unknown% Unknown entry
    \fi}%
   \begin{description}}% begin normal description environment
  {\end{description}}% end normal description environment

\begin{document}
\begin{enumerate}
  \item Question 1
  \begin{qlist}
    \item first
    \item second
    \item third
    \item fourth
    \item fifth
  \end{qlist}

  \item Question 2
  \begin{qlist}
    \item first
    \item second
  \end{qlist}

  \item Question 3
  \begin{qlist}
    \item first
    \item second
    \item third
    \item fourth
    \item fifth
  \end{qlist}

\end{enumerate}
\end{document}