0

I'm writing a document in English, but I also have some parts in other language.

I created my own style to change how the book class behaves, which also includes headings for chapter and chapter* environments. As part of this, in definition for chapter* I added the pdfbookmark command, so that all unnumbered chapters appear in the bookmark. Here is the definition:

\renewcommand{\@makeschapterhead}[1]{%
    {%
        \pdfbookmark[0]{#1}{#1}%
        \vspace*{\@spacebeforechapterhead}%
        \parindent 0pt \Large%\bfseries
        \interlinepenalty\@M%
        \vspace*{\@spaceinchapterhead}%
        \rule{0.666\textwidth}{0.5pt}%
        \par%
        \vspace*{\@spaceinchapterhead}%
        \vspace*{\@spaceinchapterhead}%
        {\spacedlowsmallcaps{#1}\hfill}%
        \mbox{}\par%
        \mbox{}\par%
        \mbox{}\par%
        \markright{}%remove header, there were problems with "My publications" header after "Bibliography"
    }%
}

Everything works as I expected, except unnumbered chapters that contain special characters in their name, for example

\chapter*{Sa{ž}etak}

The problem here is with the third argument in the pdfbookmark command, which is something like a label for the bookmark. I tried attacking this problem from different angles, but nothing seems to work. Simple solution would be to remove the pdfbookmark command from the chapter* definition, and to add it manually for all unnumbered chapters, but I'm trying to find a more elegant solution.

One of the possible solutions that I haven't tried is to put something like

\RemoveAllNonASCII{#1}

as the third argument, but I don't know how to design a function like that.

Any idea how to solve this problem?


Here is the minimum working example:

mwe.tex

\documentclass{style}

\begin{document}

\author{Me}
\title{MWE}

\maketitle

% Bookmark works
\chapter*{Unnumbered chapter}

% Bookmark does not work
\chapter*{Unnumbered chapter Ž}

% Bookmark works
\chapter{Numbered chapter}

% Bookmarks works, even though we have Ž in the title
\chapter{Numbered chapter Ž}

\end{document}

style.cls

\LoadClass[a4paper,11pt,oneside]{book}

\usepackage{hyperref}
\usepackage{bookmark}

\renewcommand{\@makeschapterhead}[1]{%
    {%
        \pdfbookmark[0]{#1}{#1}%
        {#1}
    }%
}
  • What happens if you add an optional parameter to your \chapter*? \chapter*[Sazetak]{Sa{ž}etak}? – LokiRagnarok Sep 3 '19 at 15:42
  • Thank you for your inputs, unfortunately they did not work. I added minimum working example. However, Ulrike Fischer proposed a solution that works. Thank you again! – Marko Gulin Sep 3 '19 at 16:41
1

Use something sensible as third argument.

\documentclass{article}
\usepackage{hyperref}
\newcounter{myschapter}
\begin{document}
 abc
\stepcounter{myschapter}
\pdfbookmark[0]{Sa{ž}etak}{schapter.\number\value{myschapter}}%
\end{document}
  • Excellent idea, I've set \thepage as label for bookmarks (third argument in the pdfbookmark command), everything works fine now. Thank you! – Marko Gulin Sep 3 '19 at 16:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.