0

Update - 12/28/2022 I have included below my MWE per @Miyase's comment. The error is coming from placement of color{blue} in line \addcontentsline{toc}{chapter} ... What to do to remove the Package hyperref Warning: Token not allowed in a PDF string (Unicode): removing `\@ifnextchar' message (note: now the error do not mention 'PDFDocEncoding' but 'Unicode')

\documentclass{report}
\usepackage{tocloft}
\usepackage{etoolbox}
\usepackage[titletoc]{appendix}
\usepackage[usenames,dvipsnames]{xcolor}
\usepackage[hyperfootnotes=false,english,colorlinks]{hyperref}
\hypersetup{
  colorlinks=true,
  citecolor=PineGreen,
  linkcolor=red,
  urlcolor=blue}

% color the chapter headings in toc \newcommand{\Chapter}[1]{\clearpage\thispagestyle{plain} % put new chapters on a new page \refstepcounter{chapter} % manually increment the chapter number \addcontentsline{toc}{chapter}{{\color{blue}{{\bf Chapter \thechapter: #1}}}} \noindent{\color{blue}\huge{{\bf Chapter \thechapter \hfill\break\newline\newline\newline \Huge #1}}\normalsize} \vspace{10\baselineskip} }

\begin{document}

\tableofcontents

\Chapter{Intro}

\Chapter{Test}

\begin{appendices} \appendix

\chapter{Conclusions} \end{appendices} \end{document}

Original post: Because I wanted a new font color and the word Chapter \thechapter : to appear in toc, I defined a new \Chapter command instead of the default \chapter in report class. But because of this, I get the following warning message:

Package hyperref Warning: Token not allowed in a PDF string (PDFDocEncoding): removing `\@ifnextchar' on input line 1.

Below is what I used to define \Chapter (This is the minimum working example because the error goes away if I do not use this):

\newcommand{\Chapter}[1]{\clearpage\thispagestyle{plain} % put new chapters on a new page
 \refstepcounter{chapter} % manually increment the chapter number
 \addcontentsline{toc}{chapter}{\color{blue}{Chapter \thechapter : #1}}
\noindent \huge{\color{blue}{\bf Chapter \thechapter \newline\newline \Huge #1}} \normalsize
\vspace{1\baselineskip}
}

0 Answers0