3

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.)

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

1 Answer 1

2

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}

enter image description here

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}
3
  • 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?
    – keth-tex
    Jun 8, 2020 at 16:46
  • 1
    ask a new question ... Jun 8, 2020 at 16:51
  • See: tex.stackexchange.com/questions/548437/…
    – keth-tex
    Jun 8, 2020 at 17:03

You must log in to answer this question.

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