1

I'm trying to use both the bbm (to write my preferred style of indicator variables) and the hyperref packages (to reference web URLs).

However, something strange seems to be going on whenever I use bbm in a subsection title. Any idea what might be going on here? Simple example:

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

The math itself compiles to pdf just fine, as well as the body text, for that matter.

However, a red box tends to show up somewhere in the document (which goes away if I click somewhere in the .pdf). Further, my compiler (I'm using the LaTeXTools plugin to SublimeText 3 on Linux which operates on latexmk) gives me the following warning messages, which I've no idea how to interpret.

./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.

If I exclude the mathbbm instance from the subsection title, the random red box still appears, but the warnings stop.

  • 1
    You can't include TeX code into bookmarks (that's what your doing with \subsection{$\mathbb{1}} effectively. You need \texorpdfstring{\mathbb{1}}{something for bookmark} –  Feb 16 '15 at 00:05
  • just to clarify--when the hyperref package is ?loaded?/?invoked?, section and subsection headers are translated as bookmarks (for, e.g., linking from a ToC--even though I don't have a ToC). So while including math in these headers is generally kosher, combining with hyperref engenders some parsing issues. – MichaelChirico Feb 16 '15 at 00:16
  • If so, then follow-ups: 1) Why does the math display anyway? Despite the warning, it built problem- (not warning-)free. 2) What's the {something for bookmark} bit? 3) What about this ephemeral red box? – MichaelChirico Feb 16 '15 at 00:17
  • Well, not parsing issues, just that TeX code can't be interpreted in a pdf bookmark –  Feb 16 '15 at 00:17
  • 1
  • Got it: http://en.wikibooks.org/wiki/LaTeX/Hyperlinks#Problems_with_bookmarks
  • – MichaelChirico Feb 16 '15 at 00:21