Document ClassesBeamer: Failure on \foreignlanguage within section titles

Information and discussion about specific document classes and how to create your own document classes.
Post Reply
pebo
Posts: 3
Joined: Thu Aug 14, 2008 1:00 pm

Beamer: Failure on \foreignlanguage within section titles

Post by pebo »

In a beamer document (using beamer-3.07), I get an "Undefined control sequence" error on a line like:

\section{Motivation \foreignlanguage{italian}{Motivazione}}

while the foreignlanguage statements works correctly elsewhere.
For an example, take the conference-ornate-20min.de template from the beamer package and declare some text within a section title as italian. I attached the modified templates both in lyx (1.5.6) and by regular editor on .tex file, compiled by pdflatex (the modified line is one containing "Motivation")
I usually work with lyx, so I don't know that much about latex and I'm not sure if this is a bug or if I'm doing anything wrong.
Could anybody provide a workaround for this problem?
Thanks in advance
Last edited by pebo on Mon Aug 18, 2008 9:17 am, 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.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

Stefan Kottwitz
Site Admin
Posts: 10335
Joined: Mon Mar 10, 2008 9:44 pm

Beamer: Failure on \foreignlanguage within section titles

Post by Stefan Kottwitz »

Hi Pebo,

welcome to the board!
The command \foreignlanguage will cause problems with pdf bookmarks. In such cases you can use \texorpdfstring:

Code: Select all

\section{Motivation \texorpdfstring{\foreignlanguage{italian}{motivazione}}{motivazione}}
\texorpdfstring is explained by the hyperref manual.

Stefan
LaTeX.org admin
pebo
Posts: 3
Joined: Thu Aug 14, 2008 1:00 pm

Beamer: Failure on \foreignlanguage within section titles

Post by pebo »

Thank you, Stefan, like this the pdf compiles.
However, it's a little complicated to write, not as content-oriented as it should be. (I lost all this morning trying to figure out, what's wrong :x )
Maybe, one of hyperref, beamer or at least lyx, should handle this automatically (?)
For the moment, I will prepend this redefinition, I'll see whether it introduces new problems:

Code: Select all

\let\oldforeignlanguage\foreignlanguage
\renewcommand{\foreignlanguage}[2]{\texorpdfstring{\oldforeignlanguage{#1}{#2}}{#2}}
Post Reply