Jürgen Spitzmüller wrote:
I stumbled over a bug in trunk and branch that slipped in with my CJK patch.
If "auto begin" is disabled in Prefs->Language, a language switch command is
inserted in an optArg inset, so you get something like
\section[\selectlanguage{english}short title]{long title}
in an English document, which breaks LaTeX compilation.
The reason is that I assumed (erroneously) that runparams.local_font (as used
in other places) is a safe indicator whether we are in an inset or in the
main text. However, local_font returns zero not only in the main text, but
also in OptArg insets.
The attached patch (against branch) fixes the issue by adding a new bool
argument "maintext" to latexParagraphs. I have also transferred the begin and
end tags from TeXOnePar to latexParagraphs, where they belong IMO.
Instead of doing this, you could pass a Text object instead of
ParagraphList. As the reference Buffer is also available, you can then
use Text::isMainText().
Abdel.