14

I use hyperref for a number of reasons, but among other things it sets up the document properties up well. As long as I compile with XeLaTeX that is. As soon as I compile with LuaLaTeX, everything is a jumble. There are many more fields with issues in my real project, but here is an MWE using just the title field:

\documentclass{scrartcl}
\usepackage{polyglossia}
\setmainlanguage{turkish}
\makeatletter
\usepackage[hidelinks]{hyperref}
\AtBeginDocument{%
    \hypersetup{%
        pdftitle = {\@title}
    }
}{}
\makeatother
\title{RAB'BİN GÜNÜ}
\begin{document}
Title in document properties should match: RAB'BİN GÜNÜ 
\end{document}

Compile with xelatex gives me:

Title: RAB’BİN GÜNÜ

But lualatex eats Unicode for lunch and has indigestion:

Title: RAB'BİN GÜNÜ

How do I get proper Unicode characters into the document property fields when compiling with LuaLaTeX?

3
  • @Christopher The document properties aren't typeset with a font. They are in the program chrome of whatever PDF reader you are using. And yes the default font typesets the characters fine in the document body. I use Libertine in my documents but I don't think it's relevant to this MWE.
    – Caleb
    Mar 24, 2015 at 10:56
  • @MartinSchröder This is probably a duplicate but I'm concerned that the accepted (and indeed most of the) answers there are wrong and do not work in the general case (I think they only worked for a limited non-ascii character subset but doesn't actually work for full Unicode). Perhaps that question should be closed as a duplicate of this one as the answer provided here is far more canonically the correct fix for this problem.
    – Caleb
    Mar 25, 2015 at 11:08

2 Answers 2

19

The indigestion is avoided by passing the unicode option to hyperref:

\documentclass{scrartcl}
\usepackage{polyglossia}
\setmainlanguage{turkish}
\makeatletter
\usepackage[hidelinks,unicode]{hyperref}
\AtBeginDocument{%
    \hypersetup{%
        pdftitle = {\@title}
    }
}{}
\makeatother
\title{RAB'BİN GÜNÜ}
\begin{document}
Title in document properties should match: RAB'BİN GÜNÜ
\end{document}

enter image description here

Here's the output of pdfinfo -enc UTF-8 test.pdf (only the relevant parts)

LuaLaTeX

Title:          RAB'BİN GÜNÜ
Subject:        
Keywords:       
Author:         
Creator:        LaTeX with hyperref package
Producer:       LuaTeX-0.79.1
CreationDate:   Tue Mar 24 12:01:09 2015
ModDate:        Tue Mar 24 12:01:09 2015

XeLaTeX

Title:          RAB'BİN GÜNÜ
Creator:        LaTeX with hyperref package
Producer:       xdvipdfmx (20140317)
CreationDate:   Tue Mar 24 11:58:05 2015
1
  • The clumsy \AtBeginDocument can be avoided here by the hyperref option pdfusetitle. Then hyperref catches \title and \author to use them for pdftitle and pdfauthor. Apr 8, 2015 at 6:45
3

The reason why the behavior differs when LuaTeX or XeTeX is used, is explained here. The XeTeX uses xdvipdfmx and this converter sets the UTF8 to UCS2 conversion automatically. On the other hand, when we are using direct pdfTeX primitives (like in LuaTeX) then the UTF8 to UCS2 conversion must be done at macro level. And the hyperref package does this when the mentioned unicode option is set.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .