When i define a new Style in a LyX Layout, in the LaTeX output there is always two newlines after the LyX paragraph.

I can remove the vertical spacing which is displayed inside the LyX editor (with TopSep, BottomSep and TopSep), but i'm unable to figure out how to avoid the \n\n in the LaTeX output which causes a paragraph spacing:

Style NoSpacingParagraph
    CopyStyle             Standard
    TopSep                0
    BottomSep             0
    ParSep                0

I've already tried a custom LatexName with a self-defined latex command - but the \n\n seems to be unavoidable.

Any ideas?


In LaTeX, the parskip following a paragraph can be removed by appending a negative vertical space with the length of a parskip (\vspace{-\parskip}) to the end of it. The negative spacing and the positive parskip then eliminate each other.

To incorporate this solution into a LyX paragraph style, i used the following:

Style NoSpacingParagraph
        CopyStyle             Standard
        LatexType             Command
        LatexName             noparskip
        TopSep                0.0
        ParSep                0.0
        BottomSep             0.0
        ParSkip               0.0

Now just select this new style for a paragraph and the parskip between it and the following paragraph disappears in the rendered output.

The answer is inspired by this question: Suppress parskip only AFTER a specific paragraph?

  • This is quite a poor answer for the following reasons: (1) Specifying a paragraph to have this NoSpacingParagraph style only defines a macro called \noparskip, but never uses it. You're still forced to insert \noparskip as an ERT, correct? That is, you never show it's proper usage. (2) Why does \noparskip take an argument? (3) You emphasize that the "following" paragraph will have a different \parskip... in that sense you're only referring to the \parskip at the top of some paragraph, not the bottom as well. – Werner May 6 '15 at 12:34
  • (4) Issuing \noparskip inside a paragraph technically implies you're issuing a "vertical command" inside "horizontal mode". As such it is stored until "vertical mode" is entered next. So you're issuing a command that doesn't have any meaning where it's used. – Werner May 6 '15 at 12:44
  • @Werner (1) This is what LatexType Command and LatexName noparskip are used for. The command is automatically applied to all paragraphs that are of style NoSpacingPragraph (2) see 1. the parameter is the content of the paragraph (3) the following paragraph will still have a normal parskip. formula: current paragraphs negative vspace + normal parskip = 0pt (4) the vertical skip is appended after paragraph before \n\n, which is the exact point where latex is entering vertical mode. – Kaii May 6 '15 at 12:49
  • @Werner maybe you should just try it out and look at the resulting latex code and the resulting rendered output. Also, take a look at this question where things might get more clear. It has more focus on the LaTeX details instead of the complexity LyX adds to the problem: tex.stackexchange.com/questions/242294/… – Kaii May 6 '15 at 12:50
  • Thanks for the explanation of LatexType and LatexName. – Werner May 6 '15 at 15:04

Once you have defined a validated local layout (Document > Settings... > Local Layout) it adds this as an option to the formatting dropdown/toolbar:

enter image description here

Seeing as you're using a "copy" of the Standard style to create NoSpacingParagraph, you still need to select the paragraphs which should be set using NoSpacingParagraph. Alternatively, you need to change Standard directly as a local layout (overriding it).

Here is the Standard style (taken from stdclass.inc):

Style Standard
    Category              MainText
    Margin                Static
    LatexType             Paragraph
    LatexName             dummy
    ParIndent             MM
    ParSkip               0.4
    Align                 Block
    AlignPossible         Block, Left, Right, Center
    LabelType             No_Label
    # FIXME This ought to be set dynamically.
        div.standard {
            margin-bottom: 2ex;

Secondly, the LaTeX output has a paragraph gap/skip defined by the variable \parskip. If you have a large \parskip defined somewhere, this may be the cause. It could also be easily overwritten by adding

\AtBeginDocument{\setlength{\parskip}{<your choice>}}

to your Document > Settings... > LaTeX Preamble.

  • @Kaii: You didn't mention that you want it removed for a specific paragraph. Next time, be specific in terms of your question. – Werner May 6 '15 at 12:30
  • @Kaii: Adding a single style doesn't mean it pertains to a single paragraph, since documents typically contain multiple paragraphs in general. – Werner May 6 '15 at 12:37
  • FWIW: i wrote that i wanted to create a specific style, which may apply to one or many (but not all) paragraphs inside the document. I never meant to apply it to a single paragraph, and never meant to apply it globally. What should be rephrased in my question exactly? – Kaii Jul 27 '16 at 11:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.