]> git.lyx.org Git - lyx.git/blobdiff - src/insets/InsetIndex.cpp
de.po
[lyx.git] / src / insets / InsetIndex.cpp
index 113ba77fc7f943a0d52ab9a2951427a85924b7a2..f3fafce60b00d8af9d62813a074fa3314236634a 100644 (file)
@@ -59,11 +59,13 @@ InsetIndex::InsetIndex(Buffer * buf, InsetIndexParams const & params)
 {}
 
 
-void InsetIndex::latex(otexstream & os, OutputParams const & runparams_in) const
+void InsetIndex::latex(otexstream & ios, OutputParams const & runparams_in) const
 {
        OutputParams runparams(runparams_in);
        runparams.inIndexEntry = true;
 
+       otexstringstream os;
+
        if (buffer().masterBuffer()->params().use_indices && !params_.index.empty()
            && params_.index != "idx") {
                os << "\\sindex[";
@@ -74,19 +76,19 @@ void InsetIndex::latex(otexstream & os, OutputParams const & runparams_in) const
                os << '{';
        }
 
-       odocstringstream ourplain;
-       InsetText::plaintext(ourplain, runparams);
+       odocstringstream ourlatex;
+       otexstream ots(ourlatex);
+       InsetText::latex(ots, runparams);
        if (runparams.for_search) {
                // No need for special handling, if we are only searching for some patterns
-               os << ourplain.str() << "}";
+               os << ourlatex.str() << "}";
                return;
        }
        // get contents of InsetText as LaTeX and plaintext
-       odocstringstream ourlatex;
+       odocstringstream ourplain;
+       InsetText::plaintext(ourplain, runparams);
        // FIXME: do Tex/Row correspondence (I don't currently understand what is
        // being generated from latexstr below)
-       otexstream ots(ourlatex);
-       InsetText::latex(ots, runparams);
        docstring latexstr = ourlatex.str();
        docstring plainstr = ourplain.str();
 
@@ -170,6 +172,13 @@ void InsetIndex::latex(otexstream & os, OutputParams const & runparams_in) const
                os << "|" << cmd;
        }
        os << '}';
+
+       // In macros with moving arguments, such as \section,
+       // we store the index and output it after the macro (#2154)
+       if (runparams_in.postpone_fragile_stuff)
+               runparams_in.post_macro += os.str();
+       else
+               ios << os.release();
 }