Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I currently am using the hyperref package and I'm currently getting a lot of error messages. Currently all of the chapter and section titles give this same error. I decided to try make a minimum example and currently:

\documentclass{amsbook}

\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{hyperref}
\usepackage[dvipsnames,usenames]{color}

\begin{document}
\pagenumbering{roman}

\chapter{Preface}

\mainmatter
\pagenumbering{arabic}

\part{The}

\end{document}

Is giving me the following warnings:

Package hyperref Warning: Token not allowed in a PDF string (PDFDocEncoding):
(hyperref)                \kern 5.0pt
(hyperref)                replaced by space on input line 18.

Package hyperref Warning: Token not allowed in a PDF string (PDFDocEncoding):
(hyperref)                removing '\noindent' on input line 18.

Is this a bug with the hyperref package or is this just a result of me not setting up things properly? How do I go about either fixing this or silencing the warning messages?

share|improve this question
1  
\part{The} wouldn't produce those warnings. Please prepare a minimal working example (MWE) that reproduces the messages. –  cgnieder Nov 4 '13 at 17:19
    
@cgnieder, This is producing exactly those warnings on my setup here. This was a minimal example. –  shuttle87 Nov 4 '13 at 17:20
3  
No. A MWE starts with \documentclass and ends with \end{document}. This doesn't produce said warnings: \documentclass{article} \usepackage{hyperref} \begin{document} \tableofcontents \part{The} \end{document} –  cgnieder Nov 4 '13 at 17:23
    
@cgnieder, edited as per request to include the entire example file I ran this from. –  shuttle87 Nov 4 '13 at 17:31
1  
It seems to be a bug related to amsbook, as discussed in this link. You may want to ignore the warning, if it is not affecting the desired output. –  Pedro Nov 4 '13 at 18:05

1 Answer 1

up vote 12 down vote accepted

It's not really a bug, but an innocuous “feature”. You can cure it by disabling the offending commands during bookmark preparation:

\documentclass{amsbook}

\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage[dvipsnames,usenames]{color}
\usepackage{hyperref}

\pdfstringdefDisableCommands{%
  \let\enspace\empty  % this causes the warning for \kern
  \let\noindent\empty % this causes the warning for \indent
}

\begin{document}
\frontmatter

\chapter{Preface}

\mainmatter

\part{The}

\end{document}

The macro \pdfstringdefDisableCommand has precisely this purpose: to add definitions for commands that make no sense in bookmarks. Several commands are already redefined to safe version (for instance \<space>), but it would slow down compilation if all commands one can think of were included. So only the most common ones are redefined, others can be added when needed.


As an aside, note that \frontmatter should be preferred to \pagenumbering{roman} for the front matter of the document. There's no need of \pagenumbering{arabic} after \mainmatter.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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