I'm a new user of LyX, and reading the tutorial I found that I can't add freely spaces and empty lines to the LaTeX code, since it's about formatting the text, and it's done by the compiler.

I can really understand the philosophy, and that's why I decided to use that tool; what I find hard to understand, is why I can't use spaces and empty lines to improve the readability of the code itself, and maybe let the compiler ignore them. Or maybe there is a "dummy" marker, that allows to insert a space in the code ignored by the compiler?

Follow up: I eventually switched to LaTeX right after that document and sticked to it.

  • I'm not sure if I understand. I would have thought that adding whitespace and adding multiple lines to separate paragraphs should be allowed. Can you provide a small example (the entire source)?
    – user10274
    Jan 8 '12 at 15:08
  • 1
    As Lyx aims to show you the output, not the input, I'm not quite sure how this might work. In 'raw' LaTeX there is no issue with adding additional lines to help with readability.
    – Joseph Wright
    Jan 8 '12 at 15:12
  • 4
    Lyx is not really a LaTeX IDE so much as a system which uses LaTeX 'behind the scenes'. If you are interested in working directly with LaTeX, take a look at tex.stackexchange.com/questions/339/latex-editors-ides
    – Joseph Wright
    Jan 8 '12 at 16:03

Since LyX is attempting to show something that represents the output and not the raw LaTeX input, there isn't a way (that I'm aware of) to put extra spaces in the editor since that would imply having them in the output.

One thing you can do as a "dummy marker" is to insert an "ERT" box (Ctrl+L or Alt+I+X) on the line you want to preserve as empty. The ERT box is copied verbatim into the LaTeX source, so if you leave it empty, it will have no effect on the final document.

Alternatively, you could set the document to use vertical space to separate paragraphs rather than indents (Document > Settings > Text layout). Note that this will change your output as well as the LyX representation, but it's easy to change back when you're ready to export your finished document.

  • +1 Good idea! (Sorry, I didn't notice that your answer appeared while I was typing mine, which basically describes the same idea.)
    – Daniel
    Jan 8 '12 at 16:28
  • I think that this is basically what i was looking for, but at the same moment seems that it's against what LyX is conceived for, so thank you for the answer, but i'll try to avoid the need of extra spaces :)
    – clabacchio
    Jan 8 '12 at 17:33

You can do what you want by adding the following to Document > Settings > Local Layout

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
    KeepEmpty             true
    FreeSpacing           true
        div.standard {
            margin-bottom: 2ex;

KeepEmpty allows for multiple returns and FreeSpacing allows for multiple spaces. If you decide you want to make this change permanent, either create a layout and put it in your LyX user directory's layout folder or if you want it on a per-document basis, create a module.

All of this information and much more is in Help > Customization

  • Works perfectly for me and unlike the other answers, this actually answers the original question. Nov 24 '17 at 1:25
  • I regret my previous comment. After using it, for some reason the output was affected seriously. The long paragraphs didn't stick to the page margin and continued even further to the right edge of the page. Nov 24 '17 at 2:36
  • I regret again. Just remove the line "FreeSpacing true" and the output will be unaffected, while allowing several newlines to be inserted in the LyX editor. Nov 24 '17 at 2:48
  • A fantastic solution! With the default setup one has to always work at the bottom of the screen when the text reaches there. With this, one can add blank lines and work in the middle of the screen, without affecting the output! Truely fantastic! Removing the line "FreeSpacing true" by @Carlos Pinzón is necessary.
    – Glenn
    May 26 '20 at 17:04
  • 1
    @scottkosty Thanks a lot! That is more convenient for that purpose! But your solution allows more! When editing the text, one typically has to go back and forth, adding something a bit here and there. And when doing that, one may want to push the text below the current working area further down, so much better concentration! And thanks a lot again, because I just found that I should explore Lyx better.
    – Glenn
    May 26 '20 at 17:36

this doesn't address LyX, which i'm nor really familiar with.

however, (la)tex interprets a blank line as a new paragraph. furthermore, paragraph breaks are not permitted within math, so will result in error messages.

you can simulate a blank line in your code by adding a line containing only a % sign at the beginning; this give a reasonable visual equivalent of a blank line.

(la)tex (except when explicitly set up in verbatim mode) interprets multiple spaces as a single space, so adding a few extra (keyed) spaces to provide a visual gap in the input is okay, and often a good idea, especially in strings of math, or to visually simulate column positioning in a table. beware, however, of wysiwyg input software that interprets multiple keyed spaces as indications that multiple spaces are wanted in output, and translates an "additional" keyed space to \ (backslash space) in the tex file; i don't know whether LyX does that, so you should check.

  • LyX doesn't accept at all more than one space or a newline; maybe adding commented lines, but i'm not sure if this is possible or not; maybe you can suggest a good IDE for newbies?
    – clabacchio
    Jan 8 '12 at 15:44
  • Maybe TexMaker is a good starter?
    – vaettchen
    Jan 8 '12 at 16:00
  • 1
    @vaettchen: Yes, I've recently switched from TeXnicCenter (my first) to Texmaker and I can recommend both for beginners (comparison of these two). There are several questions on editors here, the one that Joseph linked to above, and more at {editors}.
    – doncherry
    Jan 8 '12 at 16:34

Ctrl + Return. That way is the easiest. For double space you may try Ctrl+ Space.

Hope it helps.

  • 4
    Welcome to TeX.SE. I believe that this answer does not address the issue. clabacchio wants to format the source code, not the document itself.
    – yo'
    Jan 11 '13 at 8:24

This is not directly possible, and also discouraged by the LyX WYSIWYM philosophy (What You See Is What You Mean), which attempts at show you a formatting that (structure-wise) resembles the output.

A possible workaround is to add an ERT box ("Evil Red Text"), which is LyX's built-in facility to escape to LaTeX (Insert -> Tex Code or Ctrl+L). In this box you can put empty lines that are, as you wrote, ignored by LaTeX if given between paragraphs. If you additionally set the "style" of the ERT inset to "Open" (Right Click -> Settings...), the LyX editor will not collapse the ERT box:

screen shot

  • For my own education, what makes this preferable to a LyX note?
    – vaettchen
    Jan 8 '12 at 17:28
  • @vaettchen: Nothing, really. It is more that I find LyX notes to be visually more significant, so they do disturb me a bit if used as "space holders" But in any case it is just a matter of taste.
    – Daniel
    Jan 8 '12 at 18:54

In the menu Tools->Preferences->Editing->Shortcuts assign a shortcut to the function newline-insert linebreak. This will give you an ability to insert linebreaks and arbitrary number of empty lines in lyx.

  • Hi, welcome. I don't think this actually answers the question. The OP wanted to add space in the source, not in the output. Feb 3 '19 at 22:01

In the menu, go to

-> Document | Settings | Text Layout | Line Spacing | Double

That should achieve what you want?

  • No, what i mean is the possibility to add empty lines in specific points of the code (f.e. between two sections) to make more easy to find parts of text while writing.
    – clabacchio
    Jan 8 '12 at 15:59
  • You could use bookmarks (menu: Navigate | Bookmarks ). You also can Insert | Note | LyX Note anywhere in the text and also between paragraphs.
    – vaettchen
    Jan 8 '12 at 16:07

In LyX, which I am using, there is a dropdown menu you can use. Insert->formatting->Vertical Space. This provides your printout with extra room, for readability of your product. Does that help?

  • 1
    Welcome to TeX.SX! Please check the question again. I think it is about inserting space in the source code of the document which does not go into the printout. Jan 1 '14 at 7:47

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.