Source code line endings in Writer

I have a paragraph style called “Source”. It has no spacing above and below, and it uses a mono-space font and gray background. I want to paste text with some longer lines into my document and it would be important to see in print where the “enters” (paragraph endings, option A) or the automatic line wrappings (option B) are, so the reader won’t get confused on it.

Is there any setting for A or B? Workarounds?

I don’t want to format anything by hand because it would be fragile and hard to maintain. Tried numbering and got a problematic use case: When reading the document on computer it makes hard to copy sources from the document, because the numbering gets copied too.

EDIT: Increasing the spacing between paragraphs is not good enough. Not obvious enough. Looks weird and consumes lot of space in the general case when there are no long lines.

(LibreOffice Writer 4.2.1.1 English; Windows 7 64bit English; Hungarian and English texts)

How about huge indents or smart background images? See the attached document. example.odt

Edit: sorry, now it should be the right one.

I think you inserted a wrong example. It is a table not a text document and there is no source code in there.

Of course the background image could be on the left as well, I just thought I might like it more on the right, but who knows.

Cannot upvote, at least 5 points is required. I will be back some day.

Glad it helped. You should be able to mark it as accepted answer. Also have some points :slight_smile:

A also asked this at SuperUser [1], and I had the reputation to set up a bounty there. There were good ideas.

  • Set a vertical border on the left and turn on “Merge with next paragraph” at “Borders” tab. So every logical row will have one vertical line on the left side. I consider this the best
  • Set “Befor text” to x cm and “First line” to -x cm.
  • Add space before and after the paragraph so if a line breaks it will be nearer to its beginning than the next line.
  • There was also an idea to use macro which I would not start learning just for this as it is not necessary now.

[1] http://superuser.com/questions/732159

  1. I don’t think this would work without space between paragraphs

  2. that would work, also included in my example

  3. this is reversed version of 2), but would not work at all with indented lines (nicely formatted code)

(1) True. A minimal margin is needed. But margins as final solution (3) is not good, because they are not obvious enough.