]> git.lyx.org Git - features.git/commitdiff
Prevent outputting \maketitle within an inset embedded in title.
authorJuergen Spitzmueller <spitz@lyx.org>
Sat, 4 Jul 2020 08:54:20 +0000 (10:54 +0200)
committerJuergen Spitzmueller <spitz@lyx.org>
Sat, 4 Jul 2020 08:54:20 +0000 (10:54 +0200)
Amends [e4ef8ddc0f8202/lyxgit]

src/insets/Inset.h
src/insets/InsetText.cpp
src/insets/InsetText.h
src/output_latex.cpp

index c2a4becb9357e29990c333215915deb0f7b9f723..653123073a1cb10b27cb103ef38349bf555a97ea 100644 (file)
@@ -469,6 +469,8 @@ public:
        virtual InsetLayout const & getLayout() const;
        ///
        virtual bool isPassThru() const { return getLayout().isPassThru(); }
+       /// Is this inset embedded in a title?
+       virtual bool isInTitle() const { return false; }
        /// Is this inset's layout defined in the document's textclass?
        bool undefined() const;
        /// should this inset be handled like a normal character?
index ba716aeba3fe810355c181f02c59ec9f3d5e431c..aeb4c43d6ba9192285fa9b2bd2ac490da1781dcf 100644 (file)
@@ -78,7 +78,8 @@ using graphics::PreviewLoader;
 /////////////////////////////////////////////////////////////////////
 
 InsetText::InsetText(Buffer * buf, UsePlain type)
-       : Inset(buf), drawFrame_(false), is_changed_(false), frame_color_(Color_insetframe),
+       : Inset(buf), drawFrame_(false), is_changed_(false), intitle_context_(false),
+         frame_color_(Color_insetframe),
        text_(this, type == DefaultLayout)
 {
 }
@@ -86,7 +87,7 @@ InsetText::InsetText(Buffer * buf, UsePlain type)
 
 InsetText::InsetText(InsetText const & in)
        : Inset(in), drawFrame_(in.drawFrame_), is_changed_(in.is_changed_),
-         frame_color_(in.frame_color_),
+         intitle_context_(false), frame_color_(in.frame_color_),
          text_(this, in.text_)
 {
 }
@@ -838,6 +839,9 @@ void InsetText::updateBuffer(ParIterator const & it, UpdateType utype, bool cons
                        cnt.restoreLastLayout();
                        // FIXME cnt.restoreLastCounter()?
                }
+               // Record in this inset is embedded in a title layout
+               // This is needed to decide when \maketitle is output.
+               intitle_context_ = it.paragraph().layout().intitle;
        } else {
                DocumentClass const & tclass = buffer().masterBuffer()->params().documentClass();
                // Note that we do not need to call:
index d50d5556c14ff265ca36273577eb24e3676b5402..59f1202a24235bf324784c811ee9629f1ec64f29 100644 (file)
@@ -161,6 +161,8 @@ public:
        ///
        virtual bool allowMultiPar() const { return getLayout().isMultiPar(); }
        ///
+       bool isInTitle() const { return intitle_context_; }
+       ///
        /// should paragraphs be forced to use the empty layout?
        virtual bool forcePlainLayout(idx_type = 0) const
                { return getLayout().forcePlainLayout(); }
@@ -252,6 +254,8 @@ private:
        /// true if the inset contains change
        mutable bool is_changed_;
        ///
+       bool intitle_context_;
+       ///
        ColorCode frame_color_;
        ///
        Text text_;
index d567ecc53c9824ecf82ff2abb05f8ad310ece7b9..12f58aaecdaff0c9d5c103321425d3d35854fde0 100644 (file)
@@ -1627,7 +1627,8 @@ void latexParagraphs(Buffer const & buf,
                                                        << "}\n";
                                }
                        }
-               } else if (runparams.need_maketitle && !runparams.have_maketitle && !layout.inpreamble) {
+               } else if (runparams.need_maketitle && !runparams.have_maketitle
+                          && !layout.inpreamble && !text.inset().isInTitle()) {
                        if (tclass.titletype() == TITLE_ENVIRONMENT) {
                                os << "\\end{" << from_ascii(tclass.titlename())
                                                << "}\n";