微類型擴充導致 pdfauthor 出現錯誤

微類型擴充導致 pdfauthor 出現錯誤

下面的文檔給出了錯誤

 ! Argument of \MT@res@a has an extra }.

錯誤的根源是重音命令\"L(這沒有多大意義,我只在範例中使用它,因為即使\accent使用 T1 編碼,它也總是使用)。

問題的第二個根源是 hyperref 被載入到 microtype 程式碼後面的 \AtBeginDocument 中。稍後載入 microtype(或更早載入 hyperref)可以避免錯誤。

但我想知道是否有比微調載入順序更好的解決方案來保護 pdfauthor 的論點(無論如何,這對 hyperref 來說都是一個痛苦)。

\documentclass{article}
\usepackage[T1]{fontenc}

\usepackage{microtype}

\AtBeginDocument{%
  \RequirePackage[%
    pdfauthor={Max \"Labc}
  ]{hyperref}
}

\begin{document}
ablub
\end{document}

答案1

使用\hypersetup設定作者而不是在加載時直接提供它似乎工作得很好,這是推薦做法無論如何,當使用特殊字元時:

\documentclass{article}
\usepackage[T1]{fontenc}

\usepackage{microtype}

\AtBeginDocument{%
  \usepackage{hyperref}
  \hypersetup{pdfauthor={Max \"Labc}}
}

\begin{document}
ablub
\end{document}

相關內容