One LibreOffice document for multiple uses

Share

© Lead Image © Oksana Kuzmina, 123RF.com

© Lead Image © Oksana Kuzmina, 123RF.com

Article from Issue 180/2015
Author(s):

With a little planning and a few LibreOffice tricks, you can create one document that contains text customized for various end users.

Writer provides several means to hide text. You can hide text with fields or a section or by selecting the Hidden box from the Font Effects for a character or paragraph style. But why, you might wonder, would anyone want to hide text? Perhaps as an Easter egg or as proof of authorship in work done for a client you don't trust? The most obvious reason is for single sourcing: the maintenance of several versions of a document within a single file.

Multiple versions of documents that differ only in some details are common in business or academia. For instance, you might have one version each of a software manual for users, system administrators, and programmers, or separate versions of a curriculum for more than one level of user. Similarly, you might have one version of an exam to be given to students and another version that shows the answers for instructors.

The only trouble is that maintaining multiple versions of a document is difficult. Placing each version in its own file complicates keeping all the versions in sync. Forget just once to update both, and information may be presented to the wrong reader or without important details.

In other word processors, single sourcing can create all sorts of problems. It requires you to create a duplicate copy, first, to avoid accidental overwriting. Then you need to delete all the parts not needed for the version you are printing, a process in which mistakes are all too easy.

By contrast, LibreOffice's solutions to single sourcing give you a wider range of actions. Using Track Changes is a minor improvement on single sourcing, while LibreOffice's various methods for hiding and revealing text allow you to customize a document version without any of the usual concerns. As with other uses of styles, using hidden text is faster than manual formatting and reduces the chances of making mistakes. It also eliminates the need to print from copies, which, with careless hands or tired brains, can lead to the accidental overwriting of the original file.

Using Track Changes

Edit | Track Changes is a tool for multiple writers editing the same document. However, with a little ingenuity, it can become a single sourcing tool.

To work with Track Changes, each writer must fill out at least the First (name) field at Tools | Options | LibreOffice | User Data. They can fill out other information, such as their phone numbers as needed. Filling out these fields is enough so that when you click Edit | Track Changes | Show Changes, each writer's contributions to the file displays in a different color. Track Changes underlines additions to the documents and crosses out deletions with a single line. A line in the left margin indicates changed sections at a glance.

Ordinarily, when a collaborative document is ready for publication, you would select Edit | Track Changes | Manage Changes and accept or reject all changes as the mouse moves from change to change, merging the different content into a single version. However, single sourcing with Track Changes is a different process from that for which the feature was designed.

To start, fill out the First name/last names/initials fields for a document version before you add content. When you are ready to enter content for another version, change the content of these fields. These changes take effect immediately; you do not need to restart LibreOffice. If you forget the name of the version, run the cursor over a passage. The mouseover shows the name associated with that text (Figure 1).

Figure 1: Mousing over text shows the target version.

When you are ready to produce a document version, open a copy of the document and click Edit | Track Changes | Manage Changes. The version name appears in the window under the Author column, and you can quickly delete passages from all other versions by filtering by Author in the Filter tab (Figure 2).

Figure 2: The Author column shows the versions created in the document.

Unselect Edit | Track Changes | Show Changes, and you are ready to print. Remember to unselect Show Changes; otherwise, you will print the Show Changes screen display, complete with multiple colors.

This method still requires some management, but, thanks to color coding, it greatly reduces the chances of selecting the wrong material. However, LibreOffice includes even easier single sourcing methods.

Choosing a Method for Hiding Text

Features for hiding and showing text can be used in two ways:

  • If two versions of the document share common text, enter one using ordinary paragraph styles and create unique paragraph styles for the other that can be hidden and shown as needed. This method works with both Styles and with Sections and Fields but can sometimes be difficult to organize.
  • Create a special set of paragraph styles for each version of the document, turning them on and off as needed. You might even have a special set of paragraph styles for material that is common to certain versions, but not others. This second method can be used by setting up multiple variables for fields (see below), one for each version, but is best suited for working with styles only.

No matter how you work, single sourcing can be confusing, so choose the names of styles and fields to help you keep everything straight. You can even give each paragraph style a different color to make it easy to recognize. Each style's color can be replaced quickly by using Edit | Find & Replace. If you are printing in black and white and use dark enough colors, you might not even need to change the colors when you print.

To hide or reveal text, press F11 to open the Styles and Formatting window, and toggle off or on the Hidden box on a style's Font Effects tab for a character or paragraph style (Figure 3). You can either choose part of the document to hide to produce an alternative version or to create a different set of paragraph styles for each version of the document.

Figure 3: The Hidden option in the Paragraph Style dialog.

Whatever method you choose:

  1. Create one set of character and paragraph styles for text that appears in all versions of the document.
  2. Create the common styles needed for each version of the text. For example, in a student quiz with an answer key, you might have one set of styles with names like User-Text Body and Teacher-Text Body. These styles are formatted exactly the same as the common styles, except when you select or unselect Hidden before printing.
  3. On the Format | Character | Font Effects tab, toggle Hidden on or off as needed before printing. Notice that spacing above or below a paragraph is hidden along with the text. By contrast, you need to select the space after a string of hidden characters.
  4. After you print a version from a single-source file, uncheck the Hidden box so you can see the complete file the next time you open it.

Hiding Text Using Fields

An alternative but more time-consuming way of single sourcing is to place each passage in its own field. You can either toggle one version of the document on or off or create a separate variable with a unique value for each version of the document. Usually, this second method is practical only for relatively short documents.

The Functions tab of the Fields dialog, reached by clicking Insert | Fields | More Fields (or Other in some versions of LibreOffice Writer) contains several tools that assist with single sourcing (Figure 4): Hidden text, Hidden Paragraph, and Conditional text. Other types of fields exist, but except for Set variable under the Variables tab, they are not relevant to single sourcing.

Figure 4: The Functions tab contains several fields for hiding text. Here, a Hidden text field is ready to be set up for use.

The Hidden option in the Font Effects of a character or paragraph style is the stylistic equivalent of some of the field types under the Functions tab of Figure 4, such as Hidden text and Hidden Paragraph. However, make sure that View | Field Shadings and View | Hidden Paragraphs are turned on when you use these fields; otherwise, you will be lucky to find the hidden text or paragraphs.

The fields used for single sourcing are in an off (0) or on (1) condition (i.e., a simple Boolean statement) for hiding and unhiding. A Condition is merely a state of a document or, if you prefer, a version with different content.

For instance, when Condition is set to 0, then the content in the fields is hidden, creating one version of the file. When Condition is set to 1 (or any other number), then the content is shown, creating a second version. For convenience, the condition that turns one version of a document on could be the name of the version, such as User Guide. This arrangement is no different from checking or unchecking the Hidden box in a style.

Alternatively, in a Conditional text field, a simple expression is set up using the Condition, Then, and Else fields on the right side of the window (Figure 5). For instance, if the condition is 1, then the text that appears in the document is whatever is entered in the Then field, such as User's Guide. However, change the condition to anything else, and the text in the document becomes whatever is entered in the Else field, such as System Administrator's Guide.

Figure 5: When you have two versions of a document, a conditional field is an option.

This arrangement is almost as handy as the Hidden box in a style. The main disadvantage of this method is that each condition needs to be changed separately, whereas using the Hidden font effect means toggling a single box.

Buy this article as PDF

Express-Checkout as PDF
Price $2.95
(incl. VAT)

Buy Linux Magazine

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

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