bbm 和 hyperref 套件的時髦互動

bbm 和 hyperref 套件的時髦互動

我正在嘗試使用 bbm(編寫我喜歡的指示變數樣式)和 hyperref 包(引用 Web URL)。

然而,每當我在小節標題中使用 bbm 時,似乎就會發生一些奇怪的事情。知道這裡會發生什麼事嗎?簡單的例子:

\documentclass[12pt,titlepage]{article}

\usepackage{bbm}
\usepackage{hyperref}

\begin{document}

\subsection{Model: Logistic Regression of $\mathbbm{1}\left[var\right]$}

\href{http://www.google.com}{This} is a hyperlink, and
 this\footnote{footnote} is a footnote.

$\mathbbm{1}\left[x\in S\right]$ is an indicator in plain text

\end{document}

就這一點而言,數學本身以及正文都可以很好地編譯為 pdf。

然而,紅色框往往會出現在文件中的某個位置(如果我單擊 .pdf 中的某個位置,紅色框就會消失)。此外,我的編譯器(我在 Linux 上使用 SublimeText 3 的 LaTeXTools 插件,它在 Latexmk 上運行)給了我以下警告訊息,我不知道如何解釋。

./test.tex:8: Package hyperref Warning: Token not allowed in a PDF string (PDFDocEncoding):(hyperref)                removing `math shift' on input line 8.
./test.tex:8: Package hyperref Warning: Token not allowed in a PDF string (PDFDocEncoding):(hyperref)                removing `\left' on input line 8.
./test.tex:8: Package hyperref Warning: Token not allowed in a PDF string (PDFDocEncoding):(hyperref)                removing `\right' on input line 8.
./test.tex:8: Package hyperref Warning: Token not allowed in a PDF string (PDFDocEncoding):(hyperref)                removing `math shift' on input line 8.

如果我從標題中排除該mathbbm實例subsection,隨機紅色框仍會出現,但警告會停止。

答案1

的 unicode 等效項\mathbb{1}是字符1D7D9,必須將其插入\texorpdfstringusing\unicode{"1D7D9}

\documentclass[12pt,titlepage]{article}

\usepackage[utf8]{inputenc}
\usepackage{bbm}
\usepackage[pdfencoding=auto,unicode=true]{hyperref}


\begin{document}

\subsection{Model: Logistic Regression of \texorpdfstring{$\mathbbm{1}}{\unichar{"1D7D9}}\left[var\right]$}


\href{http://www.google.com}{This} is a hyperlink, and
 this\footnote{footnote} is a footnote.

$\mathbbm{1}\left[x\in S\right]$ is an indicator in plain text

\end{document}

在此輸入影像描述

例如,可以從以下位置取得字元及其代碼的可視列表 http://en.wikipedia.org/wiki/Mathematical_Alphanumeric_Symbols

相關內容