# How can I use \MakeUppercase for hyperref bookmarks?

One can't just do that:

\documentclass{book}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{hyperref}
\hypersetup{
unicode=true,
bookmarksnumbered=true
}
\begin{document}
\tableofcontents
\chapter{\MakeUppercase{First chapter}}% that doesn't work
\end{document}


I guess the command has to be "expanded" before using it for hyperref pdfstring?!

(I'd like to have the bookmarks-entries of \part-headings in all-caps. (Yet, the headings themselves formatted differently.) Basically I'd like to be able to use something like \mychapter{First chapter} in the document while having it all-caps in the bookmarks. I know that I can use \texorpdfstring{First chapter}{FIRST CHAPTER} but I'm looking for a solution which does it automatically.)

• Probably does this help Jun 8 '20 at 15:06
• @Steradiant That changes the heading, not the bookmarks-entry. It's the opposite of what I need. Jun 8 '20 at 15:28

Use the expl3 function:

\documentclass{book}
\usepackage[T1]{fontenc}

\usepackage{hyperref}
\hypersetup{
unicode=true,
bookmarksnumbered=true
}
\ExplSyntaxOn
\cs_set_eq:NN\textupper\text_uppercase:n
\ExplSyntaxOff
\begin{document}
\tableofcontents
\chapter{\textupper{First chapter}}% that doesn't work
\end{document}


If you want it only in the bookmarks you can do it like this:

\documentclass{book}
\usepackage[T1]{fontenc}

\usepackage{hyperref}
\hypersetup{
unicode=true,
bookmarksnumbered=true
}
\ExplSyntaxOn
\newcommand\textupper{}
\pdfstringdefDisableCommands{\cs_set_eq:NN\textupper\text_uppercase:n}
\ExplSyntaxOff
\begin{document}
\tableofcontents
\chapter{\textupper{First chapter}}%
\end{document}

• Thanks for this. Unfortunately it's a bit more complicated. When I use this with German umlauts and hyperref option "unicode=true", the umlauts get replaced by 'A's with a tilde in the bookmarks. I set the option "unicode=true" due to the fact that I have to use greek letters for the numbering of one of the section levels. For that I use 'textgreek'-letters, which only work in the bookmarks with the hyperref unicode option... Is there any solution to that problem? Jun 8 '20 at 16:46
• ask a new question ... Jun 8 '20 at 16:51
• Jun 8 '20 at 17:03