2

Here's my MWE :

\documentclass[a4paper,11pt]{article}
\usepackage[utf8x]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[frenchb]{babel}
\usepackage[pdftex,colorlinks=true,linkcolor=blue,citecolor=blue,urlcolor=blue]{hyperref}

\begin{document}

\tableofcontents

\addcontentsline{toc}{section}{this produces warnings : é}

é % or \phantom{é} this 'loads' é ?

\addcontentsline{toc}{section}{this does not produce warnings : é}

\end{document}

Took me a while to find why only the first \addcontentsline got warnings, but it appears I can't use accentuated characters as long as I haven't used them anywhere else... Is there a fix for this ? (other than the \phantom{é} I currently have at the beginning of my document...)

Using Miktex 2.9, I have updated all my packages recently.

Note : it works if I use \'e instead of é, but for various reasons I need the actual é character.

3
  • The simplest solution is not using utf8x, but utf8. Not related, but important: don't specify the pdftex option.
    – egreg
    Jul 26 '15 at 16:11
  • @egreg : I'll try removing the utf8x. Can't remember why I added the x a while ago, can you think of a reason ? Also why do I need to remove pdftex ?
    – imj
    Aug 3 '15 at 11:17
  • Packages such as hyperref and graphicx are able to guess the right option (if it should be dvips or pdftex) and it's best not to specify it.
    – egreg
    Aug 3 '15 at 11:24
2

hyperref needs to be prepared for unicode characters such as the direct use of é etc. Typing é somewhere in the document will do so for all following occurences, but not for the previous on. Ideally, it should appear in the preamble, but this is impossible, since there mustn't be typesetting.

The remedy is to 'fake' the output of é (and possible other unicode characters) in the preamble.

This can be achieved with \PrerenderUnicode{é} in the preamble.

By the way: There is an explicit warning in the bookmarks if \PrerenderUnicode is missing and you are advised to add \PrerenderUnicode in the preamble ;-)

\documentclass[a4paper,11pt]{article}
\usepackage[utf8x]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[frenchb]{babel}
\usepackage[pdftex,colorlinks=true,linkcolor=blue,citecolor=blue,urlcolor=blue,unicode]{hyperref}

\PrerenderUnicode{é}

\begin{document}

\tableofcontents

\addcontentsline{toc}{section}{this produces warnings : é}

%é % or \phantom{é} this 'loads' é ?

\addcontentsline{toc}{section}{this does not produce warnings : é}

\end{document}

I've omitted a screenshot since this doesn't need such one.


To clearify: Here is the warning produced in ToC and bookmarks, if \PreenderUnicode isn't applied in the preamble.

enter image description here

3
  • can't see that warning though. do I have to use \usepackage{bookmark} ?
    – imj
    Jul 26 '15 at 8:20
  • @imj: No, I've used the document above. I will show a screen shot from Adobe Reader output in a few moments
    – user31729
    Jul 26 '15 at 8:22
  • Oh, ok. Thanks a lot. Interesting place to put a Latex warning :)
    – imj
    Jul 26 '15 at 8:27
0

The simplest solution is to use utf8 instead of utf8x; in the past there were reasons to prefer the latter (not when writing in French), but the issues (with Greek) have been solved. There's no point in using utf8x and ucs (that's implicitly loaded), because it's just more complicated than utf8 and gives essentially no advantage.

\documentclass[a4paper,11pt]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[frenchb]{babel}
\usepackage[
  colorlinks=true,
  linkcolor=blue,
  citecolor=blue,
  urlcolor=blue,
]{hyperref}

\begin{document}

\tableofcontents

\addcontentsline{toc}{section}{no warning here : é}

é % or \phantom{é} this 'loads' é ?

\addcontentsline{toc}{section}{neither here : é}

\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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