josephwright / beamer

A LaTeX class for producing presentations and slides
Other
1.35k stars 139 forks source link

`hyperref` Warning: "Glyph not defined in PU encoding" in `title`, `author`, etc., for non-Unicode input encoding #889

Open alekhe opened 4 months ago

alekhe commented 4 months ago

I’m using 8-bit input encoding and some sort of a clash happens with encodings for hyperref. For my \title, \subtitle and \author (which I set in the preamble), I get

Package hyperref Warning: Glyph not defined in PU encoding,
(hyperref)                removing `\CYRN' on input line 12.
...

The title page is correctly produced, but the PDF properties (title and author) do not contain removed symbols. Everything is alright if I use article and hyperref.

Example:

\documentclass{beamer}
%\documentclass{article}
\usepackage[T2A]{fontenc}
\usepackage[cp866]{inputenc}
\usepackage[russian]{babel}
%\usepackage{hyperref}
%\hypersetup{
%   pdftitle={Название hyper},
%   pdfauthor={Автор hyper},
%}

\title{Название main}
\author{Автор main}
\begin{document}
\maketitle
\end{document}

I tried usepdftitle=false with \hypersetup{...}, and hyperref={unicode=true} in options, but no success.

Everything’s fine if UTF-8 inputenc is used.

josephwright commented 4 months ago

Why are you using a non-UTF-8 setup nowadays?

samcarter commented 4 months ago

@alekhe Can you double check the encoding of your file? If it works with utf8, maybe your file is actually encoded in utf8?

josephwright commented 4 months ago

Indeed: I'm struggling to know how to create a file with this encoding - my normal editor can't

u-fischer commented 4 months ago

The encoding is a bit outdated but not really relevant. You get the same warning in utf8 with this:

\documentclass{article}
\usepackage{hyperref}
\usepackage[T2A]{fontenc}
\hypersetup{pdftitle=\CYRN}
\begin{document}
xxx
\end{document}

The problem is that hyperref only defines cyrillic commands if cyrillic has been loaded earlier.

Add this before the \documentclass command:

\providecommand\CYRDZE{}
josephwright commented 4 months ago

@u-fischer So not-beamers fault?

u-fischer commented 4 months ago

@josephwright well beamer loads hyperref a bit early. But in view that I claim that one should resolve loading order dependencies, I would say, open an issue for hyperref.

alekhe commented 4 months ago

Why are you using a non-UTF-8 setup nowadays?

Unfortunately I have to use BibTeX, which can’t deal correctly with UTF-8 encoded bib files.

Can you double check the encoding of your file? If it works with utf8, maybe your file is actually encoded in utf8?

Yes, I checked. Moreover, if the source encoding is different from [cp866]{inputenc} then the resulting PDF will not be readable.

Indeed: I'm struggling to know how to create a file with this encoding - my normal editor can't

There are settings in TeXstudio, Notepad++, Notepad2 (et el.), Vim. I haven’t worked in TeXworks.

The encoding is a bit outdated but not really relevant. You get the same warning in utf8 with this:

I don’t know how this works, but you get no warnings if you write \CYRN in a “natural” way:

\documentclass{article}
\usepackage{hyperref}
\usepackage[T2A]{fontenc}
\hypersetup{pdftitle=Н}
\begin{document}
xxx
\end{document}

well beamer loads hyperref a bit early. But in view that I claim that one should resolve loading order dependencies, I would say, open an issue for hyperref.

I found out that hyperref should be loaded after fontenc. That is, this one results in warnings with symbols removed:

\documentclass{article}
\usepackage{hyperref}
\usepackage[T2A]{fontenc}
\usepackage[cp866]{inputenc}
\usepackage[russian]{babel}

And this one works fine:

\documentclass{article}
\usepackage[T2A]{fontenc}
\usepackage{hyperref}
\usepackage[cp866]{inputenc}
\usepackage[russian]{babel}

Is it possible to tell beamer to \usepackage (with options) before hyperref?

alekhe commented 4 months ago

A workaround:

\RequirePackage[T2A]{fontenc}
\documentclass{beamer}
u-fischer commented 4 months ago

Why don't you use what I suggest?

\providecommand\CYRDZE{}
\documentclass{beamer}

should work fine.

alekhe commented 4 months ago

Yes, you’re right, it works fine. Thank you.

I just didn’t get (and still don’t) what that meant. E.g., changing \CYRDZE to \CYRA doesn’t work. So I decided to play around.

u-fischer commented 4 months ago

hyperref is currently using \CYRDZE as a test to decide if cyrillic has been loaded or not.

alekhe commented 4 months ago

Ah, OK, thank you!