代码之家  ›  专栏  ›  技术社区  ›  meduz

在乳胶中设置author或address字符串变量

  •  7
  • meduz  · 技术社区  · 15 年前

    乳胶是写文件的好语言。与 hyperref 包装及 pdflatex ,您可以使用元数据轻松生成文档,这是一个很好的功能,可以在Web上正确引用您的文档。

    我经常使用如下模板:

    \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}
    

    到目前为止,一切都很好。我的问题从示例中突然出现:是否有方法在头中定义字符串变量,以便它们可以作为参数传递给 超级参考文献 然后到前台或文本。类似于:

    \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 }. 但也包括关键字。

    2 回复  |  直到 9 年前
        1
  •  10
  •   meduz    15 年前

    正确的模板应如下所示:

    \documentclass[11pt]{article}
    %-------definitions-----
    \newcommand{\Author}{My name} 
    \newcommand{\Title}{My title}
    \newcommand{\Keywords}{my first keyword, my first 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}
    

    编译fine,元数据在pdf阅读器中显示fine。

        2
  •  2
  •   dwarring    9 年前

    试用使用 \newcommand{\Author}{My name} 而不是 \def .