Working Around Template Limitations

LibreOffice Writer

By

If you are looking to change or combine templates in LibreOffice, there three workarounds can help you accomplish the task.

Technically, you cannot change or combine templates in LibreOffice Writer. However, you can use three different workarounds to do the equivalent: You can paste text into a new document, import styles from another document, or add a file to a Master Document. However, you do need to know the details of each workaround, and you should probably limit your use of any of them as much as possible, so that you can minimize problems.

At first, the fact that you cannot change templates in Writer might seem like a major inconvenience. In reality, though, the limitation is designed to reduce the possibility of corrupt files. From its earliest days, Writer’s use of templates was designed to avoid the problems that plagued Microsoft Word throughout most of its history. For decades, MS Word has used a default template called Normal.dot (in recent releases, Normal.dotm) that can be edited freely. In addition, it allowed the application of multiple templates to the same document. Both these policies produced chaos, especially when more than one user edited Normal.dot. Often, the only solution was to delete Normal.dot and restart MS Word so that a new default template could be created automatically -- and that meant losing much of the formatting. Intended from the start to be an alternative to Word, Writer is designed to avoid such problems.

If Word still allows the application of multiple templates to the same document, its documentation no longer mentions the fact. It does, however, still allow the editing of Normal.dotm, which continues to cause the corruption of documents.

By contrast, LibreOffice in general and Writer in particular takes a more cautious approach to templates. To start with, the default template for all documents is embedded in the code. From Tools | Options | LibreOffice Writer | Basic Fonts (Western), you can change the default fonts in this default template, but otherwise you can change little else about it. Other formatting defaults can be changed within a particular document, and that document can be saved as a template -- and even made to be the default template to use when starting a new document -- but none of its assigned settings affect the embedded default in any way. Should the assigned default become corrupt, you can delete it, and any documents that use it will use the embedded defaults the next time you open them.

Somewhat confusingly, Writer documents also have what is called a Default Style for paragraphs and character styles. However, these are the Default Styles for that particular document only. Should they become corrupt, you can press the Reset button in the Default Styles’ dialogs. The rest of Writer is unaffected, no matter what changes you make in these styles.

Going in the opposite direction, if you make changes to a template, the next time you open a document that uses the template, you are asked if you want to update the document with the revised changes. Most of the time, you probably do want to update, but if you have any suspicion, you can decline the update, permanently severing the document from the template. Alternatively, you can accept the update and then, if problems arise, close the document without saving it.

In other words, Writer carefully controls interactions between templates and documents so as to minimize disaster. Limiting how you can change formatting options is just another way that Writer saves users from potentially troublesome operations.

Paste Special

If a document consists mostly of text, the quickest way to change the formatting of text is to select Edit | Select All. Then place the cursor within a new document, and select Edit | Paste Special | Unformatted text. The copied text will be pasted into the new document using the formatting of the paragraph or character style in which it is placed (Figure 1).

Figure 1: Selecting Paste Special | Unformatted is a quick and reliable way to reformat text.

However, this technique has some serious limitations. To start with, if you select Edit | Paste, rather than Edit | Paste Special, then everything retains the original formatting, and you are no further ahead. You will still have to go over the document line by line. Conversely, selecting Unformatted text drops objects like images or tables, each of which will have to be copied and pasted separately. Because of these opposing problems, this solution is not practical for every document.

Loading Styles

Instead of creating a new document, you may want to try loading styles into the document you wish to reformat. This choice carries a possible risk of file corruption, but is organized so as to minimize the possibility.

To load styles, open Styles and Formatting by pressing F11 and select Load styles… from the drop-down list of styles in the top right of the sidebar deck. The Load Style dialog opens, from which you can select the document from which to borrow styles. On the left, the dialog displays the folders for categories of templates, and, on the right, the available styles in the currently selected folder. Alternatively, you can press the From File… button on the bottom left. To minimize any problems, you should also select what type of styles to upload: Text (paragraph and characters), Numbering, Frame, and Pages (Figure 2).

Figure 2: Loading styles can reformat a document easily, especially if both documents involved have the same names for all their styles.

You also have the option of whether to have the uploaded styles overwrite styles of the same name in the original document (the Overwrite checkbox). Deciding on whether to allow overwriting is an important consideration. On the one hand, if the two documents have both the same predefined and custom styles, reformatting becomes automatic. The next time you open the changed document, it will automatically update to use the uploaded format choices. On the other hand, the uploaded styles may not be suitable replacements for those with the same names, and overwriting may cause corruption. You might decide just to upload styles with unmatching names and then apply them as needed.

Piggybacking on a Master Document

Most users think of Master Documents as a technique for dividing large documents into smaller files. Several decades ago when LibreOffice’s ancestor was first released, that goal made sense, because computer resources were limited, which meant that large files could be slow to respond to commands. Nowadays, limited resources are not a problem, and I can personally testify that Writer can handle files of over 500 pages without problems. However, Master Documents are still useful as a way to let multiple users work at the same time on different parts of the complete document, and as a means to temporarily reformat a document.

If you are familiar with past versions of MS Word, the idea of trusting your work to a Master Document in any application may be alarming. Notoriously, MS Word Master Documents were widely said to be in one of two conditions: corrupted and about to be corrupted. When they became corrupted, you might lose all the individual files of which the Master Document consisted. But Writer Master Documents are more robust, and, while I have once or twice had one crash into uselessness, I have yet to have one affect its component files.

What makes Master Documents useful for reformatting is that they can have a separate template from their component files. When the component files are opened individually, they use their own formatting, but when opened from the Master Document, they use its formatting instead.

To make use of this workaround, start a new document using any template, and then select File | Send | Create Master Document. Then open the Master Document and, from the right-click menu, select Insert | File and select the file to reformat from the file manager and Update | All to apply the Master Document’s formatting to it. To save the file in the same format as the Master Document, select Edit from the right-click menu to open the component document in the regular editing window, from where you can save it under another name (Figure 3).

Figure 3: You can take advantage of the fact that Master Documents can have a different template from their component files in order to reformat.

Choosing a Method

In theory, these methods are listed in order from the safest to the least safe. While uploading styles and piggybacking on a Master Document are reasonably safe, they are more complex than Paste Special, so, theoretically, more can go wrong. In practice, they have always been safe for me, but, even so, you might want to backup the files used with them, just in case.

None of these three workarounds is particularly convenient. All of them may require some paragraph-by-paragraph tweaking to get acceptable results. Remember, though, that there are ways to get around restrictions that help to protect your data. They can all be laborious, but perhaps that is an acceptable price for having a stable office suite.

Related content

comments powered by Disqus
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters

Support Our Work

Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.

Learn More

News