以不同方式对问题进行编号

以不同方式对问题进行编号
\documentclass{article}
\begin{document}
\begin{center}
Exercise-1
\end{center}

\begin{enumerate}
  \item 1st question.
  \item 2nd question.
  \begin{enumerate}
    \item sub numbering of 2nd question.
    \item sub numbering of 2nd question.
  \end{enumerate}
\end{enumerate}

\end{document}

输出如下:

Exercise-1 
1. 1st question. 
2. 2nd question. 
  (a) sub numbering of 2nd question. 
  (b) sub numbering of 2nd question 

但我想获得以下输出:

Exercise-1 
(a) 1st question. 
(b) 2nd question. 
  (i) sub numbering of 2nd question. 
  (ii) sub numbering of 2nd question. 

或者

Exercise-1 
(i) 1st question. 
(ii) 2nd question.
  (a) sub numbering of 2nd question.
  (b) sub numbering of 2nd question.

答案1

enumerate包裹提供一种改变标签的简单机制。

示例输出

\documentclass{article}

\usepackage{enumerate}

\begin{document}

\begin{center}
Exercise~1
\end{center}

\begin{enumerate}[1.]
  \item 1st question.
  \item 2nd question.
  \begin{enumerate}[(a)]
    \item sub numbering of 2nd question.
    \item sub numbering of 2nd question.
  \end{enumerate}
\end{enumerate}

\begin{center}
  Excerise~2
\end{center}

\begin{enumerate}[(a)]
  \item 1st question.
  \item 2nd question.
  \begin{enumerate}[(i)]
    \item sub numbering of 2nd question.
    \item sub numbering of 2nd question.
  \end{enumerate}
\end{enumerate}

\end{document}

为了更好地控制列表,包括设置默认标签,enumitem包裹可以推荐。

答案2

这很容易做到enumitem包。这是您的第一个案例。

这里,第一级环境通过设置enumerate获取标签,第二级环境通过获取标签。的语法是。(\roman)\setlist[enumerate,1]{label=(\roman*)}(\alph)\setlist[enumerate,2]{label=(\alph*)}\setlist\setlist[<listname>,<level>]{<format>}

\documentclass{article}

\usepackage{enumitem}
\setlist[enumerate,1]{label=(\roman*)}
\setlist[enumerate,2]{label=(\alph*)}

\begin{document}
\begin{center}
Exercise-1
\end{center}

\begin{enumerate}
  \item 1st question.
  \item 2nd question.
  \begin{enumerate}
    \item sub numbering of 2nd question.
    \item sub numbering of 2nd question.
  \end{enumerate}
\end{enumerate}

\end{document}

在此处输入图片描述

编辑

我忘了说你使用enumerate-like 语法与shortlabels选项。

\documentclass{article}

\usepackage[shortlabels]{enumitem}

\begin{document}

\begin{center}
Exercise-1
\end{center}

\begin{enumerate}[(a)]
  \item 1st question.
  \item 2nd question.
  \begin{enumerate}[(i)]
    \item sub numbering of 2nd question.
    \item sub numbering of 2nd question.
  \end{enumerate}
\end{enumerate}

\begin{center}
Exercise-2
\end{center}

\begin{enumerate}[(i)]
  \item 1st question.
  \item 2nd question.
  \begin{enumerate}[(a)]
    \item sub numbering of 2nd question.
    \item sub numbering of 2nd question.
  \end{enumerate}
\end{enumerate}

\end{document}

在此处输入图片描述

答案3

您可以将所选择的“编号”作为可选参数传递给\item命令:

\documentclass{article}
\begin{document}
\begin{center}
Exercise-1
\end{center}

\begin{enumerate}
 \item[(a)] 1st question.
 \item[(b)] 2nd question.
 \begin{enumerate}
  \item[(i)] sub numbering of 2nd question.
  \item[(ii)] sub numbering of 2nd question.
 \end{enumerate}
\end{enumerate}

\end{document}

但是,这是手动更改。要自动更改,您必须定义\renewcommand{\labelenumi}{\roman{enumi})}- 至少是顶层。您可能也可以更改较低级别。为了获得更大的灵活性,您可以使用包enumitem

答案4

您需要重新定义用于枚举的标记。这些由命令控制\theenumi(用于枚举列表的顶层\theenumii、第二层等)。然后将标记选项设置为以下之一arabic,alph,Alph,Roman or roman。这是 MWE

\documentclass{article}

%Redefine the first level
\renewcommand{\theenumi}{\roman{enumi}}
\renewcommand{\labelenumi}{(\theenumi)}

%Redefine the second level
\renewcommand{\theenumii}{\alph{enumii}}
\renewcommand{\labelenumii}{(\theenumii)}

\begin{document}
\begin{center}
Exercise-1
\end{center}

\begin{enumerate}
  \item 1st question.
  \item 2nd question.
  \begin{enumerate}
    \item sub numbering of 2nd question.
    \item sub numbering of 2nd question.
  \end{enumerate}
\end{enumerate}


\end{document}

相关内容