我知道这里至少已经有一个关于如何设置批准表的问题。但是,我现在带给您的问题略有不同,因为问题本身涉及如何自动化考试委员会成员人数。通常,根据学生所属的课程,委员会可能由三名、四名、五名或更多成员组成。因此,我想编写一个代码,在其中我可以在文档序言中告知以下信息:1 - 告知考试委员会成员人数;2 - 输入第一位成员的姓名;3 - 告知第一位成员的职称;4 - 告知第一位成员的机构,等等。当然,当我告知委员会中出席的成员人数时,第 2、3 和 4 项会重复。是否有可能创建这样的代码?
下面,我给出一个简单的例子。
\documentclass[12pt,a4paper]{memoir}
\parindent0pt
\setSpacing{1.5}
\abnormalparskip{0.2\baselineskip}%
\setlength{\parindent}{1.5cm}%
\renewcommand*{\footnoterule}{\kern -3pt \hrule width 50mm \kern
2.6pt}%
\setlrmarginsandblock{30mm}{20mm}{*}%
\setulmarginsandblock{30mm}{20mm}{*}%
\setheadfoot{\baselineskip}{2\baselineskip}
\setheaderspaces{20.0mm}{*}{*}%
\setmarginnotes{2.0mm}{16mm}{5.0mm}%
\setcolsepandrule{3.5mm}{0.15mm}
\setfootins{\bigskipamount}{\bigskipamount}
\checkandfixthelayout[fixed]
\newcommand{\committeemembernumber}[1]{#1}
\newcommand{\memberonename}[1]{\gdef\thememberonename{#1}}
\newcommand{\memberoneinstitute}[1]{\gdef\thememberoneinstitute{#1}}
\newcommand{\membertwoname}[1]{\gdef\themembertwoname{#1}}
\newcommand{\membertwoinstitute}[1]{\gdef\themembertwoinstitute{#1}}
\newcommand{\memberthreename}[1]{\gdef\thememberthreename{#1}}
\newcommand{\memberthreeinstitute}[1]{\gdef\thememberthreeinstitute{#1}}
\newcommand{\memberfourname}[1]{\gdef\thememberfourname{#1}}
\newcommand{\memberfourinstitute}[1]{\gdef\thememberfourinstitute{#1}}
\newcommand{\memberfivename}[1]{\gdef\thememberfivename{#1}}
\newcommand{\memberfiveinstitute}[1]{\gdef\thememberfiveinstitute{#1}}
\title{Approval sheet: an example for the LaTeX}
\author{Alexsandro Lucena Mota}
\date{2020}
%\committeemembernumber{3}
\memberonename{Prof.~MA. Sir Isaac Newton}
\memberoneinstitute{Trinity College -- University of Cambrigde}
\membertwoname{Prof.~PhD. Albert Einstein}
\membertwoinstitute{Institute for Advanced Study (IAS)}
\memberthreename{Prof. PhD. Paul Adrien Maurice Dirac}
\memberthreeinstitute{Florida State University}
\memberfourname{Prof. PhD. Richard Phillips Feynman}
\memberfourinstitute{California Institute of Technology -- Caltech}
\memberfivename{Prof. PhD. Murray Gell-Mann}
\memberfiveinstitute{California Institute of Technology -- Caltech}
\begin{document}
\thispagestyle{empty}
\begin{center}
{\large \theauthor\par}
\vspace{\baselineskip}
{\Large
\begin{OnehalfSpace}%
\bfseries\thetitle\par%
\end{OnehalfSpace}%
}
\vspace{0.0cm}
\end{center}
\begin{flushright}%
\begin{minipage}{0.55\textwidth}%
\begin{SingleSpacing}%
{\small Doctoral thesis presented at Postgraduate
Program in Physics of the Universidade Federal do
Maranhão as prerequisite to obtain the Doctoral
degree.}\par
{\small {\bfseries Research line:} Topological
field theory with Lorentz symmetry breaking.}\par%
\end{SingleSpacing}%
\end{minipage}%
\end{flushright}
\vspace{\baselineskip}
Approval in: \rule[0.0cm]{3cm}{0.04cm}~
\rule[0.0cm]{1cm}{0.04cm},~\thedate.\par
\vspace{\baselineskip}
\begin{center}
{\Large Examining Committee}\par%
\vspace{\baselineskip}
\begin{SingleSpacing}
\rule{12cm}{0.04cm}\par%
\thememberonename\par%
\thememberoneinstitute\par
\vspace{1.9\baselineskip}
\rule{12cm}{0.04cm}\par
\themembertwoname\par%
\themembertwoinstitute\par
\vspace{1.9\baselineskip}
\rule{12cm}{0.04cm}\par
\thememberthreename\par
\thememberthreeinstitute\par
\vspace{1.9\baselineskip}
\rule{12cm}{0.04cm}\par
\thememberfourname\par%
\thememberfourinstitute\par
\vspace{1.9\baselineskip}
\rule{12cm}{0.04cm}\par
\thememberfivename\par
\thememberfiveinstitute\par
\end{SingleSpacing}
\end{center}
\end{document}
本代码提供以下pdf文档:
答案1
这是实现此目的的一种方法。基本思路是使用单个命令:
\member{<name>}{<institute>}
这将自动分配委员会的成员资格,并跟踪有多少人。然后,使用跟踪成员的计数器为每个委员会名称/隶属关系赋予一个唯一的名称。这是使用包提供的\csgdef
包装器完成的。然后,我们使用该计数器和循环(使用包)来生成正确数量的成员行(当然,受页面上空间的限制)。\csname ... \endcsname
etoolbox
pgffor
\documentclass[12pt,a4paper]{memoir}
\parindent0pt
\setSpacing{1.5}
\abnormalparskip{0.2\baselineskip}%
\setlength{\parindent}{1.5cm}%
\renewcommand*{\footnoterule}{\kern -3pt \hrule width 50mm \kern
2.6pt}%
\setlrmarginsandblock{30mm}{20mm}{*}%
\setulmarginsandblock{30mm}{20mm}{*}%
\setheadfoot{\baselineskip}{2\baselineskip}
\setheaderspaces{20.0mm}{*}{*}%
\setmarginnotes{2.0mm}{16mm}{5.0mm}%
\setcolsepandrule{3.5mm}{0.15mm}
\setfootins{\bigskipamount}{\bigskipamount}
\checkandfixthelayout[fixed]
\usepackage{etoolbox}
\usepackage{pgffor}
\newcounter{committee}
\newcommand{\member}[2]{\stepcounter{committee}\csgdef{member\thecommittee}{#1}
\csgdef{institute\thecommittee}{#2}}
\title{Approval sheet: an example for the LaTeX}
\author{Alexsandro Lucena Mota}
\date{2020}
\member{Prof.~MA. Sir Isaac Newton}{Trinity College -- University of Cambridge}
\member{Prof.~PhD. Albert Einstein}{Institute for Advanced Study (IAS)}
\member{Prof. PhD. Paul Adrien Maurice Dirac}{Florida State University}
\member{Prof. PhD. Richard Phillips Feynman}{California Institute of Technology -- Caltech}
\member{Prof. PhD. Murray Gell-Mann}{California Institute of Technology -- Caltech}
\begin{document}
\thispagestyle{empty}
\begin{center}
{\large \theauthor\par}
\vspace{\baselineskip}
{\Large
\begin{OnehalfSpace}%
\bfseries\thetitle\par%
\end{OnehalfSpace}%
}
\vspace{0.0cm}
\end{center}
\begin{flushright}%
\begin{minipage}{0.55\textwidth}%
\begin{SingleSpacing}%
{\small Doctoral thesis presented at Postgraduate
Program in Physics of the Universidade Federal do
Maranhão as prerequisite to obtain the Doctoral
degree.}\par
{\small {\bfseries Research line:} Topological
field theory with Lorentz symmetry breaking.}\par%
\end{SingleSpacing}%
\end{minipage}%
\end{flushright}
\vspace{\baselineskip}
Approval in: \rule[0.0cm]{3cm}{0.04cm}~
\rule[0.0cm]{1cm}{0.04cm},~\thedate.\par
\vspace{\baselineskip}
\begin{center}
{\Large Examining Committee}\par%
\vspace{\baselineskip}
\begin{SingleSpacing}
\foreach \x in {1,...,\value{committee}}{
\rule{12cm}{0.04cm}\par%
\csuse{member\x}\par%
\csuse{institute\x}\par
\vspace{1.9\baselineskip}
}
\end{SingleSpacing}
\end{center}
\end{document}