Use accented characters in bookmarks
I suggest you (a) load the fontenc
package with the option T1
, (b) simplify the way you load the hyperref
package, and (c) not load the bookmark
and inputenc
packages unless your TeX distributions is several years old and hasn't been updated in more than three years.
\documentclass[twoside, 12pt]{article}
\usepackage[letterpaper, headheight=15pt, hmargin=1cm, vmargin=2cm]{geometry}
\usepackage{fancyhdr}
\usepackage[T1]{fontenc} % <-- new
\usepackage[bookmarks]{hyperref} % <-- simplified
\newcommand{\group}[1]{\pdfbookmark{#1}{#1}}
\newcommand{\recipe}[1]{%
\newpage%
\pagestyle{fancy}%
\fancyhead[RO,LE]{\footnotesize\textbf{#1}}%
\fancyfoot[RO,LE]{\thepage}%
\fancyfoot[C]{}%
\pdfbookmark[1]{#1}{\pdfmdfivesum{#1}}%
\section*{#1}%
}
\begin{document}
\group{Boissons}
\recipe{Dark \& stormy}
\recipe{Limonana}
\group{Desserts}
\recipe{Tiramisu}
\recipe{X-mas cake}
\group{Poisson}
\recipe{Gravlax de saumon au miel et à la moutarde}
\recipe{Pain de saumon}
\group{Viande}
\recipe{Boulets de Liège}
\recipe{Poulet à l'ananas}
\recipe{Ragoût à la joue de bœuf et lard paysan}
\end{document}
The rendering of the bookmarks in your example should work fine if you compile with a current tex system and the pdf viewer can handle unicode.
What doesn't work are the actual links: the bookmark package and hyperref have slightly different methods and settings to handle commands in destination names and so create different names in your example. So you need to use \detokenize
to make them to simple strings:
\documentclass{article}
\usepackage[unicode]{hyperref}
\usepackage{bookmark}
\begin{document}
xxx
\newpage
aaa
\pdfbookmark[1]{1. Ragoût à la joue de bœuf et lard paysan}
{\pdfmdfivesum{zzzRagoût à la joue de bœuf et lard paysan}}
\pdfbookmark[1]{2. Ragoût à la joue de bœuf et lard paysan}
{\pdfmdfivesum{\detokenize{xxxRagoût à la joue de bœuf et lard paysan}}}
\end{document}
In the first bookmark will give a warning
pdfTeX warning (dest): name{68378F0B27FA693E17106CB4A2941F21.
1} has been referenced but does not exist, replaced by a fixed one
and jump to the first page, but the second will work.
An alternative is to use the sectioning commands. The hyperref
package will generate bookmarks for all sections, subsections, and so on, down to the current bookmarksdepth
(which by default is the \tocdepth
).
It lets you use all the standard commands for section formatting, create a table of contents page in addition to the PDF bookmarks, and make references to a \label
.
\documentclass[twoside, 12pt]{article}
\tracinglostchars=2 % Warn if the current font is missing a glyph
\usepackage[letterpaper, headheight=15pt, left=1cm, right=1cm, top=2cm, bottom=2cm]{geometry}
\usepackage{fancyhdr}
\usepackage[hidelinks,bookmarks,bookmarksdepth,unicode]{hyperref}
\usepackage{libertinus} % Or your fonts of choice.
\usepackage{microtype}
\setcounter{tocdepth}{2} % Create bookmarks for subsections (recipes)
\newcommand{\group}[1]{%
\clearpage%
\section{#1}%
\markright{}%
}
\newcommand{\recipe}[1]{%
\pagebreak%
\subsection*{#1}%
\markright{#1}%
}
\pagestyle{fancy}%
\fancyhead[RE,LO]{\textsc{\nouppercase{\leftmark}}}
\fancyhead[RO,LE]{\footnotesize{\textbf{\rightmark}}}%
\fancyfoot[RO,LE]{\thepage}%
\fancyfoot[C]{}%
\begin{document}
\group{Boissons}\label{gr:boissons}
\recipe{Dark \& stormy}\label{rx:darknstormy}
\recipe{Limonana}\label{rx:limonana}
\group{Desserts}\label{gr:desserts}
\recipe{Tiramisu}\label{rx:tiramisu}
\recipe{X-mas cake}\label{rx:xmascake}
\group{Poisson}\label{gr:poisson}
\recipe{Gravlax de saumon au miel et à la moutarde}\label{rx:gravlax}
\recipe{Pain de saumon}\label{rx:painsaumon}
\group{Viande}\label{gr:viande}
\recipe{Boulets de Liège}\label{rx:liegs}
\recipe{Poulet à l'ananas}\label{rx:lananas}
\recipe{Ragoût à la joue de bœuf et lard paysan}\label{rx:ragoutpaysan}
\end{document}
That code is compatible with both LuaLaTeX and PDFTeX. I personally recommend LuaTeX except when a publisher forces you to use PDFTeX, but use what you prefer.