Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pdftex driver of hyperref package doesn't work with utf-8 encoded .tex files

i use pdflatex to generate pdf files. my source files are all utf-8 encoded because of non-english characters. without \usepackage{hyperref} code, they can be compiled without any problem. but when i put \usepackage{hyperref} (even without any \href{}{} code) in the package list, an error would occur, saying

**************************************
! Use of \@chapter doesn't match its definition.  
\CJK@altchar ...fx \csname \reserved@a \endcsname   
                                                  \relax \CJKsymbol {\@tempc...  
l.1 \chapter{XXX}                    
?  
**************************************

where "XXX" represents non-english characters.

then i googled a lot, finding the cause is that hyperref uses pdftex drivers, which doesn't work with utf-8 encoded files. i checked this page: http://www.tug.org/applications/hyperref/manual.html , and failed to find any driver suitable for pdflatex.

i tried \usepackage[utf8]{inputenc}, but still couldn't get it to work.

so anyone could help me? thank you!

like image 643
Lion Avatar asked Jan 04 '11 09:01

Lion


2 Answers

Have you tried loading hyperref using \usepackage[unicode]{hyperref}, or, equivalently, specifying \hypersetup{ unicode = true } right after ? This should enable you to use unicode characters in bookmarks.

like image 106
Francois G Avatar answered Sep 21 '22 16:09

Francois G


Try this, works for me. Instead of:

\usepackage[pdftex, unicode,
            pdfauthor={çç êÊ},
            pdftitle={T\'{o}picos Avançados ôô},
            pdfsubject={Trabalho 6},
            pdfkeywords={a1, a2},
            pdfproducer={Latex with hyperref},
            pdfcreator={pdflatex}]{hyperref}

I do:

\usepackage[pdftex, unicode,
            pdfproducer={Latex with hyperref},
            pdfcreator={pdflatex}]{hyperref}

\hypersetup{
  pdfauthor={çç êÊ},
  pdftitle={T\'{o}picos Avançados ôô},
  pdfsubject={Trabalho 6},
  pdfkeywords={a1, a2},
}

I hope it works for you too.

like image 2
Marcos Lourenço Avatar answered Sep 23 '22 16:09

Marcos Lourenço