还有其他可能的连续编号方式吗?

还有其他可能的连续编号方式吗?

我正在使用考试类创建文档。我这里有四种问题类型,我为每种问题类型创建了一个命令。是否有工具可以强制对每种问题类型进行连续编号,而不是使用\begin{questions}以 结尾的编号\end{questions}

例子:

I. True or False Question type
 1. ____ text text text text text text.
 2. ____ text text text text text text.
 3. ____ text text text text text text.

II. Enumeration
 4. Elements of  nature
 5. text text text text text text.
 6. text text text text text text.

第一部分的数字序列在第二部分中继续。我怎样才能制作出类似这样的作品?

答案1

尝试一下这个enumitem包:

\documentclass{article}
\usepackage{enumitem}

\begin{document}

\begin{enumerate}
  \item First question
  \item Second question
\end{enumerate}

Some other stuff...

\begin{enumerate}[resume]
  \item More items 
  \item ...
\end{enumerate}

\end{document}

对于更复杂的嵌套,您可能需要使用series包的选项。

答案2

如果您不想让问题编号从 1 重新开始,请不要结束环境questions。您可以使用标准 LaTeX\section命令插入章节标题,如果您将命令括\section在命令的参数中\fullwidth,则不会缩进。例如,如果您输入

\documentclass[12pt]{exam}
\begin{document}
\renewcommand{\thesection}{\Roman{section}}
\begin{questions}
\fullwidth{\section{True or false question types}}
  \question This is one of the questions.
  \question This is one of the questions.
  \question This is one of the questions.

\fullwidth{\section{Enumeration}}
  \question This is one of the questions.
  \question This is one of the questions.
  \question This is one of the questions.
\end{questions}
\end{document}

那么你会得到

在此处输入图片描述

答案3

简单地说\setcounter{tfno}{0},在定义truefalse环境之前,就像下面的代码一样:

\documentclass{article}
\usepackage{amssymb,graphicx}
\usepackage{array,enumitem}
\usepackage{longtable}
\newcounter{tfno}
\renewcommand\arraystretch{2}
\newcommand{\mybox}{\resizebox{.5cm}{!}{\raisebox{-.5ex}{$\Box$}}}
%
\setcounter{tfno}{0} %% moved here
\newenvironment{truefalse}{%
%\setcounter{tfno}{0}  %% moved up
\setlength\LTleft{0pt}
\setlength\LTright{0pt}
\begin{longtable}{>{\stepcounter{tfno}\thetfno.}cp{.5\textwidth}@{\extracolsep{\fill}}cc}
\multicolumn{1}{r}{}&  & \fbox{\parbox{.75cm}{True}} & \fbox{\parbox{.75cm}{False}}  \\
}{%
\end{longtable}
}
\newcommand\tfquestion[1]{ & #1 & \mybox  & \mybox  \\}
\begin{document}
\begin{enumerate}[label=\Roman*.]
\item First set of questions
\begin{truefalse}
  \tfquestion{This is a sample text.}
  \tfquestion{This is another sample short text.}
  \tfquestion{This is a long line containing text and wrapping into second line without hitting the boxes}
\end{truefalse}
%
\item Second set comes here.
\begin{truefalse}
  \tfquestion{This is a sample text.}
  \tfquestion{This is another sample short text.}
  \tfquestion{This is a long line containing text and wrapping into second line without hitting the boxes}
\end{truefalse}
\end{enumerate}

\end{document}

在此处输入图片描述

相关内容