hyperref 和 attachmentfile2 包之间的冲突

hyperref 和 attachmentfile2 包之间的冲突

我在创建包含附件的 PDF 文档时遇到问题。此代码运行良好:

% <xetex — Unicode-based TeX engine>
\documentclass[12pt, a4paper, czech, twoside]{book} 
\usepackage{hyperref}
\usepackage{attachfile2}
\begin{document}
   My attached file is \attachfile{my.m}
\end{document}

但是这个代码

\documentclass[12pt, a4paper, czech, twoside]{book} 
\usepackage[xetex,
            bookmarks={true},    %  A set of Acrobat bookmarks are written
            colorlinks={true},   %  Colors the text of links and anchors. 
            linkcolor={red},     %  Color for normal internal links.
            anchorcolor={black}, %  Color for anchor text.
            filecolor={cyan},    %  Color for URLs which open local files.
            menucolor={red},     %  Color for Acrobat menu items.
            runcolor={blue},     %  Color for run links (launch annotations).
            urlcolor={magenta},  %  Color for linked URLs.          
            unicode={true},  
            pdfauthor={Jaroslav Fait}, 
            pdftitle={Wiking}, 
            pdfsubject={study notes},
            pdfkeywords={linear algebra, math, electronics},
            pdfproducer={XeLateX with hyperref},
            pdfcreator={Xelatex}]{hyperref} 

\usepackage{attachfile2}
\begin{document}
 My attached file is \attachfile{my.m}
\end{document} 

没有!!!。注意(my.m 是 Matlab m 文件)。

生成的 pdf 文档包含附件,但无法打开或保存,并且附件的文件名已损坏。我的调查结果是 hyperref 包不应该有任何选项。我使用 Miktex 2.9(xelatex 引擎,最新更新)和 Adob​​e reader X。

答案1

对我来说,它通过使用\hypersetup而不是直接提供包选项来工作:

\documentclass[12pt, a4paper, czech, twoside]{book} 
\usepackage[xetex,
            bookmarks={true},    %  A set of Acrobat bookmarks are written
            colorlinks={true},   %  Colors the text of links and anchors. 
            linkcolor={red},     %  Color for normal internal links.
            anchorcolor={black}, %  Color for anchor text.
            filecolor={cyan},    %  Color for URLs which open local files.
            menucolor={red},     %  Color for Acrobat menu items.
            runcolor={blue},     %  Color for run links (launch annotations).
            urlcolor={magenta},  %  Color for linked URLs.          
            ]{hyperref}
\hypersetup{pdfauthor={Jaroslav Fait}, 
            pdftitle={Wiking}, 
            pdfsubject={study notes},
            pdfkeywords={linear algebra, math, electronics},
            pdfproducer={XeLateX with hyperref},
            pdfcreator={Xelatex}}
\usepackage{attachfile2}
\begin{document}
 My attached file is \attachfile{my.m}
\end{document}

(顺便说一句,该pdfproducer选项不起作用xdvipdfmx,因为 XeTeX 用来生成 PDF 的程序,总是用自己的条目覆盖它)。

编辑:进一步的调查显示,问题是由使用选项hyperref/unicode=true引起的pdfencoding=unicode,如果您在加载包时使用和朋友作为参数,则会自动激活该pdfauthor选项。因此,解决方案是不使用其中一个选项unicodepdfencoding和设置pdfauthor等。使用\hypersetup,即建议做法反正。

相关内容