]> git.lyx.org Git - lyx.git/blobdiff - src/output_latex.cpp
Micro-optimization.
[lyx.git] / src / output_latex.cpp
index d40874e041959b60141ff60b235caf823f5bfe80..5457dee3dfdd6ec0331f61a250cb370021b398ae 100644 (file)
@@ -181,7 +181,7 @@ TeXEnvironment(Buffer const & buf,
                           << "}\n";
                } else if (style.labeltype == LABEL_BIBLIO) {
                        if (pit->params().labelWidthString().empty())
-                               os << '{' << bibitemWidest(buf) << "}\n";
+                               os << '{' << bibitemWidest(buf, runparams) << "}\n";
                        else
                                os << '{'
                                  << pit->params().labelWidthString()
@@ -319,6 +319,15 @@ ParagraphList::const_iterator TeXOnePar(Buffer const & buf,
        OutputParams runparams = runparams_in;
        runparams.isLastPar = nextpit == paragraphs.end();
 
+       bool const maintext = text.isMainText();
+       // we are at the beginning of an inset and CJK is already open;
+       // we count inheritation levels to get the inset nesting right.
+       if (pit == paragraphs.begin() && !maintext
+           && (cjk_inherited_ > 0 || open_encoding_ == CJK)) {
+               cjk_inherited_ += 1;
+               open_encoding_ = none;
+       }
+
        if (runparams.verbatim) {
                int const dist = distance(paragraphs.begin(), pit);
                Font const outerfont = text.outerFont(dist);
@@ -341,15 +350,6 @@ ParagraphList::const_iterator TeXOnePar(Buffer const & buf,
 
        runparams.moving_arg |= style.needprotect;
 
-       bool const maintext = text.isMainText();
-       // we are at the beginning of an inset and CJK is already open;
-       // we count inheritation levels to get the inset nesting right.
-       if (pit == paragraphs.begin() && !maintext
-           && (cjk_inherited_ > 0 || open_encoding_ == CJK)) {
-               cjk_inherited_ += 1;
-               open_encoding_ = none;
-       }
-
        // This paragraph's language
        Language const * const par_language = pit->getParLanguage(bparams);
        // The document's language
@@ -671,11 +671,18 @@ ParagraphList::const_iterator TeXOnePar(Buffer const & buf,
                // when the paragraph uses CJK, the language has to be closed earlier
                if (font.language()->encoding()->package() != Encoding::CJK) {
                        if (lyxrc.language_command_end.empty()) {
-                               if (!prev_language->babel().empty()) {
+                               // If this is a child, we should restore the
+                               // master language after the last paragraph.
+                               Language const * const current_language =
+                                       (nextpit == paragraphs.end()
+                                       && runparams.master_language)
+                                               ? runparams.master_language
+                                               : outer_language;
+                               if (!current_language->babel().empty()) {
                                        os << from_ascii(subst(
                                                lyxrc.language_command_begin,
                                                "$$lang",
-                                               prev_language->babel()));
+                                               current_language->babel()));
                                        pending_newline = true;
                                }
                        } else if (!par_language->babel().empty()) {
@@ -822,7 +829,7 @@ void latexParagraphs(Buffer const & buf,
                texrow.newline();
                open_encoding_ = CJK;
        }
-       // if "auto begin" is switched off, explicitely switch the
+       // if "auto begin" is switched off, explicitly switch the
        // language on at start
        if (maintext && !lyxrc.language_auto_begin &&
            !bparams.language->babel().empty()) {
@@ -896,7 +903,7 @@ void latexParagraphs(Buffer const & buf,
                texrow.newline();
        }
 
-       // if "auto end" is switched off, explicitely close the language at the end
+       // if "auto end" is switched off, explicitly close the language at the end
        // but only if the last par is in a babel language
        if (maintext && !lyxrc.language_auto_end && !bparams.language->babel().empty() &&
                lastpar->getParLanguage(bparams)->encoding()->package() != Encoding::CJK) {