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.

MS-SPO
  • 11,519
Sahana
  • 9
  • 5

1 Answers1

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

frougon
  • 24,283
  • 1
  • 32
  • 55
  • 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 '18 at 09: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 '18 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 09 '22 at 08: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 09 '22 at 09:12
  • Good point, I just checked pdf properties and mouse-hovering popup in Windows. That's how most people receiving my PDFs will have access to that info, on the other hand:( – Andrestand Jul 09 '22 at 14:35
  • @Andrestand By the way, unless you use something like \edef\mypdftitle{\GetDocumentProperties{hyperref/pdftitle}} \title{\mypdftitle}, I don't think providing LaTeX markup for the pdftitle key is useful; do you have another use for it? – frougon Jul 09 '22 at 16:47
  • @frougon I'm not sure if I fully understand your comment, but I guess my answer is no. My point is that people using Windows will probably see 3o instead of (which is how 3rd is usually written in Spanish). – Andrestand Jul 10 '22 at 11:09
  • 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 '22 at 12:17