Many times, I find that I need to create a document that includes either code or output from a command-line. I haven’t found that either LibreOffice or Microsoft Word provide good styling to make that code or output look nice in a technical document. Below is how I created some Paragraph styles in both programs to display the code. I would love feed back on how I can improve the look. Please Comment Below.
Code Style in LibreOffice
Here is what the style looks like in LibreOffice:
To build the style, I opened the “Styles and Formatting” pane and created a new style:
On the “Organizer” tab, I just set the name of the new style to “Code”:
Next, I set the font properties on the “Font” tab:
- Family: Courier New
- Size: 9pt
On the “Indents & Spacing” tab, I set:
- Before text: 0.20″
- Above paragraph: 0.11″
- Below paragraph: 0.11″
- Checked “Don’t add space between paragraphs of the same style”
- Line Spacing: Single
On the “Borders” tab, I added the line on the left:
- Line Style: Dashed
- Width: 0.50 pt
- Color: Blue
- Spacing to Contents — Left: 0.12″
- Clicked the left border on the “User-defined”
On the “Area” tab, I set the background color to “Blue Classic”:
My biggest complaint about the style in LibreOffice is that the area doesn’t hug the text enough. I would like the background color to separate from the border line on the left. Also, I don’t like the way the background color runs right up to the paragraph before it. Microsoft Office handles that part much nicer unless I missed some settings that would have allowed me to fix it.
Code Style in Microsoft Word
Here’s what my style looks like on a Word document.
So, I created a new style called “Code” just like on LibreOffice. Instead of different tabs on the dialog, the settings are under the “Format” buttom on the bottom.
Here are all of the different settings summarized:
Font: Courier New, 9 pt, Indent:
Left: 0.2″
Line spacing: single, Space
Before: 8 pt, Don’t add space between paragraphs of the same style, Border:
Left: (Dotted, Accent 1, 0.5 pt Line width, From text: 12 pt Border spacing: )
Pattern: Clear (Accent 1), Style: Show in the Styles gallery
Based on: Normal
Here’s what I changed:
- Font: Courier New
- Font Size: 9pt
Under Format > Paragraph, I changed:
- Left Indentation: 0.2″
- Spacing Before: 8pt
- Don’t add space between paragraphs of the same style: Yes
Under Format > Border, I changed:
- Style: dotted (second option)
- Color: blue
- Width: 1/2 pt
- Clicked on the left side to set the left border only
Under options, I set:
- Left: 12 pt
- Right: 4 pt
On the shading tab, I set the Fill to light blue:
“Jethro” Suggestions
It would be really nice if these styles could be exported to file. Then, I could put them out here, and you could download them and use them without having to go through all of the settings.
Also, I wish I could get the LibreOffice version to look a little more like the Word version.
Please comment on any suggestions that you have to make it look better. What do you do in your documents?