LaTeX forum ⇒ Text FormattingMakeUppercase, hyperref, and addcontentsline

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
jaykemper
Posts: 22
Joined: Wed Apr 15, 2009 12:11 am

MakeUppercase, hyperref, and addcontentsline

Postby jaykemper » Tue Dec 06, 2011 10:44 pm

Is there a workaround to the problem this creates?

  1. \documentclass{article}
  2.  
  3. \usepackage{hyperref}
  4.  
  5. \begin{document}
  6. \tableofcontents
  7. \addcontentsline{toc}{section}{\MakeUppercase{section}}
  8. \end{document}


yields

  1. Package hyperref Warning: old toc file detected, not used; run LaTeX again.
  2.  
  3. ! Undefined control sequence.
  4. \MakeUppercase ...rcaseIsNotSupportedInPdfStrings
  5.  
  6. l.9 ...line{toc}{section}{\MakeUppercase{section}}



If the hyperref package is commented out, it builds fine with a table of contents containing "SECTION"

Tags:

jaykemper
Posts: 22
Joined: Wed Apr 15, 2009 12:11 am

Postby jaykemper » Tue Dec 06, 2011 11:18 pm

Found a solution, use \texorpdfstring with an empty second argument.

  1. \documentclass{article}
  2.  
  3. \usepackage{hyperref}
  4.  
  5. \begin{document}
  6. \tableofcontents
  7. \addcontentsline{toc}{section}{\texorpdfstring{\MakeUppercase{section}}{}}
  8. \end{document}

User avatar
Stefan Kottwitz
Site Admin
Posts: 9582
Joined: Mon Mar 10, 2008 9:44 pm

Postby Stefan Kottwitz » Tue Dec 06, 2011 11:19 pm

It works with \uppercase:

  1. \documentclass{article}
  2. \usepackage{hyperref}
  3. \begin{document}
  4. \tableofcontents
  5. \addcontentsline{toc}{section}{\uppercase{section}}
  6. \end{document}


Stefan
LaTeX.org admin

jaykemper
Posts: 22
Joined: Wed Apr 15, 2009 12:11 am

Postby jaykemper » Wed Dec 07, 2011 12:28 am

I guess that does work, but it gives this message:

  1. Package hyperref Warning: Token not allowed in a PDF string (PDFDocEncoding):
  2. (hyperref) removing `\uppercase' on input line 5.


But I guess you can ignore the messages.


Return to “Text Formatting”

Who is online

Users browsing this forum: No registered users and 6 guests