2

I was trying Asana Math font on old file to see how it looks. I found lualatex gives a compile error because the file was using

    \usepackage[pdfencoding=auto]{hyperref}

Changing the above to

    \usepackage[]{hyperref}

Removes the error. Also removing Asana Math font and keeping pdfencoding fixes the error. I have math fonts inside subsubsection title.

Why is that? What Am I doing wrong and what is best way to correct this?

Here is one which shows the error

\documentclass[12pt]{article}%

\usepackage{amsmath}

\usepackage{fontspec}
\usepackage{unicode-math}
\setmathfont{Asana Math}

\usepackage[pdfencoding=auto]{hyperref}

\begin{document}
\subsubsection{Part 4 $\det\left(  A^{T}\right)  =\det A$}
test

\end{document}

And now lualatex foo.tex gives

This is LuaTeX, Version 1.10.0 (TeX Live 2019)
 restricted system commands enabled.
(./foo.tex
LaTeX2e <2018-12-01>
....    
Package hyperref Warning: Token not allowed in a PDF string (Unicode):
(hyperref)                removing `\nmlimits@' on input line 13.

! Improper alphabetic constant.
<to be read again>
\math@bgroup
l.13 ...{Part 4 $\det\left(  A^{T}\right)  =\det A$}

?

But if I use this

\documentclass[12pt]{article}%    
\usepackage{amsmath}     
\usepackage[pdfencoding=auto]{hyperref}

\begin{document}
\subsubsection{Part 4 $\det\left(  A^{T}\right)  =\det A$}
test

\end{document}

No error. But I get same warnings from hyperref

Package hyperref Warning: Token not allowed in a PDF string (Unicode):
(hyperref)                removing `math shift' on input line 10.

According to answer Math symbol in section heading it said

Option pdfencoding=auto or unicode enables bookmarks in Unicode with more symbols.

Using TL 2019

2

Bookmarks must be written in the PDF encoding, not with LaTeX formatting (although some text-mode macros that expand to characters will still work). You might be able to make some formulae work by adding the option psdextra to hyperref.

You can specify an alternative PDF string for the table of contents. This may contain any Unicode characters, including all mathematical symbols, the mathematical alphanumeric symbols, and the superscripts and subscripts.

\documentclass[12pt]{article}

\usepackage{amsmath}
\usepackage{fontspec}
\usepackage{unicode-math}

\defaultfontfeatures{Scale=MatchLowercase}
\setmainfont{TeX Gyre Pagella}[Scale = 1.0]
\setmathfont{Asana Math}

\usepackage[unicode, bookmarks]{hyperref}

\newcommand\transpose[1]{#1^{\symup T}}

\begin{document}
\subsubsection{\texorpdfstring{Part 4 \( \det\left(  \transpose{A} \right)  =\det A \)}%
                              {Part 4 det(𝐴ᵀ) = det 𝐴}%
}
test

\end{document}

You might also use the bookmark package. On a side note, if you’re including text like “Part 4,” you might instead increase the tocdepth or bookmarksdepth to auto-number sub-sections in the table of contents. Also, if you want the math in your section header to match the weight of the text, you either need to use \boldmath or \boldsymbol with a math font that has a bold weight (as of 2019, XITS Math, Libertinus Math or Minion Math) or change the formatting of headers to use regular weight.

| improve this answer | |
1

Basically the problem is described in https://github.com/latex3/hyperref/issues/63: hyperref doesn't like it if in the text meant for the bookmarks are commands which have been let to a char.

Somewhere in the depth of the font changing commands of unicode math such a command is used, and then the \det fails. I don't know a good solution: The luacode in the issue will not resolve the problem; while it avoids the error it also inserts unwanted content in the booksmarks.

The best is really to avoid arbitrary, complicated math in content meant for the bookmarks. Use as Davislor suggested \texorpdfstring.

Side remark: With a current hyperref and lualatex you can/should simply use

  \usepackage{hyperref} 

This will default to unicode bookmarks.

| improve this answer | |

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.