# Using non ASCII characters in author names and titles within hyperref pdfinfo

I am trying to generate a PDF file (using pdflatex) with hyperref references; both the title and author should be visible as pdf properties, and both contain accents or non us-ASCII. The rest of the document compiles fine using \documentclass[a4paper,openright]{book}, \usepackage[utf8]{inputenc} and \usepackage[spanish]{babel}.

I would expect this to work:

\usepackage[pdftex,colorlinks=true,
% ...
pdftitle={Título con acentos o eñes},
pdfauthor={Migueláñez}
]{hyperref}


-- it generates around 54 warnings and outputs something like

Title:          T19 tulo con acentos o en126 nes
Author:         Miguela19 an126 nez
Creator:        LaTeX with hyperref package
Producer:       pdfTeX-1.40.10


I have also tried leaving the pdfauthor empty and later using

\pdfstringdef{myauthor}{Miguel\'{a}\~{n}ez}


or

\pdfstringdef{myauthor}{Migueláñez}


and

\hypersetup{pdfauthor={\myauthor}}


But all variants result in errors instead of warnings.

-
You can define pdfstringdef like that: \pdfstringdef\mtGEP{gedit \176/.profile} where \176 in this example is octal notation of tilde character. –  Vladimir S. Sep 3 '13 at 6:34

Try setting the properties with the command \hypersetup{...} instead of supplying them directly when loading hyperref (hyperref manual, page 4):

\usepackage[colorlinks=false]{hyperref}
\hypersetup{pdftitle={A Perfect Day}}


As seen in the previous example, information entries (pdftitle, pdfauthor, . . . ) should be set after the package is loaded. Otherwise LaTeX expands the values of these options prematurely.

So the following code works fine for me, with the correct author and title displayed in Adobe Reader:

\documentclass[a4paper,openright]{book}
\usepackage[utf8]{inputenc}
\usepackage[spanish]{babel}
\hypersetup{pdftitle={Título con acentos o eñes},pdfauthor={Migueláñez}}
\begin{document}
The document
\end{document}

-
Works like a charm. And I thought I had tried all the variants. Thanks! –  tucuxi Mar 9 '11 at 9:26

While I think diabonas answer is preferable for Spanish or other non-English documents which anyway use inputenc and babel I like to post an answer which works without them. Just in case of a English-only document written by someone with non-ASCII letters in its name. Especially journals like when you minimize the number of used packages.

The trick is to escape the non-ASCII characters in the following way. Please note, that you can't use them as package option because the LaTeX kernel expands the \<number> sequences first and complains about that e.g. \3 is not defined. Inside \hypersetup they work fine:

\documentclass{book}
\usepackage{hyperref}
\hypersetup{%
pdfauthor={Miguel\341\361ez},
pdftitle={T\355tulo con acentos o e\361es}
}
\begin{document}
Text
\end{document}


Result (output of pdfinfo file.pdf):

Title:          Título con acentos o eñes
Subject:
Keywords:
Author:         Migueláñez
...


A list of the needed numbers of special characters can be found e.g. under: http://www.pjb.com.au/comp/diacritics.html

-
Thanks Martin - wish I could vote two answers as correct, but diabonas' is slightly easier (no arcane reference for PDF characters required) –  tucuxi Mar 9 '11 at 9:25
@tucuxi: No problem. As I already wrote diabonas answer is normally preferable. I just wanted to add an alternative for other people which want to avoid e.g. babel etc. –  Martin Scharrer Mar 9 '11 at 9:57
With variants like xetex that accept full unicode input (I think) could you just type the name in the document using the real unicode characters? –  Peter Gerdes Jun 28 '12 at 11:36

I know that two answers have already been provided but I think mine is different and really handy. Why loading something in the preamble? If one uses inputs it is good to specify the TITLE in the real DOCUMENT FILE, as it logically goes there. If you edit your file with UTF-8 and unicode settings just use

\usepackage[utf8]{inputenc}
\usepackage[spanish]{babel}
\usepackage[unicode=true,,]{hyperref} %with more options specified if you like


then there is no problem in doing

\newcommand\longtitle{Właśnie tu długi tytuł} %translation: long title
\newcommand\authors{Przemysław Majewski}


and then simply stating

%pdf authors and titles for hyperref ---> document specific
\hypersetup{
pdfauthor={\authors},
pdftitle={\longtitle},
pdfsubject={},
pdfkeywords={hypergeometric,,}
}


Does it work?

-
Welcome to TeX.sx! –  Kurt Feb 7 '13 at 19:20