![答题纸上的列。第二列和第三列连续编号?](https://linux22.com/image/311666/%E7%AD%94%E9%A2%98%E7%BA%B8%E4%B8%8A%E7%9A%84%E5%88%97%E3%80%82%E7%AC%AC%E4%BA%8C%E5%88%97%E5%92%8C%E7%AC%AC%E4%B8%89%E5%88%97%E8%BF%9E%E7%BB%AD%E7%BC%96%E5%8F%B7%EF%BC%9F.png)
我用了此指令由 Herbert 编写的答题纸。但是,我对第二列和第三列的编号有一个问题。我想让第二列和第三列连续编号吗?
\documentclass[11pt]{article}
\usepackage{geometry}
\usepackage{polski}
\usepackage[utf8]{inputenc}
\newgeometry{tmargin=1.5cm, bmargin=1cm, lmargin=1.5cm, rmargin=1.5cm}
\usepackage{multicol}
\usepackage{array}
\pagestyle{empty}
\parindent=0pt
\baselineskip=6.35mm
\parskip=0pt
\makeatletter
\newcommand*{\InitToks}{\toks@={}}
\newcommand{\AddToks}[1]{\toks@=\expandafter{\the\toks@ #1}}
\newcommand*{\PrintToks}{\the\toks@}
\unitlength=1mm
\def\BOX{\framebox(3.55,2){}}
\newcount\rowNo
\newcommand*{\dynTable}[1]{%
\begingroup
\InitToks
\AddToks{\tabcolsep=0pt\begin{tabular}{c*{11}{>{\centering}p{6.35mm}}}}%
\AddToks{&&A&B&C&D&E&\tabularnewline}
\rowNo=0 %
\loop\ifnum\rowNo<#1\relax
\advance\rowNo by 1
\AddToks{\strobe & }
\expandafter\AddToks\expandafter{%
\the\rowNo &
\BOX & \BOX & \BOX & \BOX & \BOX %
\tabularnewline}%
\repeat
\AddToks{\end{tabular}}%
\PrintToks
\endgroup}
\makeatother
\def\strobe{\rule{0pt}{4mm}\rule{3mm}{2.54mm}}
\begin{document}
\sffamily\small
{\large\begin{center}KARTA ODPOWIEDZI\end{center}}
Imię i nazwisko: \line(2,0){89}
\bigskip
\begin{multicols}{3}
\dynTable{40} % column 1
\dynTable{40} % column 2
\dynTable{40} % column 3
\end{multicols}
\end{document}
答案1
使用辅助计数器,即numberofquestions
每次行计数器增加时该计数器也会增加,但不会用新的列计数器重置。
由于涉及到标记扩展,因此需要将数字明确地写为 而\number\value{numberofquestions}
不是(在此代码中\thenumberofquestions
替换) 。\the\rowNo
翻过新的一页后,人们应该说\setcounter{numberofquestions}{0}
也许,除非当然应该继续计数。
\documentclass[11pt]{article}
\usepackage{geometry}
\usepackage{polski}
\usepackage[utf8]{inputenc}
\newgeometry{tmargin=1.5cm, bmargin=1cm, lmargin=1.5cm, rmargin=1.5cm}
\usepackage{multicol}
\usepackage{array}
\pagestyle{empty}
\parindent=0pt
\baselineskip=6.35mm
\parskip=0pt
\makeatletter
\newcommand*{\InitToks}{\toks@={}}
\newcommand{\AddToks}[1]{\toks@=\expandafter{\the\toks@ #1}}
\newcommand*{\PrintToks}{\the\toks@}
\unitlength=1mm
\def\BOX{\framebox(3.55,2){}}
\newcount\rowNo
\newcounter{numberofquestions}
\newcommand*{\dynTable}[1]{%
\begingroup
\InitToks
\AddToks{\tabcolsep=0pt\begin{tabular}{c*{11}{>{\centering}p{6.35mm}}}}%
\AddToks{&&A&B&C&D&E&\tabularnewline}
\rowNo=0 %
\loop\ifnum\rowNo<#1\relax
\advance\rowNo by 1
\stepcounter{numberofquestions}
\AddToks{\strobe & }
\expandafter\AddToks\expandafter{%
\number\value{numberofquestions} &
\BOX & \BOX & \BOX & \BOX & \BOX %
\tabularnewline}%
\repeat
\AddToks{\end{tabular}}%
\PrintToks
\endgroup}
\makeatother
\def\strobe{\rule{0pt}{4mm}\rule{3mm}{2.54mm}}
\begin{document}
\sffamily\small
{\large\begin{center}KARTA ODPOWIEDZI\end{center}}
Imię i nazwisko: \line(2,0){89}
\bigskip
\begin{multicols}{3}
\dynTable{40} % column 1
\dynTable{40} % column 2
\dynTable{40} % column 3
\end{multicols}
\end{document}