Math & ScienceIncluding math expressions in titles?

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
Post Reply
aerodan
Posts: 3
Joined: Wed Jul 28, 2010 4:29 am

Including math expressions in titles?

Post by aerodan »

Hi,

I am trying to include math expressions in some of my section titles, with a bunch of warnings as a result. Here's what I did:

Code: Select all

\subsection{Optimization Using $\Delta x_b, \Delta y_b$}
I get the following warnings (no errors):
./GaitOptimizationChapter.tex:501: Token not allowed in a PDFDocEncoded string,(hyperref) removing `math shift' on input line 501. Token not allowed in a PDFDocEncoded string,(hyperref) removing `math shift'
./GaitOptimizationChapter.tex:501: Token not allowed in a PDFDocEncoded string,(hyperref) removing `\Delta' on input line 501. Token not allowed in a PDFDocEncoded string,(hyperref) removing `\Delta'
./GaitOptimizationChapter.tex:501: Token not allowed in a PDFDocEncoded string,(hyperref) removing `subscript' on input line 501. Token not allowed in a PDFDocEncoded string,(hyperref) removing `subscript'
./GaitOptimizationChapter.tex:501: Token not allowed in a PDFDocEncoded string,(hyperref) removing `\Delta' on input line 501. Token not allowed in a PDFDocEncoded string,(hyperref) removing `\Delta'
./GaitOptimizationChapter.tex:501: Token not allowed in a PDFDocEncoded string,(hyperref) removing `subscript' on input line 501. Token not allowed in a PDFDocEncoded string,(hyperref) removing `subscript'
I would appreciate any comments on what these warnings mean, and how to get rid of them.
Last edited by aerodan on Wed Jul 28, 2010 4:23 pm, edited 1 time in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

frabjous
Posts: 2064
Joined: Fri Mar 06, 2009 12:20 am

Including math expressions in titles?

Post by frabjous »

You need to follow board rules and provide an actual minimal working example, and not a single line of code out of context.

It is obvious that the errors have to do with the hyperref package, yet, how are we even supposed to know that you are using the hyperref package, and what options you are giving it, etc., when you only provided a single line of code?

If I had to guess, however, I'd say that these warnings are the result of hyperref trying to create “PDF bookmarks”, or basically, a PDF table of contents that can be displayed on the side panel of many PDF viewers. These bookmarks do not allow subscripts or superscripts or special mathematical characters, and hence this results is a mismatch between the PDF bookmark and the actual subsection name.

Perhaps this screenshot will indicate what I mean:
Screenshot-tester.pdf.png
Screenshot-tester.pdf.png (25.24 KiB) Viewed 10553 times
The best way I know to deal with this is to use the optional argument to specify an alternative subsection name to use in the table of contents, free of special symbols, etc.

Code: Select all

\subsection[Optimization Using Delta xb, Delta yb]{Optimization Using $\Delta x_b, \Delta y_b$}
This may result in other changes you don’t want, however, especially if there’s a normal table of contents, or subsection names are displayed in headings, etc. If you don't mind slight errors in the PDF bookmarks, however, the warnings are pretty much harmless and can be ignored.
aerodan
Posts: 3
Joined: Wed Jul 28, 2010 4:29 am

Re: Including math expressions in titles?

Post by aerodan »

Thank you frabjous, I see the problem now. After trying it with the optional name parameter the warnings went away.

I'll be more careful about posting full working examples in the future.
aerodan
Posts: 3
Joined: Wed Jul 28, 2010 4:29 am

Including math expressions in titles?

Post by aerodan »

By the way, I figured out an extension to your solution that made it work even better for me:

Code: Select all

\subsection [Optimization Using \texorpdfstring{$(\Delta x_b, \Delta y_b)$}{(Delta xb, Delta yb)}]	{Full Gait Optimization Using $(\Delta x_b, \Delta y_b)$}
By using \texorpdfstring the text that shows up in the table of contents is the actual mathematical expression, and the text shown in the PDF Bookmarks list on the side of the document is the second argument of \texorpdfstring.
User avatar
Stefan Kottwitz
Site Admin
Posts: 10345
Joined: Mon Mar 10, 2008 9:44 pm

Re: Including math expressions in titles?

Post by Stefan Kottwitz »

Hi aerodan,

welcome to the board!
\texorpdfstring is the right way, as mentioned in the hyperref manual.
Btw. please mark the topic as "solved" if the question is solved. This can be done by editing the first post and choosing the checkmark symbol as topic icon.

Stefan
LaTeX.org admin
Post Reply