Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have tried to insert source code as listings in OpenOffice.org Writer, but it just doesn't work in an acceptable way.

If space is not enough for an line, it breaks that line automatically into the next one. Of course the reader of the documentation doesn't know what happened and gets confused. Some books insert an arrow-icon in this case, that shows that this belongs to the upper line. However, I couldn't find anything to do that. Although I could do it manually, that's not an option in an 500 pages documentation.

Are there any solutions or ways how to fix that problem? Maybe with an macro that works on an particular paragraph style, i.e. the "Source Code Listings Paragraph Style"?

I have found an Extension: Coooder, but this doesn't match the problem. It seems that it does only syntax highlighting, which is not really important in this case. Long lines and making the forced linebreak visible is the problem.

share|improve this question

migrated from stackoverflow.com Mar 10 '10 at 20:45

This question came from our site for professional and enthusiast programmers.

    
Maybe you will find help in the OOo user forums on how to apply a certain formatting to text in Writer? The URL is oooforum.org/forum/viewforum.phtml?f=2 –  0xA3 Apr 17 '09 at 12:16
    
see also superuser.com/questions/109419/… –  Ian Ringrose Jan 3 '12 at 11:01

4 Answers 4

Here is a way to do it visually. It shows a "notch" on lines that are continuations. I don't know a way to do a continuation character.

code list

In OpenOffice.org Writer:

Select the text of the listing

Table > Convert > Text to table

Separate text at > Paragraph

Table > Select table (keep the whole table selected for all the following steps)

Table > Table properties
    Text flow tab
        Allow row to break across pages and columns > Unchecked
    Borders tab
        Line arrangement > Default > Set no borders
    Background tab
        For > Table
        Background color > Gray 10%

Format paragraph
    Indents & spacing tab
        Indent > Before text > 0.25”
        Indent > First line -0.25”
        Spacing > Below paragraph > 0.1”
    Text flow tab
        Options > Do not split paragraph > Checked
    Background tab
        Background color > Gray 10%

Format > Character
        Background > White
share|improve this answer

Thanks! I tried to figure out if there is any other way of doing it without having lots of borders. Then I remembered good old html+css and thought about an background image that would start from the upper right and whoose size is exactly optimized to the text size. So I made a background image where the first line is empty, but the next ten lines show that desired linebreak-arrow. The trick is: I assigned that background image to my code-listing paragraph style with position upper right. Then, when I add code to my book, I just have to make sure that each line of code is exactly one paragraph with that style. So if it is just one line, the background image will not appear. If it is more then one line, it will repeat and look exactly the way I wanted it to. Although sometimes there is a linebreak arrow too much there, and the image looks a little bit washy since I resized the image a lot of times to match the text size. But it works. Las thing I did, was to add a an white border in the paragraph style, so that I could make a spacing on the right.

share|improve this answer

Another way could be something like this:

alt text

Using Paragraph Style - Borders, and defining the right border without "Merge with the next paragraph" and/or bottom-right shadow with Gray 10% color or similar (on the image Gray 30% is used). A smaller shadow would be less intruding.

share|improve this answer

@voyager - I liked your idea, but both yours and my original one are a little heavy looking. Here I've used a bottom border, instead of a side one and a shadow. I used red, but any color would work.

listing

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.