]> 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 09:01:22 +0000 (11:01 +0200)
Amends [e4ef8ddc0f8202/lyxgit]

(cherry picked from commit 0bddf448ef5756eee90c771ff3277dd805b2b0a3)

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

index a1c0518a2cc729438e598cc69485fbe44b0db6aa..c14f8b526fcfeb1542994ee8ab1c52c74a984046 100644 (file)
@@ -448,6 +448,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 d0a37d673200e82e0c889bf38eb191d6c05f7c10..358a377542ddb96c89531c48dea0a82253aada16 100644 (file)
@@ -79,14 +79,14 @@ using graphics::PreviewLoader;
 /////////////////////////////////////////////////////////////////////
 
 InsetText::InsetText(Buffer * buf, UsePlain type)
-       : Inset(buf), drawFrame_(false), frame_color_(Color_insetframe),
-       text_(this, type == DefaultLayout)
+       : Inset(buf), drawFrame_(false), intitle_context_(false),
+         frame_color_(Color_insetframe), text_(this, type == DefaultLayout)
 {
 }
 
 
 InsetText::InsetText(InsetText const & in)
-       : Inset(in), text_(this, in.text_)
+       : Inset(in), intitle_context_(false), text_(this, in.text_)
 {
        drawFrame_ = in.drawFrame_;
        frame_color_ = in.frame_color_;
@@ -793,6 +793,9 @@ void InsetText::updateBuffer(ParIterator const & it, UpdateType utype)
                        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 eea88cdd690786ac9fddfaaa127872159b4c9180..76d3a5217fc2a56d1eb0935032af1cf28fd1bb5f 100644 (file)
@@ -157,6 +157,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(); }
@@ -240,6 +242,8 @@ private:
        ///
        bool drawFrame_;
        ///
+       bool intitle_context_;
+       ///
        ColorCode frame_color_;
        ///
        Text text_;
index c382050680ef25f3fc689579b0cb68f6ad2e210d..3838ba39934729033881c1b06d08ed2672c7eb37 100644 (file)
@@ -1496,7 +1496,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";