Getting Your Book to Use the Template

Ok, so now we actually need to get your book to use our style template. Though you could apply the template to your current document, I would strongly recommend against this. It is much safer to start from scratch and copy and paste into a new document. The reason for this is simply that, though there shouldn’t be strange things going on in your document that, though not visible to the naked eye, trip up our export plugin, there often is. This is especially true if you’ve been working on your novel for years, during which time LibreOffice has gone through various changes, or if you started off in a different word processor and imported your book in or experimented with a different program during your writing. Admittedly it is true that there are ways to get rid of these invisible nasties, but as they aren’t visible, it is quite difficult to tell whether or not you have been successful. It is far far easier to start with a known quantity.

I would also suggest adding in an intermediate step and pasting your novel into a text editor, like gedit. This is so you can remove any strange formatting (tabs, double lines, extra spaces etc.) before pasting your text in, making it easier to apply our new styles to the correct parts the book. It also removes the risk of accidentally hitting “Paste” rather than “Paste Special->Unformatted Text” (which is easier than you might think when dealing with a document as long as a novel that is going to be pasted in multiple chunks), causing all the old formatting we are trying to get rid of to be copied into our shiny new document! So open up your master piece, hit Control-A and copy and paste it into gedit.

As gedit is text editor it can only contain text (not style information), so we know there are no nasty surprises hiding out of sight. Right, before we paste it into our new LibreOffice document, let’s clean it up a bit. What exactly you need to do will depend on how you’ve been formatting your book thus far. I’ll step through the three main things you need to deal with, and hopefully you can figure out the rest (nb. you can do all these things in LibreOffice, I just think it is easier to see if everything is working properly if you clean up the text first).

Getting Rid of Tabs at the Beginning of Paragraphs

Ok let’s start with an easy one, we need to get rid of all the tab stops at the beginning of the paragraphs, as our paragraph style indents the text for us. Click “Search->Replace…” This will bring up the Replace Dialogue. In the “Search for:” box enter “\t”. The backslash (note that it is a backslash “\” not a forwardslash “/”) tells gedit that we are searching for a special character and that character is t, which is short for tab. We want to leave the “Replace with:” box empty because we just want to delete the tabs (i.e replace them with nothing). Hit “Replace All”, and that’s it. This won’t just get rid of those tabs at the beginning of paragraphs but any others you’ve snuck in. So that’s all the tabs dealt with. Let’s move on to extra spaces.

Gedit's search and replace dialog
Gedit's Replace Dialog ready to delete all our tabs.

Getting Rid of Extra Spaces (with a little help from Regular Expressions)

It is important to get rid on any extra spaces you’ve accidentally added to your novel (or even any that you have intentionally added by e.g. hitting space a load of times to centre something rather than using centre alignment) as they can confuse the automatic spacing of your text, especially when using justified alignment.

There are two ways we could go about this. The simple way is to enter two spaces in the “Search for:” box (i.e. hit the spacebar twice) and one in the “Replace with:” box and just hit Replace All, but this won’t work if you have more than two spaces e.g. if you have three spaces in a row, the search will find the first two spaces, replace them with one space, move onto the next character, which is a space on its own, and leave it be. Of course you could just keep hitting “Replace All” until it has removed all your crazily long lines of spaces, two at a time. However, a neater way of doing things is to use regular expressions.

Regular expressions give you a very powerful (if somewhat complex) way of preforming complicated pattern matching and replacing. Anything you can think you’d like to do to a bit of text, regular expressions let you do it. We, though, are going to keep it simple. All we are going to do use them to tell gedit to replace “two or more spaces” with “a single space”. To do this all we need do is enter two spaces in the “Search For:” box followed by a “+”. The plus means “match as many of the preceding characters as possible” i.e. match a space followed by one or more spaces. Then put a single space in the “Replace with” box. Finally and most importantly, check the “Match as regular expression” box, and then click “Replace All”.

Whilst we are here, we will make sure you haven’t left any s paces trailing on the end of your paragraphs. To do this enter a full stop followed by a space followed by a plus sign followed by the newline character (\n), which gives us “. +\n”. And, importantly, delete the space in the “Replace with:” box (it is very easy to forget to delete it as you can’t see it’s there to remind you!) and enter “.\n”. Here we are saying, “find a full stop followed by any number of spaces and then a newline and replace them with a full stop and a newline”.

