TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

\foreignlanguage does not work in tabular. How to switch language in tabular?

\documentclass[spanish,russian]{scrbook}
\usepackage[T1,T2A]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage{misccorr}
\usepackage{array}

\begin{document}

\selectlanguage{russian}

\foreignlanguage{spanish}{This text is ok.} Здесь всё хорошо.

\begin{tabular}{ll}
\foreignlanguage{spanish}{Not work: some words in spanish.} & А здесь по-русски. \\
\end{tabular}

\end{document}

pdfLaTeX said:

! Missing \endgroup inserted.
<inserted text> 
                \endgroup 
l.15 ...spanish}{Not work: some words in spanish.}
                                                   & А здесь по-ру...

? 
share|improve this question

Oh that's a bit odd, you should maybe report it as a bug in babel, however an extra group fixes it:

\documentclass[spanish,russian]{scrbook}
\usepackage[T1,T2A]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage{misccorr}
\usepackage{array}

\begin{document}

\selectlanguage{russian}

\foreignlanguage{spanish}{This text is ok.} Здесь всё хорошо.

\begin{tabular}{ll}
{\foreignlanguage{spanish}{Not work: some words in spanish.}}& А здесь по-русски. \\
\end{tabular}

\end{document}
share|improve this answer
    
Note that it's specific of Spanish; the error happens when TeX is processing \es@operators, which uses & for doing a recursion, which obviously doesn't please TeX when found at the outer level in a table. – egreg Mar 27 '14 at 10:03
    
I reported this: latex-project.org/cgi-bin/ltxbugs2html?pr=babel/4374 – David Carlisle Mar 27 '14 at 10:11
    
Sometimes package writers have some weird ideas ;-) I'm working in a new version of spanish and I'll fix this bug. – Javier Bezos Mar 27 '14 at 15:49

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.