Set PDF metadata in LaTeX (title, author, keywords)
Load hyperref and set the fields with \hypersetup: pdftitle, pdfauthor, pdfsubject and pdfkeywords. A PDF viewer shows them in the document properties.
Preamble
The snippets on this page need these lines before \begin{document}:
\usepackage{hyperref}Title, author, subject and keywords
Put each value in braces, so a comma inside it is not read as the end of the option. Umlauts and other UTF-8 characters can be written directly.
This goes into the preamble.
\hypersetup{
pdftitle={Measuring Wind Speed with Ultrasound},
pdfauthor={Anna Schmidt, Jörg Müller},
pdfsubject={Master's thesis},
pdfkeywords={ultrasound, wind speed, sensor}
}Take title and author from the document
The package option pdfusetitle copies \title and \author into the PDF fields, so you write them only once.
Complete document:
\documentclass{article}
\usepackage[pdfusetitle]{hyperref}
\title{Measuring Wind Speed with Ultrasound}
\author{Anna Schmidt}
\begin{document}
\maketitle
Text of the document.
\end{document}Language and the view on opening
pdflang stores the language of the text, which screen readers use. pdfdisplaydoctitle=true shows the title in the title bar of the viewer in place of the file name, pdfpagemode=UseOutlines opens the bookmark panel, and pdfstartview=FitH fits the page width to the window.
This goes into the preamble.
\hypersetup{
pdflang={en-GB},
pdfdisplaydoctitle=true,
pdfpagemode=UseOutlines,
pdfstartview=FitH
}Bookmarks from the headings
hyperref turns the headings into PDF bookmarks. bookmarksnumbered=true adds the section numbers and bookmarksopen=true unfolds all levels. A bookmark is plain text; for a heading with a formula, \texorpdfstring{formula}{text} supplies the text for the bookmark.
Complete document:
\documentclass{article}
\usepackage{hyperref}
\hypersetup{bookmarksnumbered=true, bookmarksopen=true}
\begin{document}
\section{The \texorpdfstring{$\alpha$}{alpha} particle}
Text of the section.
\end{document}Pitfalls
- Without
\texorpdfstring, a formula in a heading gives the warning "Token not allowed in a PDF string", see Token not allowed in a PDF string (Unicode). hyperrefenters "LaTeX with hyperref" as the creating program.pdfcreator={}andpdfproducer={}empty the two fields about the software.- The
bookmarkpackage, loaded afterhyperref, writes the bookmarks in one run and adds options for their colour and font style.
Compiled with pdfLaTeX from TeX Live 2023.
Related pages
- Package
hyperref - Package
bookmark - How-to Insert hyperlinks in LaTeX
- How-to Create a title page in LaTeX
- Error Token not allowed in a PDF string (Unicode)