使用 forloop 指定项目数时,枚举中的多列行为异常

使用 forloop 指定项目数时,枚举中的多列行为异常

我正在使用文档类,并且当使用来指定项目数时,exam我观察到枚举环境中的列中断行为异常。forloop

当我使用 forloop 生成响应行的枚举列表时,我得到以下内容:在此处输入图片描述

但是,当我手动生成枚举列表时,我得到以下信息:在此处输入图片描述

以下是产生这两种结果的 MWE:

\documentclass[11pt,addpoints]{exam}

\usepackage[paperwidth=8.5in, paperheight=11in, hmargin={20mm,20mm}, vmargin={20mm,12mm}, includefoot, footskip=10mm]{geometry}
\usepackage{amsmath,amssymb} %math basics
\usepackage{titlesec} %for formatting section titles
\usepackage{multicol,tikz,cancel} %document basics
\usepackage{forloop} %for specifying number of questions on answer page

\newcommand*\circled[1]{\tikz[baseline=(char.base)]{
        \node[shape=circle,draw,inner sep=2pt] (char) {#1};}}
\newcommand{\tikzcircle}[2][black,fill=black]{\tikz[baseline=-0.75ex]\draw[#1,radius=#2] (0,0) circle ;}

\titleformat{\section}[runin]{\normalfont\large\bfseries}{\hskip -24pt $\Box$ \hskip 6pt Part \thesection\ -- }{0pt}{}[\normalsize \qquad {[}Total Marks: \pointsinrange{\thesection}{]} \vspace{8pt} \\ \vspace{6pt}]

\renewcommand\thesection{\Alph{section}}

\pointsinrightmargin\bracketedpoints

\pagestyle{headandfoot}

\coverfirstpageheader{Semester \\ School Board \\ School \\ Location}{}{Teacher: Mr.\ Gartenburg \\ Number of Pages: \numpages \\ Total Marks: \pointsinrange{Total} \\ Duration: 2.0 hours}
\coverrunningheader{\footnotesize\textsc{MCV4U1-02: Calculus \& Vectors}}{\textsc{Formulae}}{\footnotesize\textsc{Final Examination -- Month 2016}}
\coverrunningheadrule
\coverextraheadheight[0.75in]{0in}

\headrule
\header{\footnotesize\textsc{MCV4U1-02: Calculus \& Vectors}}{}{\footnotesize\textsc{Final Examination}, Part 1 of 2 -- \textsc{Month 2016}}
\footer{}{\thepage\ of \numpages}{}

\setlength\parindent{0pt}

\begin{document}
\begin{coverpages} \null \vspace{1.25in}
\begin{center}
\textsc{\Large MCV4U1--01} \\ \vspace{2mm}
\textsc{\large Grade 12 University Calculus \& Vectors} \\ \vspace{8mm}
{\bfseries{\scshape{\Large Final Examination}}} \\ \vspace{3mm}
\textbf{-- \ Part 1 of 2 \ --} \\ \vspace{6mm}
\textsc{{\large \today}} \\ \vspace{1in}
\textsc{\large Name: \ \ \underline{\hspace{3.5in}}}
\end{center} \vspace{0.5in}

\underline{Instructions}:
\begin{itemize}
    \item Calculators or other electronic devices are permitted provided they do \textbf{not} have wireless connectivity, are \textbf{not} capable of any symbolic or graphical computations and/or representations, do \textbf{not} store or play any media or other document files, and are used in a way that is \textbf{not} distracting to others.
    \item Any formulae, equations, etc.\ that are provided are \emph{on the reverse of this page}.
    \item Clearly demonstrate your knowledge and understanding by
    \begin{itemize}
        \item reading all questions \textbf{carefully},
        \item answering all questions \textbf{fully}, and
        \item providing concluding statements with correct \textbf{units}, where appropriate.
    \end{itemize}
    \item Round all answers to one decimal place, unless otherwise specified.
    \item Answers to all \textbf{True/False} and \textbf{Multiple Choice} questions must be provided on the \emph{Multiple Choice Answer Sheet}, which may be removed and submitted separately for convenience.
    \item Solutions to all \textbf{Full Answer} questions must be provided on the exam paper in the space provided.  (You may use the blank side of each page for rough work, but this will \textbf{not} be marked.)
\end{itemize}
\newpage \null \vspace{1in}
$$\text{some formulae}$$
\end{coverpages}
\begin{questions}
\section{True/False}
\uplevel{\hspace{-18pt} Indicate if each statement is \textbf{True} or \textbf{False}.  Record your answers on the \emph{Multiple Choice Answer Sheet}.}
\begingradingrange{Total}
\begingradingrange{A}
    \question[1] a  \label{firstA}
    \question[1] a
    \question[1] a
    \question[1] a
    \question[1] a
    \question[1] a
    \question[1] a
    \question[1] a
    \question[1] a
    \question[1] a
    \question[1] a
    \question[1] a
    \question[1] a
    \question[1] a
    \question[1] a
    \question[1] a
    \question[1] a
    \question[1] a
    \question[1] a
    \question[1] a
    \question[1] a
    \question[1] a
    \question[1] a
    \question[1] a
    \question[1] a \label{lastA}
\endgradingrange{A} \newpage
\section{Multiple Choice}
\uplevel{\hspace{-18pt} Indicate the \textbf{most appropriate} response.  Record your answers on the \emph{Multiple Choice Answer Sheet}.}
\begingradingrange{B}
    \question[1] a \label{firstB}
    \question[1] a
    \question[1] a
    \question[1] a
    \question[1] a
    \question[1] a
    \question[1] a
    \question[1] a \label{lastB}
\endgradingrange{B} \newpage
\section{Full Answer} 
\uplevel{\hspace{-18pt} Provide \textbf{full solutions} in the space provided.}
\begingradingrange{C}
    \question[4] a \label{firstC}
    \question[4] a
    \question[8] a
    \question[3] a
    \question[5] a
    \question[3] a
    \question[8] a
    \question[3] a
    \question[4] a
    \question[3] a
    \question[7] a
\endgradingrange{C}
\endgradingrange{Total}
\end{questions}

\newpage

\null \vspace{0.125in}

\begin{centering}
{\LARGE Multiple Choice Answer Sheet} \vspace{0.625in} \\
\textsc{\large Name: \ \ \underline{\hspace{3.5in}}} \vspace{0.625in} \\
\end{centering} \label{answersheet}

\textsc{\large Instructions:} \vspace{2mm}

\quad Use a \textbf{solid dot} to ``block out'' your response to each question. \vspace{3mm}

\begin{tabular}{ll}
Correct: \hspace{4mm} T \hspace{10mm} \tikzcircle{7pt} & Incorrect: \hspace{4mm} T \hspace{10mm} \circled{F} \vspace{5mm} \\
Correct: \hspace{4mm} \tikzcircle{7pt} \hspace{10mm} B \hspace{10mm} C \hspace{10mm} D \hspace{0.375in} & Incorrect:  \hspace{4mm} \xcancel{A} \hspace{10mm} B \hspace{10mm} C \hspace{10mm} D
\end{tabular}\vspace{0.5in}

\textbf{Part A -- True/False} \newcounter{j}

\begin{enumerate}
\begin{multicols}{4} \raggedcolumns
\forloop{j}{\ref{firstA}}{\value{j}<\ref{lastA}}{\item \hspace{4mm} T \hspace{10mm} F}
\item \hspace{4mm} T \hspace{10mm} F
\end{multicols}
\end{enumerate} \vspace{0.25in}

\textbf{Part B -- Multiple Choice}

\begin{enumerate}
\begin{multicols}{2} \setcounter{enumi}{\ref{lastA}} \raggedcolumns
\forloop{j}{\ref{firstB}}{\value{j}<\ref{lastB}}{\item \hspace{4mm} A \hspace{10mm} B \hspace{10mm} C \hspace{10mm} D}
\item \hspace{4mm} A \hspace{10mm} B \hspace{10mm} C \hspace{10mm} D
\end{multicols}
\end{enumerate} \newpage \null \vspace{0.125in}

\begin{centering}
{\LARGE Multiple Choice Answer Sheet} \vspace{0.625in} \\
\textsc{\large Name: \ \ \underline{\hspace{3.5in}}} \vspace{0.625in} \\
\end{centering} \label{answersheet}

\textsc{\large Instructions:} \vspace{2mm}

\quad Use a \textbf{solid dot} to ``block out'' your response to each question. \vspace{3mm}

\begin{tabular}{ll}
Correct: \hspace{4mm} T \hspace{10mm} \tikzcircle{7pt} & Incorrect: \hspace{4mm} T \hspace{10mm} \circled{F} \vspace{5mm} \\
Correct: \hspace{4mm} \tikzcircle{7pt} \hspace{10mm} B \hspace{10mm} C \hspace{10mm} D \hspace{0.375in} & Incorrect:  \hspace{4mm} \xcancel{A} \hspace{10mm} B \hspace{10mm} C \hspace{10mm} D
\end{tabular} \vspace{0.5in}

\textbf{Part A -- True/False}
\begin{enumerate}
\begin{multicols}{4} \raggedcolumns
    \item \hspace{4mm} T \hspace{10mm} F
    \item \hspace{4mm} T \hspace{10mm} F
    \item \hspace{4mm} T \hspace{10mm} F
    \item \hspace{4mm} T \hspace{10mm} F
    \item \hspace{4mm} T \hspace{10mm} F
    \item \hspace{4mm} T \hspace{10mm} F
    \item \hspace{4mm} T \hspace{10mm} F
    \item \hspace{4mm} T \hspace{10mm} F
    \item \hspace{4mm} T \hspace{10mm} F
    \item \hspace{4mm} T \hspace{10mm} F
    \item \hspace{4mm} T \hspace{10mm} F
    \item \hspace{4mm} T \hspace{10mm} F
    \item \hspace{4mm} T \hspace{10mm} F
    \item \hspace{4mm} T \hspace{10mm} F
    \item \hspace{4mm} T \hspace{10mm} F
    \item \hspace{4mm} T \hspace{10mm} F
    \item \hspace{4mm} T \hspace{10mm} F
    \item \hspace{4mm} T \hspace{10mm} F
    \item \hspace{4mm} T \hspace{10mm} F
    \item \hspace{4mm} T \hspace{10mm} F
    \item \hspace{4mm} T \hspace{10mm} F
    \item \hspace{4mm} T \hspace{10mm} F
    \item \hspace{4mm} T \hspace{10mm} F
    \item \hspace{4mm} T \hspace{10mm} F
    \item \hspace{4mm} T \hspace{10mm} F
\end{multicols}
\end{enumerate} \vspace{0.25in}

\textbf{Part B -- Multiple Choice}
\begin{enumerate}\setcounter{enumi}{25}
\begin{multicols}{2}
    \item \hspace{4mm} A \hspace{10mm} B \hspace{10mm} C \hspace{10mm} D
    \item \hspace{4mm} A \hspace{10mm} B \hspace{10mm} C \hspace{10mm} D
    \item \hspace{4mm} A \hspace{10mm} B \hspace{10mm} C \hspace{10mm} D
    \item \hspace{4mm} A \hspace{10mm} B \hspace{10mm} C \hspace{10mm} D
    \item \hspace{4mm} A \hspace{10mm} B \hspace{10mm} C \hspace{10mm} D
    \item \hspace{4mm} A \hspace{10mm} B \hspace{10mm} C \hspace{10mm} D
    \item \hspace{4mm} A \hspace{10mm} B \hspace{10mm} C \hspace{10mm} D
    \item \hspace{4mm} A \hspace{10mm} B \hspace{10mm} C \hspace{10mm} D
\end{multicols}
\end{enumerate}

\end{document}

如有任何建议或修复,我们将不胜感激。

答案1

“MWE” 很难读懂,但主要问题是

  • \begin{enumerate}\begin{multicols}{4}看起来不对→反过来用
  • \forloop初始化\ref{firstA},它不可扩展或提供的内容不是实数(整数)。这个循环搞砸了。为了获取引用计数器值,请使用,当然要为此\getrefnumber{firstA}加载包。使用这个会混淆命令,在枚举列表中留下垃圾,也会造成混淆。refcount\ref{firstA}\forloopmulticols
  • 的起始值enumerate应该由enumitem包及其start=选项来enumerate代替\setcounter{enumi}{...}(我在这里没有这样做!)

\documentclass[11pt,addpoints]{exam}

\usepackage[paperwidth=8.5in, paperheight=11in, hmargin={20mm,20mm}, vmargin={20mm,12mm}, includefoot, footskip=10mm]{geometry}
\usepackage{amsmath,amssymb} %math basics
\usepackage{titlesec} %for formatting section titles
\usepackage{multicol,tikz,cancel} %document basics
\usepackage{refcount}%
\usepackage{forloop} %for specifying number of questions on answer page

\newcounter{j}

\newcommand*\circled[1]{\tikz[baseline=(char.base)]{
        \node[shape=circle,draw,inner sep=2pt] (char) {#1};}}
\newcommand{\tikzcircle}[2][black,fill=black]{\tikz[baseline=-0.75ex]\draw[#1,radius=#2] (0,0) circle ;}

\titleformat{\section}[runin]{\normalfont\large\bfseries}{\hskip -24pt $\Box$ \hskip 6pt Part \thesection\ -- }{0pt}{}[\normalsize \qquad {[}Total Marks: \pointsinrange{\thesection}{]} \vspace{8pt} \\ \vspace{6pt}]

\renewcommand\thesection{\Alph{section}}

\pointsinrightmargin\bracketedpoints

\pagestyle{headandfoot}

\coverfirstpageheader{Semester \\ School Board \\ School \\ Location}{}{Teacher: Mr.\ Gartenburg \\ Number of Pages: \numpages \\ Total Marks: \pointsinrange{Total} \\ Duration: 2.0 hours}
\coverrunningheader{\footnotesize\textsc{MCV4U1-02: Calculus \& Vectors}}{\textsc{Formulae}}{\footnotesize\textsc{Final Examination -- Month 2016}}
\coverrunningheadrule
\coverextraheadheight[0.75in]{0in}

\headrule
\header{\footnotesize\textsc{MCV4U1-02: Calculus \& Vectors}}{}{\footnotesize\textsc{Final Examination}, Part 1 of 2 -- \textsc{Month 2016}}
\footer{}{\thepage\ of \numpages}{}

\setlength\parindent{0pt}

\begin{document}
\begin{coverpages} \null \vspace{1.25in}
\begin{center}
\textsc{\Large MCV4U1--01} \\ \vspace{2mm}
\textsc{\large Grade 12 University Calculus \& Vectors} \\ \vspace{8mm}
{\bfseries{\scshape{\Large Final Examination}}} \\ \vspace{3mm}
\textbf{-- \ Part 1 of 2 \ --} \\ \vspace{6mm}
\textsc{{\large \today}} \\ \vspace{1in}
\textsc{\large Name: \ \ \underline{\hspace{3.5in}}}
\end{center} \vspace{0.5in}

\underline{Instructions}:
\begin{itemize}
    \item Calculators or other electronic devices are permitted provided they do \textbf{not} have wireless connectivity, are \textbf{not} capable of any symbolic or graphical computations and/or representations, do \textbf{not} store or play any media or other document files, and are used in a way that is \textbf{not} distracting to others.
    \item Any formulae, equations, etc.\ that are provided are \emph{on the reverse of this page}.
    \item Clearly demonstrate your knowledge and understanding by
    \begin{itemize}
        \item reading all questions \textbf{carefully},
        \item answering all questions \textbf{fully}, and
        \item providing concluding statements with correct \textbf{units}, where appropriate.
    \end{itemize}
    \item Round all answers to one decimal place, unless otherwise specified.
    \item Answers to all \textbf{True/False} and \textbf{Multiple Choice} questions must be provided on the \emph{Multiple Choice Answer Sheet}, which may be removed and submitted separately for convenience.
    \item Solutions to all \textbf{Full Answer} questions must be provided on the exam paper in the space provided.  (You may use the blank side of each page for rough work, but this will \textbf{not} be marked.)
\end{itemize}
\newpage \null \vspace{1in}
 %    $$\text{some formulae}$$
\end{coverpages}
\begin{questions}
\section{True/False}
\uplevel{\hspace{-18pt} Indicate if each statement is \textbf{True} or \textbf{False}.  Record your answers on the \emph{Multiple Choice Answer Sheet}.}
\begingradingrange{Total}
\begingradingrange{A}
    \question[1] a  \label{firstA}
    \question[1] a
    \question[1] a
    \question[1] a
    \question[1] a
    \question[1] a
    \question[1] a
    \question[1] a
    \question[1] a
    \question[1] a
    \question[1] a
    \question[1] a
    \question[1] a
    \question[1] a
    \question[1] a
    \question[1] a
    \question[1] a
    \question[1] a
    \question[1] a
    \question[1] a
    \question[1] a
    \question[1] a
    \question[1] a
    \question[1] a
    \question[1] a \label{lastA}
\endgradingrange{A} \newpage
\section{Multiple Choice}
\uplevel{\hspace{-18pt} Indicate the \textbf{most appropriate} response.  Record your answers on the \emph{Multiple Choice Answer Sheet}.}
\begingradingrange{B}
    \question[1] a \label{firstB}
    \question[1] a
    \question[1] a
    \question[1] a
    \question[1] a
    \question[1] a
    \question[1] a
    \question[1] a \label{lastB}
\endgradingrange{B} \newpage
\section{Full Answer} 
\uplevel{\hspace{-18pt} Provide \textbf{full solutions} in the space provided.}
\begingradingrange{C}
    \question[4] a \label{firstC}
    \question[4] a
    \question[8] a
    \question[3] a
    \question[5] a
    \question[3] a
    \question[8] a
    \question[3] a
    \question[4] a
    \question[3] a
    \question[7] a
\endgradingrange{C}
\endgradingrange{Total}
\end{questions}

\newpage

\null \vspace{0.125in}

\begin{centering}
{\LARGE Multiple Choice Answer Sheet} \vspace{0.625in} \\
\textsc{\large Name: \ \ \underline{\hspace{3.5in}}} \vspace{0.625in} \\
\end{centering} \label{answersheet}

\textsc{\large Instructions:} \vspace{2mm}

\quad Use a \textbf{solid dot} to ``block out'' your response to each question. \vspace{3mm}

\begin{tabular}{ll}
Correct: \hspace{4mm} T \hspace{10mm} \tikzcircle{7pt} & Incorrect: \hspace{4mm} T \hspace{10mm} \circled{F} \vspace{5mm} \\
Correct: \hspace{4mm} \tikzcircle{7pt} \hspace{10mm} B \hspace{10mm} C \hspace{10mm} D \hspace{0.375in} & Incorrect:  \hspace{4mm} \xcancel{A} \hspace{10mm} B \hspace{10mm} C \hspace{10mm} D
\end{tabular}\vspace{0.5in}

\textbf{Part A -- True/False} 

\begin{multicols}{4} \raggedcolumns
\begin{enumerate}
  \forloop{j}{\getrefnumber{firstA}}{\value{j}<\getrefnumber{lastA}}{\item \hspace{4mm} T \hspace{10mm} F}
\item \hspace{4mm} T \hspace{10mm} F
\end{enumerate} 
\vspace{0.25in}
\end{multicols}

\textbf{Part B -- Multiple Choice}

\begin{multicols}{2} \setcounter{enumi}{\ref{lastA}} \raggedcolumns
\begin{enumerate}
\forloop{j}{\ref{firstB}}{\value{j}<\ref{lastB}}{\item \hspace{4mm} A \hspace{10mm} B \hspace{10mm} C \hspace{10mm} D}
\item \hspace{4mm} A \hspace{10mm} B \hspace{10mm} C \hspace{10mm} D
\end{enumerate} \newpage \null \vspace{0.125in}
\end{multicols}

\begin{centering}
{\LARGE Multiple Choice Answer Sheet} \vspace{0.625in} \\
\textsc{\large Name: \ \ \underline{\hspace{3.5in}}} \vspace{0.625in} \\
\end{centering} \label{answersheet}

\textsc{\large Instructions:} \vspace{2mm}

\quad Use a \textbf{solid dot} to ``block out'' your response to each question. \vspace{3mm}

\begin{tabular}{ll}
Correct: \hspace{4mm} T \hspace{10mm} \tikzcircle{7pt} & Incorrect: \hspace{4mm} T \hspace{10mm} \circled{F} \vspace{5mm} \\
Correct: \hspace{4mm} \tikzcircle{7pt} \hspace{10mm} B \hspace{10mm} C \hspace{10mm} D \hspace{0.375in} & Incorrect:  \hspace{4mm} \xcancel{A} \hspace{10mm} B \hspace{10mm} C \hspace{10mm} D
\end{tabular} \vspace{0.5in}

\textbf{Part A -- True/False}
\begin{multicols}{4} \raggedcolumns
\begin{enumerate}
    \item \hspace{4mm} T \hspace{10mm} F
    \item \hspace{4mm} T \hspace{10mm} F
    \item \hspace{4mm} T \hspace{10mm} F
    \item \hspace{4mm} T \hspace{10mm} F
    \item \hspace{4mm} T \hspace{10mm} F
    \item \hspace{4mm} T \hspace{10mm} F
    \item \hspace{4mm} T \hspace{10mm} F
    \item \hspace{4mm} T \hspace{10mm} F
    \item \hspace{4mm} T \hspace{10mm} F
    \item \hspace{4mm} T \hspace{10mm} F
    \item \hspace{4mm} T \hspace{10mm} F
    \item \hspace{4mm} T \hspace{10mm} F
    \item \hspace{4mm} T \hspace{10mm} F
    \item \hspace{4mm} T \hspace{10mm} F
    \item \hspace{4mm} T \hspace{10mm} F
    \item \hspace{4mm} T \hspace{10mm} F
    \item \hspace{4mm} T \hspace{10mm} F
    \item \hspace{4mm} T \hspace{10mm} F
    \item \hspace{4mm} T \hspace{10mm} F
    \item \hspace{4mm} T \hspace{10mm} F
    \item \hspace{4mm} T \hspace{10mm} F
    \item \hspace{4mm} T \hspace{10mm} F
    \item \hspace{4mm} T \hspace{10mm} F
    \item \hspace{4mm} T \hspace{10mm} F
    \item \hspace{4mm} T \hspace{10mm} F
\end{enumerate} \vspace{0.25in}
\end{multicols}

\textbf{Part B -- Multiple Choice}
\begin{multicols}{2}
\begin{enumerate}\setcounter{enumi}{25}
    \item \hspace{4mm} A \hspace{10mm} B \hspace{10mm} C \hspace{10mm} D
    \item \hspace{4mm} A \hspace{10mm} B \hspace{10mm} C \hspace{10mm} D
    \item \hspace{4mm} A \hspace{10mm} B \hspace{10mm} C \hspace{10mm} D
    \item \hspace{4mm} A \hspace{10mm} B \hspace{10mm} C \hspace{10mm} D
    \item \hspace{4mm} A \hspace{10mm} B \hspace{10mm} C \hspace{10mm} D
    \item \hspace{4mm} A \hspace{10mm} B \hspace{10mm} C \hspace{10mm} D
    \item \hspace{4mm} A \hspace{10mm} B \hspace{10mm} C \hspace{10mm} D
    \item \hspace{4mm} A \hspace{10mm} B \hspace{10mm} C \hspace{10mm} D
\end{enumerate}
\end{multicols}

\end{document}

相关内容