LaTeX 是编写文档的绝佳语言。使用hyperref
包 和pdflatex
,您可以轻松地生成带有元数据的文档,这是一个很好的功能,可以让您的文档在网络上被引用。
我经常使用这样的模板:
\documentclass[11pt]{article}
\usepackage[pdftex, pdfusetitle,colorlinks=false,pdfborder={0 0 0}]{hyperref}%
\hypersetup{%
pdftitle={My title},%
pdfauthor={My name},%
pdfkeywords={my first keyword, my second keyword, more keywords.},%
}%
\begin{document}
\title{My title}
\author{My name}
\date{}
\maketitle
{\bf Keywords:} my first keyword, my second keyword, more keywords.%
My text is here...
\end{document}
到目前为止,一切都很好。我的问题从示例中跳出来:有没有办法在标题中定义字符串变量,以便它们可以作为参数传递hyperref
给 frontmatter 或文本。就像是:
\documentclass[11pt]{article}
%-------definitions-----
\def\Author{My name}
\def\Title{My title}
\def\Keywords{my first keyword, my second keyword, more keywords.}
%--------------------------
\usepackage[pdftex, pdfusetitle,colorlinks=false,pdfborder={0 0 0}]{hyperref}%
\hypersetup{%
pdftitle={\Title},%
pdfauthor={\Author},%
pdfkeywords={\Keywords},%
}%
\begin{document}
\title{\Title}
\author{\Author}
\date{}
\maketitle
{\bf Keywords:} \Keywords %
My text is here...
\end{document}
这对于包含关键字的\maketitle
部件和 hyperref
元数据都失败了。! Use of \Title doesn't match ! Argument of \let has an extra }.