套件 hyperref 警告:PDF 字串中不允許使用令牌 (PDFDocEncoding)

套件 hyperref 警告:PDF 字串中不允許使用令牌 (PDFDocEncoding)

載入 hyperref 套件時,例如:

\usepackage[bookmarks,bookmarksnumbered]{hyperref}
\hypersetup{colorlinks = true,linkcolor = blue,anchorcolor =red,citecolor = blue,filecolor = red,urlcolor = red}

我在日誌檔案中收到以下 hyperref 警告:

Package hyperref Warning: Token not allowed in a PDF string (PDFDocEncoding):
(hyperref) removing `\<def>-command' on input line 174.
Package hyperref Warning: Token not allowed in a PDF string (PDFDocEncoding):
(hyperref) removing `\cnotenum' on input line 174.
Package hyperref Warning: Token not allowed in a PDF string (PDFDocEncoding):
(hyperref) removing `\<def>-command' on input line 174.
Package hyperref Warning: Token not allowed in a PDF string (PDFDocEncoding):
(hyperref) removing `\@corref' on input line 174.

但在第 174 行,它只是一個等式:

\begin{equation}\label{eq_DefP}
\mathbf{P} = <\boldsymbol{p}> = <\boldsymbol{\sigma}>
\end{equation}

如果我評論這一行,它將出現在下一個方程中。在這一行之前,還有方程式,但沒有出現警告。誰能幫我解決這個警告?

這裡我舉一個小例子:

\documentclass[final,3p,times,authoryear]{elsarticle}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{amsmath}
\usepackage{multirow}
\usepackage[bookmarks,bookmarksnumbered]{hyperref}
\hypersetup{colorlinks = true,linkcolor = blue,anchorcolor =red,citecolor = blue,filecolor = red,urlcolor = red}

\journal{Elesvier}

\begin{document}

\begin{frontmatter}

\title{Title}

\author[GRs]{author\corref{cor}}

\cortext[cor]{Corresponding author.}

\end{frontmatter}

\begin{equation}\label{eq_DefP}
\mathbf{P} = <\boldsymbol{\sigma}>
\end{equation}

\end{document}

我認為這是問題, \author[GRs]{author\corref{cor}}因為當我刪除它時,它\corref{cor}會正常。但我需要這個,所以我該怎麼辦?

答案1

問題不在於方程式——那隻是報告問題的地方。在第一頁的末尾,hyperref 將標題和作者儲存在 pdf 資訊中,然後抱怨作者姓名中的 \corref。

最好的方法是手動插入pdfauthor

\documentclass[final,3p,times,authoryear]{elsarticle}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{amsmath}
\usepackage{multirow}
\usepackage[bookmarks,bookmarksnumbered]{hyperref}
\hypersetup{colorlinks = true,linkcolor = blue,anchorcolor =red,citecolor = blue,filecolor = red,urlcolor = red,
            pdfauthor=author}

\journal{Elesvier}

\begin{document}

\begin{frontmatter}

\title{Title}

\author[GRs]{author\corref{cor}}

\cortext[cor]{Corresponding author.}

\end{frontmatter}

\begin{equation}\label{eq_DefP}
\mathbf{P} = <\boldsymbol{\sigma}>
\end{equation}

\end{document}

答案2

與 Ulrike 類似的修復報告於這個答案,效果類似\texorpdfstring

\pdfstringdefDisableCommands{%
  \def\corref#1{<#1>}%
}

答案3

daleif 的解決方案對我來說就像一個魅力:

\author[add1]{Author1\texorpdfstring{\corref{cor1}}{}}
\ead{[email protected]}     % e-mail of the author

\cortext[cor1]{Corresponding author}
\address[add1]{Institute for Study of Things}

相關內容