Problem solve Get help with specific problems with your technologies, process and projects.

Using styles in

Manual formatting without styles means time-consuming, repetitive changes to every document. An OpenOffice expert saves you time by explaining how to create sophisticated styles or modify styles already in use.

It's 4:00 PM on a Friday. Your car is packed for a fabulous ski weekend with your new honey, JJ. You're hitting the coffee machine one more time for energy on the drive up to Vail, when your boss catches up with you.

More OpenOffice tips:
Using the data pilot: Calc's answer to pivot tables

Exporting data from an Base database

"Chris!" she cries. "I'm so glad I found you. You know your 700-page report on dolphin languages that's being published in the Best Research Ever edition of the National Dolphin Journal? They rejected it because it's not in their format. And the deadline is Monday!"

What do you do?

A) Curse and tear your hair, and spend the weekend reformatting the report instead of hobnobbing with JJ. JJ goes alone, finds a hot new ski instructor and breaks up with you the next week.

B) Reject your lifelong goal of being published in the prestigious National Dolphin Journal, go skiing with JJ, but eventually find your life meaningless and turn to a life of crime. After you go to jail, JJ dumps you for Pat from Accounting.

C) Shrug, go back to your desk and reformat the document in a half hour, tops, by bringing in the style definitions from the National Dolphin Journal template. You and JJ have a great time skiing all weekend and eventually marry and become the new power couple in the dolphin science community.

Ideally, of course, you want the answer to be C). This article is all about how to make that happen.

A quickie style overview

My friend Kent used to say, "Unix is like chocolate sauce. Add it to anything and it's better." I'm going to tell him that the same is true of styles. They're great. And not too complicated, either. Styles are essentially just organized formatting. Create a style with all the formatting characteristics it should have and give it a name. Then just double-click to apply any style to text, a graphic or a page. Then to update anything that style is applied to, just change the style definition.

Five different kinds of styles cover everything you work with: lists, pages, graphics and other objects, paragraphs of text, and individual pieces of text.

Why styles rock and can keep you from a life of crime

To appreciate styles, ya gotta know what life is like without them.

Life without styles in the cold, hard world of manual formatting

With manual formatting, you apply the formatting attributes like bold and Times New Roman directly to the text, graphic or page. Every single piece of text or graphic or page has to carry around all that knowledge about how it's formatted.

Here's a conceptual illustration of manual formatting. You have to tell every item everything about what it is.

You don't just have to tell every item what it is, but you have to tell every item everything about what it is. If it has seven formatting characteristics, you need to tell every item all seven things. In a page, for instance, you need to specify that you want the margins to be .8 on the left and .5 on the right, with a header that has the title on the left side and the date on the far right side, a footer with the page in the center and dark gray borders around the edge, .08 inches from the text.

Add to that the issue that page styles are the only way to combine different page layouts in the same document, and you have even more reason to use styles.

Seems exhausting, isn't it? You have to tell every chunk of text every single piece of formatting that you want to apply to it, every single time. Well—all right, not every single time. There is the Paintbrush icon. And you can multi-select nonconsecutive pieces of text; select the first chunk, then hold down Ctrl and select the next, and so on. But you're still working harder than you need to.)

Then when things change, as they always do, you need to go around to every piece of text, yet again, and tell it how to change. If three of the five formatting attributes change, for instance, that's a lot of work. Especially with a 700-page dolphin report.

Life with styles

With styles, you group all those formatting attributes, like bold and Times New Roman, into a style. Give it a good, clear name.

Then you apply the style to the text. This can take a while, but not as long as it takes to apply the formatting.

Then when things change, as they always do, the only thing you need to change is the definition of the style. The text knows what style it is, so it just does whatever the style tells it to do.

Using styles

Let's say you're convinced. Or at least curious. You want to have your weekends free, at least. What's the best way to use styles?

Well, the first step is to just apply them. The simplest thing to do is just use the existing styles. For paragraph styles, Heading1 through Heading10 are nice, so is TextBody. For character styles, Emphasis or Strong Emphasis can be good. With Frame you'll generally need to create your own, but in page styles you've got First Page, Left Page and Right Page. And the pre-existing list styles are all pretty useful.

Note: One issue with these styles that come with is that they can't be renamed. See Importing someone else's template for info on why this might not be an advantage.

Applying styles

1. Choose Format > Styles and Formatting. You'll see the Styles and Formatting window, your new best friend.

2. Click the correct icon for the style category you want. This is important and easy to forget.

3. If you don't see the styles you want, from the dropdown list at the bottom, select All.

4. Find the style you want. Select the item you want to apply it do. Double-click the style. The style is applied.

Using existing styles and tweaking them

Now that you've applied the styles, however, you're not perfectly happy with how they look. Or perhaps a prestigious journal that you want to get published in has different definitions for those style names. Here's how to modify them the way to work the way you want.

1. Choose Format > Styles and Formatting. You'll see the Styles and Formatting window, your new best friend.

2. Click the correct icon for the style category you want.

3. If you don't see the styles you want, from the dropdown list at the bottom select All.

4. Find the style to modify, then right-click and choose Modify.

5. In the window that appears, just change the settings and click OK.

6. All the items that have that style will now be updated to look the way you want them to.

Creating new styles from scratch

If you want to truly inflict your formatting will on a document, you'll eventually need to create your own styles.

1. Choose Format > Styles and Formatting. You'll see the Styles and Formatting window, your new best friend.

