commit f0126b9fdff2118f3e9566387bed0cb5da2df9d4
Author: Juergen Spitzmueller <[email protected]>
Date:   Sun Oct 31 11:56:53 2021 +0100

    \\noindent in a paragraph that starts with \\vspace is possible
    
    But the \\vspace must precede \\noindent (the latter leaves vmode)
---
 src/OutputParams.h         |    5 ++++-
 src/Paragraph.cpp          |   25 +++++++++++++++++--------
 src/insets/InsetVSpace.cpp |   10 ++++++++--
 3 files changed, 29 insertions(+), 11 deletions(-)

diff --git a/src/OutputParams.h b/src/OutputParams.h
index 2191a83..7ca5c1f 100644
--- a/src/OutputParams.h
+++ b/src/OutputParams.h
@@ -283,7 +283,7 @@ public:
 
        /** Whether we are in a table cell.
         *  For newline, it matters whether its content is aligned or not.
-         */
+       */
        TableCell inTableCell = NO;
 
        /** Whether we are inside a float or subfloat.
@@ -422,6 +422,9 @@ public:
 
        /// Explicit output folder, if any is desired
        std::string export_folder;
+
+       /// A postponed \\noindent (after VSpace)
+       mutable bool need_noindent = false;
 };
 
 
diff --git a/src/Paragraph.cpp b/src/Paragraph.cpp
index 10131ef..6b1e118 100644
--- a/src/Paragraph.cpp
+++ b/src/Paragraph.cpp
@@ -2355,14 +2355,23 @@ int Paragraph::Private::startTeXParParams(BufferParams 
const & bparams,
        // 1. that cannot have indentation or are indented always,
        // 2. that are not part of the immediate text sequence (e.g., contain 
only floats),
        // 3. that are PassThru,
-       // 4. that are centered,
-       // 5. or start with a vspace.
-       if (canindent && params_.noindent() && owner_->isPartOfTextSequence()
-           && !layout_->pass_thru && curAlign != LYX_ALIGN_CENTER
-           && !owner_->empty()
-           && (!owner_->isInset(0) || owner_->getInset(0)->lyxCode() != 
VSPACE_CODE)) {
-               os << "\\noindent" << termcmd;
-               column += 10;
+       // 4. or that are centered.
+       if (canindent && params_.noindent()
+           && owner_->isPartOfTextSequence()
+           && !layout_->pass_thru
+           && curAlign != LYX_ALIGN_CENTER) {
+               if (!owner_->empty()
+                   && (owner_->isInset(0)
+                       && owner_->getInset(0)->lyxCode() == VSPACE_CODE))
+                       // If the paragraph starts with a vspace, the \\noindent
+                       // needs to come after that (as it leaves vmode).
+                       // If the paragraph consists only of the vspace,
+                       // \\noindent is not needed at all.
+                       runparams.need_noindent = owner_->size() > 1;
+               else {
+                       os << "\\noindent" << termcmd;
+                       column += 10;
+               }
        }
 
        if (curAlign == layout_->align)
diff --git a/src/insets/InsetVSpace.cpp b/src/insets/InsetVSpace.cpp
index c774e98..80fba4d 100644
--- a/src/insets/InsetVSpace.cpp
+++ b/src/insets/InsetVSpace.cpp
@@ -209,9 +209,15 @@ void InsetVSpace::draw(PainterInfo & pi, int x, int y) 
const
 }
 
 
-void InsetVSpace::latex(otexstream & os, OutputParams const &) const
+void InsetVSpace::latex(otexstream & os, OutputParams const & rp) const
 {
-       os << from_ascii(space_.asLatexCommand(buffer().params())) << '\n';
+       os << from_ascii(space_.asLatexCommand(buffer().params())) << breakln;
+       if (rp.need_noindent) {
+               // If the paragraph starts with a vspace and has more than that
+               // content, the \\noindent needs to come after that
+               // (as \\noindent leaves vmode).
+               os << "\\noindent" << termcmd;
+       }
 }
 
 
-- 
lyx-cvs mailing list
[email protected]
http://lists.lyx.org/mailman/listinfo/lyx-cvs

Reply via email to