LaTeX是写文档的绝妙语言。使用hyperref
包和pdflatex
,您可以轻松生成带有元数据的文档,这是一个很好的功能,可以在Web上正确引用文档。在LaTeX中设置作者或地址字符串变量
我经常使用像模板:
\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
一部分,并与! Use of \Title doesn't match ! Argument of \let has an extra }.
的hyperref
元数据也为包括关键字。
我相信在这种情况下,'\ def \ Title'作为参数定界符(尽管我不确定它是否允许使用无参数宏)。这意味着你必须调用'\ Title ='而不是普通的'\ Title'。 '\ Title ='也可以工作(分隔符不是名称的一部分)。但它不会具有(可能是预期的)任务的意义。 – 2010-02-25 17:57:36
谢谢,我纠正了错字!问题总共打开了15分钟! – meduz 2010-02-25 18:21:22
我投票结束这个问题作为题外话,因为这个问题不能在现代发行版中重现。 – Werner 2015-08-05 00:18:50