我正在和一位朋友一起写项目报告。问题是,在某个地方(例如titlepage
),我需要写下我们所有的详细信息,但在某个地方我只需要姓名。
以下是我想做的事情:
\documentclass{article}
\makeindex
\title{}
\author{Author 1 (Registration Number: XXXX, Email: XXXX) \\ \& Author 2 (Registration Number: YYYY, Email: YYYY)}
\begin{document}
% Title page contains the name and other details
\maketitle \clearpage
\section{Introduction}
\section*{Declaration}
% But, here I need only names and registration numbers separately
We, {\it the~authors individually} declare something.
\\
\\
\begin{minipage}[t]{0.5\linewidth}
Signature of Author 1 (Name only)\\ \\ \rule[0em]{15em}{0.5pt} \\ (Registration of Author 1) \\ \\ Date \\ \rule[0em]{15em}{0.5pt}
\end{minipage}%
\hfill
\begin{minipage}[t]{0.5\linewidth}
Signature of Author 2 (Name only)\\ \\ \rule[0em]{15em}{0.5pt} \\ (Registration of Author 2) \\ \\ Date \\ \rule[0em]{15em}{0.5pt}
\end{minipage}
\end{document}
有没有自动化的方法可以实现这一点?
此外,我还有一个问题:如何在签名和日期上添加虚线?
答案1
像这样:
声明两个命令如\FirstAuthor
和\SecondAuthor
,分别包含 的名称。
\documentclass{article}
\newcommand{\FirstAuthor}{John Doe}%
\newcommand{\SecondAuthor}{Jane Doe}%
\makeindex
\title{}
\author{\FirstAuthor (Registration Number: XXXX, Email: XXXX) \\ \& \SecondAuthor (Registration Number: YYYY, Email: YYYY)}
\begin{document}
% Title page contains the name and other details
\maketitle \clearpage
\section{Introduction}
\section*{Declaration}
% But, here I need only names and registration numbers separately
We, {\it the~authors individually} declare something.
\\
\\
\begin{minipage}[t]{0.5\linewidth}
Signature of \FirstAuthor \\ \\ \rule[0em]{15em}{0.5pt} \\ (Registration of \FirstAuthor) \\ \\ Date \\ \rule[0em]{15em}{0.5pt}
\end{minipage}%
\hfill
\begin{minipage}[t]{0.5\linewidth}
Signature of \SecondAuthor \\ \\ \rule[0em]{15em}{0.5pt} \\ (Registration of \SecondAuthor) \\ \\ Date \\ \rule[0em]{15em}{0.5pt}
\end{minipage}
\end{document}
编辑其他版本,只需一个\NameAuthor[]
命令:
\documentclass{article}
\usepackage{etoolbox}%
\newcommand{\NameAuthor}[1][3]{%
\ifnumequal{#1}{1}{%
John Doe}{Jane Doe}%
}%
\makeindex
\title{}
\author{\NameAuthor[1] (Registration Number: XXXX, Email: XXXX) \\ \& \NameAuthor{2} (Registration Number: YYYY, Email: YYYY)}
\begin{document}
% Title page contains the name and other details
\maketitle \clearpage
\section{Introduction}
\section*{Declaration}
% But, here I need only names and registration numbers separately
We, {\it the~authors individually} declare something.
\\
\\
\begin{minipage}[t]{0.5\linewidth}
Signature of \NameAuthor[1] \\ \\ \rule[0em]{15em}{0.5pt} \\ (Registration of \NameAuthor[1]) \\ \\ Date \\ \rule[0em]{15em}{0.5pt}
\end{minipage}%
\hfill
\begin{minipage}[t]{0.5\linewidth}
Signature of \NameAuthor[2] \\ \\ \rule[0em]{15em}{0.5pt} \\ (Registration of \NameAuthor[2]) \\ \\ Date \\ \rule[0em]{15em}{0.5pt}
\end{minipage}
\end{document}
的第一个参数\NameAuthor
是可选的,默认为1
,即第一作者。\NameAuthor[1]
无论如何,我使用了,以明确用法。
另一个更复杂的版本,使用
*.bib
数据库和用户定义的引用样式。伪造的作者条目可以位于*.bib
文档中已经使用的任何文件中,只要与条目键(如)不一致author1, author2,...
,但这种情况不太可能发生。
authorextract.cbx
首先在文件中定义 citationstyle
\ProvidesFile{authorextract.cbx}%
\RequireCitationStyle{authoryear}% Change if needed to other style
\newbibmacro{year}{\printfield{year}}%
\DeclareCiteCommand{\namecite}[]{}{\usebibmacro{author}}{}{}%
\DeclareCiteCommand{\mailcite}[]{}{\usebibmacro{title}}{}{}%
\DeclareCiteCommand{\regcite}[]{}{\usebibmacro{year}}{}{}%
\endinput%
接下来是作者的条目docauthors.bib
:
@BOOK{author1,
author={John Doe},
volume={XXXX},
title={\makeatletter [email protected]\makeatother},
year={XXXX},
options={skipbib=true},
}
@BOOK{author2,
author={Jane Doe},
year={YYYY},
title={\makeatletter [email protected]\makeatother},
options={skipbib=true},
}
@BOOK{author3,
author={Julius Caesar},
year={QQQQ},
title={\makeatletter [email protected]\makeatother},
introduction={Beware the Ides of March},
options={skipbib=true},
}
@BOOK{author4,
author={Will Shake},
year={ZZZZ},
title={\makeatletter [email protected]\makeatother},
introduction={I did honestly wrote all plays by myself},
options={skipbib=true},
}
这个skipbib=true
选项很重要,否则所有引用都会出现在参考书目中-->这里不需要!
现在*.tex
代码
\documentclass{article}
\usepackage{etoolbox}%
\usepackage[citestyle=authorextract,backend=bibtex]{biblatex}
\bibliography{docauthors}%
\newrobustcmd{\NameAuthor}[1][4]{%
\namecite{author#1}%
}%
\newrobustcmd{\MailAuthor}[1][5]{%
\mailcite{author#1}%
}%
\newrobustcmd{\RegAuthor}[1][6]{%
\regcite{author#1}%
}%
\newrobustcmd{\AuthorInformationExtraction}[1][7]{%
\NameAuthor[#1] (Registration Number: \RegAuthor[#1], Email: \MailAuthor[#1])
}%
\newrobustcmd{\AuthorInformation}{%
\AuthorInformationExtraction[1] \\ \&
\AuthorInformationExtraction[2] \\ \&
\AuthorInformationExtraction[3] \\ \&
\AuthorInformationExtraction[4]%
}%
\makeindex
\title{}
\author{%
\AuthorInformation%
}%
\begin{document}
% Title page contains the name and other details
\maketitle \clearpage
\section{Introduction}
\section*{Declaration}
% But, here I need only names and registration numbers separately
We, {\it the~authors individually} declare something.
\\
\\
\begin{minipage}[t]{0.5\linewidth}
Signature of \NameAuthor[1] \\ \\ \rule[0em]{15em}{0.5pt} \\ (Registration of \NameAuthor[1]) \\ \\ Date \\ \rule[0em]{15em}{0.5pt}
\end{minipage}%
\hfill
\begin{minipage}[t]{0.5\linewidth}
Signature of \NameAuthor[2] \\ \\ \rule[0em]{15em}{0.5pt} \\ (Registration of \NameAuthor[2]) \\ \\ Date \\ \rule[0em]{15em}{0.5pt}
\end{minipage}
\printbibliography
\end{document}
我“滥用”了数据库的author
、title
和year
字段,.bib
分别存储author name
、mail adress
和registration
数字。稍后,\namecite
、\mailcite
和\regcite
用于这些情况,例如authorextract.cbx
。使用\NameAuthor[]
与上一个代码版本和 相同的方法\AuthorInformation
用于\author{...}
块。
使用以下方式编译
pdflatex foo.tex biblatex foo pdflatex foo.tex
答案2
是吗,您期望什么?
\documentclass{article}
\def\authorA{Author 1} \def\regauthorA{(Registration Number: XXXX, Email: XXXX)}
\def\authorB{Author 2} \def\regauthorB{(Registration Number: YYYY, Email: YYYY)}
\makeindex
\title{}
\author{\authorA\ \regauthorA \\ \& \authorB\ \regauthorB}
\begin{document}
% Title page contains the name and other details
\maketitle \clearpage
\section{Introduction}
\section*{Declaration}
% But, here I need only names and registration numbers separately
We, {\it the~authors individually} declare something.
\par\bigskip
\noindent\begin{minipage}[t]{0.5\linewidth}
Signature of \authorA\ (Name only)\par\bigskip \rule[0em]{15em}{0.5pt} \\
(Registration of \authorA) \par\bigskip Date \par \rule[0em]{15em}{0.5pt}
\end{minipage}%
\hfil
\begin{minipage}[t]{0.5\linewidth}
Signature of \authorB\ (Name only)\par\bigskip \rule[0em]{15em}{0.5pt} \\
(Registration of \authorB) \par\bigskip Date \par \rule[0em]{15em}{0.5pt}
\end{minipage}%
\end{document}
注意:我对您的代码做了一些小改动,以避免盒子过满/过满。