2. Click the correct icon for the style category you want.

3. If you don't see the styles you want, from the dropdown list at the bottom select All.

4. Right-click in a blank spot and select New.

5. In the window that appears, name the style, then click each tab necessary and apply settings. Click OK.

6. Now apply the style to the appropriate items.

Note: Instead of steps 4-6, you can format the text the way you want with normal manual formatting, then click and hold down on the far-right icon and choose New Style From Selection. Name it in the window that appears and click OK.

Sophisticated style usage

Here are just a few tips to round out your style usage—including the dolphin example in the beginning.

Transferring styles from one document to another

Styles stay in the document where you created them. This is good, because otherwise you could have random style collisions and you'd have about a half a bazillion styles in every document.

But that also means that if you want the styles from dolphins_languages.odt to be in your new document, dolphin_parties.odt, you need to transfer them somehow. Here's how.

1. Open the document where you want the styles to be.

2. Choose Format > Styles and Formatting.

3. In the window that appears, click and hold down on the far-right icon and choose Load Styles.

4. Mark all the checkboxes (unless you only want to load particular categories of styles) and click Find File.

5. Select the file containing the styles.

6. There you go—the styles are now in the new document.

Creating a template of your favorite styles

The best favor you can do for yourself is to create a template of your styles and use that template, when appropriate, to start a new document. If you have a type of document that you create frequently, like a chapter of a book, a memo for the library, or a report for the National Dolphin Journal, get the styles how you want them, then preserve them in a template.

Do this.

1. Create the styles in a Writer document and make sure they're right. Include any canned text or graphics you want.

2. In that document, choose File > Templates > Save.

3. Select a category and a name. Click OK.

4. Choose File > New > Templates and Documents. Click the Templates icon, then find the right category. Double-click the template you made and you'll get yourself a fresh new untitled document with all those styles.

Importing someone else's template

Let's revisit the National Dolphin Journal issue. You've got your own set of styles that you used, perhaps PulitzerWinningArticleHeading1, PulitzerWinningArticleBodyText, and so on. And now you need to use the dolphin journal's template full of styles instead. I gave the impression that you could just import the styles and whammo, you're done.

You can....kind of.

If you created your own styles with your own style names like PulitzerWinningArticleHeading1, then it is pretty much whammo. You need to do a preliminary step but after that it's whammo.

If you used the preexisting styles included in like Heading1....well, then you just need to go through your document and apply the dolphin journal styles one by one. This is faster, at least, than applying the formatting manually without styles. So it would take maybe two hours, tops, for a 700-page document. (You could still make the ski trip; JJ would just have to call the condo and tell them you'll be checking in late.)

Let's go back to the scenario in which you created your own styles like PulitzerWinningArticleHeading1. What's that mysterious preliminary step I alluded to? Why, it's renaming the styles. Here's something very cool. Let's say you've got 42 paragraphs with the style ReportTextBody applied. If you rename ReportTextBody as ReportContent, then automagically all 42 paragraphs now have the style ReportContent.

This means that if you've got your styles, all you need to do is rename them appropriately. Then import the new styles and your styles will take on the formatting of the new styles. And whammo, you're done with formatting and you can take off for the weekend.

You figure out what your styles are, and the corresponding new style in the template you need to apply to your document. Something like this.

Your style name The style name in the template to import
PulitzerWinningArticleHeading1 Head1
PulitzerWinningArticleBodyText BodyContent
PulitzerWinningArticleList MainList
PulitzerWinningArticleTableHeading TableHead

Then you just rename all the styles on the left, giving them the name on the right.

1. Choose Format > Styles and Formatting.

2. In the window that appears, click the correct icon at the top to see paragraph styles, list styles, etc.

3. Right-click on the style name to rename and choose Modify.

4. In the window that appears, click the Organizer tab and give it the new name from the right-hand side of the table.

5. Click OK.

Now import styles, and whammo, you're done.

Living the stylin' life

It's easy to bypass styles when you're in a hurry since they require a little planning and can be unfamiliar at first. But honestly, I don't do anything complex, where the formatting matters, without styles. (I admit I'm not that good at deleting them—my books still have the NoBrainer note icon that my co-author Floyd created in 1999.)

But they're great, and not just for the reasons I mentioned. Here's just some of the stuff you get practically, if not totally, for free, if you properly apply styles.

  • Automatic tables of contents
  • A huge amount of control over numbering formatting
  • Easier lists (see my article on lists here [link to lists article])
  • Running headers and footers
  • Dynamic cross-references
  • Conditional formatting (in Calc)

So give yourself the gift of efficiency and time this holiday season. And afterwards, reward yourself with some chocolate sauce.

Solveig Haugland has worked as an instructor, course developer, author and technical writer in the high-tech industry for 15 years, for employers including Microsoft Great Plains, Sun Microsystems,and BEA. Currently, Solveig is a StarOffice and instructor, author, and freelance technical writer. She is also co-author, with Floyd Jones, of three books: Staroffice 5.2 Companion, Staroffice 6.0 Office Suite Companion and OpenOffice.Org 1.0 Resource Kit, published by Prentice Hall PTR. Her fourth book, on 2.0, is coming this summer. For more tips on working in OpenOffice, visit Solveig's OpenOffice blog.

Did you find this tip useful? Email us and let us know.

Dig Deeper on Linux servers

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.