从 0 开始嵌套枚举

从 0 开始嵌套枚举

这是我的乳胶代码:

\begin{enumerate}
\item  
\begin{enumerate}
\item  I do not feel sad. 
\item  I feel sad 
\item I am sad all the time and I can't snap out of it. 
\item I am so sad and unhappy that I can't stand it.
\end{enumerate}
\end{enumerate}

这是输出

在此处输入图片描述

这就是我想要的

在此处输入图片描述

从第二张图片中可以看到,数字从 0 开始,从第二行开始。我该如何获取这个数字?

答案1

你可以这样做:

\documentclass{article}


\begin{document}
   \begin{enumerate}
\item  

\begin{enumerate}\setcounter{enumii}{-1}\renewcommand\theenumii{\arabic{enumii}}
\item  I do not feel sad. 
\item  I feel sad 
\item I am sad all the time and I can't snap out of it. 
\item I am so sad and unhappy that I can't stand it.
\end{enumerate}
\end{enumerate}
\end{document}

您也可以按照\settozero上面的命令进行定义:

\def\settozero{\setcounter{enumii}{-1}\renewcommand\theenumii{\arabic{enumii}}}

然后您可以在内部枚举开始时使用它:

\documentclass{article}

\def\settozero{\setcounter{enumii}{-1}\renewcommand\theenumii{\arabic{enumii}}}

\begin{document}
\begin{enumerate}
\item  

\begin{enumerate}\settozero
\item  I do not feel sad. 
\item  I feel sad 
\item I am sad all the time and I can't snap out of it. 
\item I am so sad and unhappy that I can't stand it.
\end{enumerate}
\end{enumerate}
\end{document}

并且更加自动化:

\documentclass{article}

\def\settozero{\setcounter{enumii}{-1}\renewcommand\theenumii{\arabic{enumii}}}


\newenvironment{myenumerate}{\begin{enumerate}\ifx\c@enumii\undefined\relax\else\settozero\fi}{\end{enumerate}}
\begin{document}
\begin{enumerate}
\item  

\begin{myenumerate}
\item  I do not feel sad. 
\item  I feel sad 
\item I am sad all the time and I can't snap out of it. 
\item I am so sad and unhappy that I can't stand it.
\end{myenumerate}

\item
\begin{myenumerate}
   \item Test 0
   \item Test 1
\end{myenumerate}

\end{enumerate}
\end{document}

输出:

在此处输入图片描述

答案2

\documentclass{article}
\usepackage{enumitem}
\begin{document}
\begin{enumerate}
\item  
\begin{enumerate}[label=\arabic*,itemindent=.5in,labelsep=.5in,start=0]
\item[]
\item  I do not feel sad. 
\item  I feel sad 
\item I am sad all the time and I can't snap out of it. 
\item I am so sad and unhappy that I can't stand it.
\end{enumerate}
\end{enumerate}
\end{document}

在此处输入图片描述

相关内容