Ask Your Question
1

How do I create a frame for code? [closed]

asked 2013-11-07 21:57:57 +0100

Stefano Borini gravatar image

updated 2013-11-07 22:05:43 +0100

Good morning,

I am writing technical documentation and I am trying to create a grey area in my document which is dedicated to programming code, to distinguish it from the explanatory text. To give an example of the visual aspect, look at the editor's preview area here on libreoffice Q/A.

In my first attempt I created a paragraph style with a mono font and a gray background. Unfortunately, I found out that, since it's a paragraph style, at every Enter a new paragraph is started. This leads to a very strange situation when exporting to pdf. In the document, the grey area appears as smooth, but in the pdf, you can see the individual horizontal paragraph lines, separated by a thin white line.

So I went on to create a Frame style. This apparently works, but with a complication. I get automatic capitalization when I don't want it. Also, the frame is, of course, a frame, so it lives separated from the normal text flow, meaning that I have to click inside it to have the cursor enter the area for editing, and it does not wrap to the other page if it's too long to fit in.

is there a better way to achieve what I want?

edit retag flag offensive reopen merge delete

Closed for the following reason question is not relevant or outdated by Alex Kemp
close date 2015-11-13 06:01:04.878999

Comments

1

Answer below by @carnendil is largely correct. "This leads to a very strange situation when exporting to pdf. In the document, the grey area appears as smooth, but in the pdf, you can see the individual horizontal paragraph lines, separated by a thin white line." This is an on-screen artefact of the PDF viewing software i.e., as I indicate, zooming in does not enlarge these lines. Do the fine lines appear on a printed version?

oweng gravatar imageoweng ( 2013-11-10 03:06:18 +0100 )edit

1 Answer

Sort by » oldest newest most voted
1

answered 2013-11-07 22:46:19 +0100

carnendil gravatar image

updated 2013-11-07 22:47:57 +0100

When defining your paragraph style, apply a border with the same color of your background around the paragraph, but make sure you un-check "Combine with following paragraph" under "Properties" at the bottom of the dialog box.

You can play with the thickness of the line, as well as the spacing to text.

It seems to me that this works in removing the thin white lines. At least I couldn't detect them at 400% zoom on my PDF.

edit flag offensive delete link more

Comments

1

The fine lines visible with the "Combine with following paragraph" option selected (checked) disappear as the zoom level is increased and they do not print.

oweng gravatar imageoweng ( 2013-11-10 03:13:57 +0100 )edit
1

In fact, I didn't check printing. If it's just an artifact in the pdf reader, everything might be left as is. Being an issue related with the PDF software, rather than with the file, it is possible that other users of the same file will have a different experience when displaying the file on their screens, rendering the adjustments in my answer either unnecessary or useless.

carnendil gravatar imagecarnendil ( 2013-11-11 16:34:59 +0100 )edit

Question Tools

2 followers

Stats

Asked: 2013-11-07 21:57:57 +0100

Seen: 358 times

Last updated: Nov 07 '13