1

This question already has an answer here:

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.

marked as duplicate by Werner, Svend Tveskæg, user13907, Masroor, Gonzalo Medina Feb 16 '15 at 1:34

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 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} – user31729 Feb 16 '15 at 0: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 0: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 0:17
  • Well, not parsing issues, just that TeX code can't be interpreted in a pdf bookmark – user31729 Feb 16 '15 at 0:17
  • 1
1

The unicode equivalent of \mathbb{1} is the character 1D7D9, which has to be inserted into \texorpdfstring using \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}

enter image description here

A visual list of characters and their codes can be obtained for example from http://en.wikipedia.org/wiki/Mathematical_Alphanumeric_Symbols

  • the Unicode bolded 1 is a nice touch. – MichaelChirico Feb 16 '15 at 1:25

Not the answer you're looking for? Browse other questions tagged or ask your own question.