0

This is my title page of my thesis and the code is as below

\documentclass{article}
\begin{document}
\hypersetup{
pdftitle={properties of F\textsubscript{2}},
pdfauthor={xxx},
pdfsubject={Masterthesis},
pdfkeywords={Master Thesis},
pdfpagelayout=OneColumn, pdfnewwindow=true, pdfstartview=XYZ, plainpages=false} 
\end{document}

I get six warnings as below for using a subscript in this hypersetup environment. Is it the subscript causing the warning or something else? Could someone help me understand this better? Thank you.

Package hyperref Warning: Token not allowed in a PDF string (PDFDocEncoding): (hyperref) removing '\mathsurround' on input line.

Package hyperref Warning: Token not allowed in a PDF string (PDFDocEncoding): (hyperref) removing '\z@' on input line.

Package hyperref Warning: Token not allowed in a PDF string (PDFDocEncoding): (hyperref) removing 'subscript' on input line.

Package hyperref Info: Option 'pdfnewwindow' set 'true' on input line.

Package hyperref Info: Option 'plainpages' set 'false' on input line.

1 Answer 1

1

I doubt your example compiles (no \usepackage{hyperref}).

Anyway, the following works without warnings:

\documentclass{article}
\usepackage{hyperref}

\hypersetup{
  pdftitle={\texorpdfstring{Properties of F\textsubscript{2}}{Properties of F2}},
  pdfauthor={xxx},
  pdfsubject={Masterthesis},
  pdfkeywords={Master Thesis},
  pdfpagelayout=OneColumn,
  pdfnewwindow=true,
  pdfstartview=XYZ,
  plainpages=false}

\begin{document}
Blah.
\end{document}

Explanation: text strings for PDF metadata can't contain fancy TeX markup. hyperref's \texorpdfstring command allows one to specify two versions of a given string: the first argument may contain (La)TeX markup and is used for typesetting, whereas the second argument is used when the string is embedded as PDF metadata (title, author, subject, etc.)

8
  • Thanks @frougon. I have defined the package as \usepackage[bookmarks,bookmarksnumbered=true,bookmarksopenlevel=section,breaklinks=false,pdfborder={0 0 0},backref=false,colorlinks=false]{hyperref} . Is this correct way?
    – Sahana
    Jun 22, 2018 at 9:48
  • If you're satisfied with the answer, please mark it as accepted. Concerning what you ask, these are really different questions. bookmarksopenlevel should be an integer (see example). The rest seems okay at first sight (see here for an authoritative post about pdfborder).
    – frougon
    Jun 22, 2018 at 10:01
  • A year ago, hyperref didn't complain about a \textsuperscript{o} (although the metadata output was "3,52,5o" for it). I came back to the code today and I found not even \texorpdfstring{\textsuperscript{o}}{º} runs without errors :(, so I will have to accept a \texorpdfstring{$^\text{o}$}{º} (although the metadata will read "o" instead of "º").
    – Andrestand
    Jul 9, 2022 at 8:52
  • 1
    @Andrestand Not sure if it is correct for the PDF metadata encoding, but \texorpdfstring{Properties of F\textsubscript{o}}{Properties of Fº} results in apparently correct metadata (displayed by pdfinfo and okular). Tested with TeX Live updated today, after seeing your comment.
    – frougon
    Jul 9, 2022 at 9:12
  • 1
    @Andrestand My comment was an interrogation regarding my own answer: I could have proposed pdftitle={Properties of F2}. I have the impression that using \texorpdfstring inside the pdftitle is likely not very useful as the value doesn't get typeset by LaTeX, unless one extracts it like I wrote using \GetDocumentProperties, then uses the result in typesetting. Now regarding your point: looking at §7.19, Option ‘pdfencoding’ in the hyperref manual, Unicode seems to be supported by default nowadays for the information dictionary; so, AFAIUI, using ° directly here should be fine.
    – frougon
    Jul 10, 2022 at 12:17

You must log in to answer this question.

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