![自动生成字段的签到表多种规则](https://linux22.com/image/278049/%E8%87%AA%E5%8A%A8%E7%94%9F%E6%88%90%E5%AD%97%E6%AE%B5%E7%9A%84%E7%AD%BE%E5%88%B0%E8%A1%A8%E5%A4%9A%E7%A7%8D%E8%A7%84%E5%88%99.png)
我正在尝试制作一个具有多条规则的登录表,它可以生成我需要的不同场合所需的任意数量的字段。我有一个可行的解决方案,但我不知道如何使每个条目在必要时都有两条或三条规则。这是我目前的代码。
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\documentclass{article}
\usepackage[top=1in, right=1in, left=1in, bottom=1in]{geometry}
\usepackage{mathspec}
\setmainfont{Times New Roman}
\setmonofont{Lucida Sans Typewriter}
\usepackage{titling}
\title{ Computer Sign In Sheet}
\author{\ttfamily Physics Department}
\date{}
\usepackage{mathabx}
\usepackage{xkeyval}
\makeatletter
\define@key{setpar}{left}[0pt]{\leftmargin=#1}
\define@key{setpar}{right}[0pt]{\rightmargin=#1}
\define@key{setpar}{both}{\leftmargin=#1\relax\rightmargin=#1}
\usepackage{titling, xcolor}
\definecolor{title}{HTML}{000000}
\definecolor{title2}{HTML}{000000}
\pretitle{\begin{center}\hspace{0cm}\Huge\textcolor{title} \ttfamily} % %% center can also be flushrig%
\posttitle{\par\end{center} } %% don't use centering %%%%
\preauthor{\begin{center}\large\rmfamily\vskip 0mm } %%%% \scshape give small caps fonts %%%
\postauthor{\end{center} }
\predate{\begin{center}\large\scshape \vskip -1cm}
\postdate{\end{center} \vskip 2mm}
\usepackage{calc}
\newenvironment{instructions}[1][both=1.5in]
{\normalsize\list{}{\setkeys{setpar}{left,right}%
\setkeys{setpar}{#1}%
\listparindent=0em
\topsep=0pt
\partopsep=0pt
\parsep=0ex}\item\relax\hspace{\listparindent}\ignorespaces}
{\endlist\vspace{3ex}}
\begin{document}
\ttfamily
\maketitle
\rmfamily
\begin{instructions}
Please sign your name below on the line corresponding to the computer that you are going to use for the day. You must sign for the computer in order to borrow it. Please sign in all of your group members. Thank you.
\end{instructions}
\vspace{5ex}
%\setlength{\parindent}{0ex}
\newcounter{computer}
\newcommand{\makelines}[1]{ \mbox{\noindent Computer no. #1 \rule{0.35\textwidth }{0.1 ex} }}
\setcounter{computer}{1}
\noindent
\@whilenum{\value{computer}<20}\do{%
\makelines{\thecomputer}\vspace{2em} \hfill%
\addtocounter{computer}{1}}%
\newpage\stepcounter{computer}
\end{document}
答案1
我不得不放弃 mathspec 才能让它在我的系统上运行。我猜这就是你所说的多条规则。你意识到你正在向右边距推进,因此需要 \mbox。
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\documentclass{article}
\usepackage[top=1in, right=1in, left=1in, bottom=1in]{geometry}
%\usepackage{mathspec}
%\setmainfont{Times New Roman}
%\setmonofont{Lucida Sans Typewriter}
\usepackage{titling}
\title{ Computer Sign In Sheet}
\author{\ttfamily Physics Department}
\date{}
\usepackage{mathabx}
\usepackage{xkeyval}
\makeatletter
\define@key{setpar}{left}[0pt]{\leftmargin=#1}
\define@key{setpar}{right}[0pt]{\rightmargin=#1}
\define@key{setpar}{both}{\leftmargin=#1\relax\rightmargin=#1}
\usepackage{titling, xcolor}
\definecolor{title}{HTML}{000000}
\definecolor{title2}{HTML}{000000}
\pretitle{\begin{center}\hspace{0cm}\Huge\textcolor{title} \ttfamily} % %% center can also be flushrig%
\posttitle{\par\end{center} } %% don't use centering %%%%
\preauthor{\begin{center}\large\rmfamily\vskip 0mm } %%%% \scshape give small caps fonts %%%
\postauthor{\end{center} }
\predate{\begin{center}\large\scshape \vskip -1cm}
\postdate{\end{center} \vskip 2mm}
\usepackage{calc}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{xparse}
% \newcommand{\append}[2] #1=text to repeat, #2=number or repetitions
\ExplSyntaxOn
\DeclareExpandableDocumentCommand{\append}{mm}
{
\prg_replicate:nn{#2}{#1}
}
\ExplSyntaxOff
\def\NumberRulesPerComputer{3}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newenvironment{instructions}[1][both=1.5in]
{\normalsize\list{}{\setkeys{setpar}{left,right}%
\setkeys{setpar}{#1}%
\listparindent=0em
\topsep=0pt
\partopsep=0pt
\parsep=0ex}\item\relax\hspace{\listparindent}\ignorespaces}
{\endlist\vspace{3ex}}
\begin{document}
\ttfamily
\maketitle
\rmfamily
\begin{instructions}
Please sign your name below on the line corresponding to the computer that you are going to use for the day. You must sign for the computer in order to borrow it. Please sign in all of your group members. Thank you.
\end{instructions}
\vspace{5ex}
\setlength{\parindent}{0ex}
\newcounter{computer}
\newcommand{\makelines}[1]{\mbox{Computer no. #1%
\parbox[t]{0.35\textwidth}{\append{\rule{0pt}{3em}
\rule{0.35\textwidth}{0.1 ex}\\}
{\NumberRulesPerComputer}}}}
\setcounter{computer}{1}
\noindent
\@whilenum{\value{computer}<20}\do{%
\makelines{\thecomputer}\vspace{2em} \hfill%
\addtocounter{computer}{1}}%
\newpage\stepcounter{computer}
\end{document}