Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

\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

1 Answer 1

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 at 10:03
    
    
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 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.