Of course, because we just replaced all the multiple spaces with single ones, there is no way we could have more than one spaces on the end of a line so we could have unchecked “Match as regular expression” and not used the + sign, but it is not a bad idea to get a bit of practice with regular expressions as, sooner or later, you will have some really complicated bit of search and replacing to do! (nb. Regular expressions give you lots of ways you could accomplish the same thing e.g. they have a special symbol that indicates the end of a line, which we could have used, and they also can stipulate that only certain bits of the search pattern are replaced so we didn’t have to delete the entire search pattern and then add back in the full stop and newline, we could just have deleted the spaces.)

Gedit's search and replace dialog.
Removing unwanted spaces. Though it’s hard to tell, there are two spaces before the + and one in the “Replace with:” Box.

Getting Rid of Extra Lines

Right, getting rid of extra lines is, sadly, slightly tricky. Though we can do it by replacing “\n\n+” with “\n”, we then have no way of distinguishing between paragraphs and sections (as we already got rid of the tabs)! So my suggestion here is just to leave them be and we’ll get rid of them in LibreOffice once we have assigned all the sections the “Novel-Paragraph-Section” style.

Ellipsis, Dashes and Hyphens

Whilst we are here we should also deal with any odd characters that you are using. The most common of these are ellipsis, dashes and hyphens but others exist. Ellipsis are the (three!) little dots you use to indicate someone is trailing off their speech (also, less commonly in fiction, that some quoted text is missing): “I have my passport somewhere…” It is common to enter these as three separate full stops, but they are actually just one single ellipsis character. The reason it is a good idea to change it over is because it affects both the spacing of words and where LibreOffice thinks would be a good place to put a line break. Just in case you have got a bit full stop happy anywhere, just to be on the safe side, we’ll replace any occurrences of three or more full stops with the ellipsis. We could do two or more if your sure you haven’t accidentally hit the full stop twice when ending a particularly exciting sentence. Anyway, let’s get to it enter “…+” in the “Search for:” box and “…” in the “Replace with:” one (you’ll need to turn regular expressions on if they aren’t already). That second symbol is an ellipsis character by the way. In order to enter it, you can either copy and paste it in from here or the Character Map or you can enter it directly by pressing Shift-Ctl-U at the same time and then typing 2026 (you don’t have to keep the other keys held down whilst typing the number) and then hitting return. If you are writing a lot (which you probably are!) you might want to set up your compose key so it is easier to enter awkward characters. A quick google will tell you how.

Inserting an ellipsis using Character Map.
Inserting an ellipsis using Character Map.

Once you’ve done that, the other thing you might want to check whilst you’re here is that you are using dashes and hyphens correctly. As a quick reminder, these are the three different punctuation marks we are talking about here:

em-dash: —
The longest of the dashes you are likely to use (the size of a “M” character) used mainly in fiction to show an interruption in speech: “I’m going to have a—” “No you are not.”
en-dash: –
A mid sized dash (the size of a “n” character). Used mainly in place of bracketing commas to show more emphasis: “I am sure my present – when I get it – will be lovely.”
hyphen: –
Smaller than our two dashes and the only one of three that you have a dedicated key for on your keyboard. It is used to join object-verbal compounds such as “man-eating shark”, and double barrel surnames e.g. “Mrs Horita-Smithe”. The hyphen is also used when a long word is being broken over two lines. LibreOffice’s justification is pretty good so you shouldn’t need to do this unless you are using very long words such as those found in science e.g. pseudopseudohypoparathyroidism. Clearly you don’t want to be hyphenating anything for this reason at the moment as we aren’t in LibreOffice, but if you had previously, delete them.

The best way to fix your dashes and hyphens is step through each one using the find function of the Search and Replace dialogue.

Ok, now we have nice clean book that is ready to copy into our new LibreOffice document (which is using our Novel Template).

Series Navigation<< Save the TemplateLet’s Get Pasting >>

Leave a Reply

Your email address will not be published. Required fields are marked *