]> git.lyx.org Git - lyx.git/blobdiff - src/output_latex.cpp
Fix bug #6649 - fix texrow structure generated by InsetIndex
[lyx.git] / src / output_latex.cpp
index a87416d7b7955e22066fcdeb797ab5465206ceca..cdd42aaf4325222dffc0f18efff4d343bca6e20c 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);
@@ -339,17 +348,6 @@ ParagraphList::const_iterator TeXOnePar(Buffer const & buf,
        Layout const style = text.inset().forcePlainLayout() ?
                bparams.documentClass().plainLayout() : pit->layout();
 
-       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
@@ -462,7 +460,9 @@ ParagraphList::const_iterator TeXOnePar(Buffer const & buf,
                // Look ahead for future encoding changes.
                // We try to output them at the beginning of the paragraph,
                // since the \inputencoding command is not allowed e.g. in
-               // sections.
+               // sections. For this reason we only set runparams.moving_arg
+               // after checking for the encoding change, otherwise the
+               // change would be always avoided by switchEncoding().
                for (pos_type i = 0; i < pit->size(); ++i) {
                        char_type const c = pit->getChar(i);
                        Encoding const * const encoding =
@@ -513,6 +513,7 @@ ParagraphList::const_iterator TeXOnePar(Buffer const & buf,
                }
        }
 
+       runparams.moving_arg |= style.needprotect;
        Encoding const * const prev_encoding = runparams.encoding;
 
        bool const useSetSpace = bparams.documentClass().provides("SetSpace");
@@ -677,7 +678,7 @@ ParagraphList::const_iterator TeXOnePar(Buffer const & buf,
                                        (nextpit == paragraphs.end()
                                        && runparams.master_language)
                                                ? runparams.master_language
-                                               : prev_language;
+                                               : outer_language;
                                if (!current_language->babel().empty()) {
                                        os << from_ascii(subst(
                                                lyxrc.language_command_begin,
@@ -829,7 +830,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()) {
@@ -903,7 +904,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) {