Difference between revisions of "Documentation/OOoAuthors User Manual/Writer Guide/Introduction to Styles"

From Apache OpenOffice Wiki
Jump to: navigation, search
(Modifying paragraph styles)
(Indent Heading 3)
Line 101: Line 101:
 
The result should resemble Figure 9.
 
The result should resemble Figure 9.
  
inline:Frame11.png
+
: inline:Frame11.png
  
 
== Linked styles ==
 
== Linked styles ==

Revision as of 06:27, 14 July 2007

Template:NeedsWork This page was created by converting ODT to Mediawiki using Writer2MediaWiki.

This is Chapter 6 of the OpenOffice.org 2.x Writer Guide (Third edition), produced by the OOoAuthors group. A PDF of this chapter is available from the OOoAuthors Guides page at OpenOffice.org.

<< User Manuals page
<< Writer Guide Table of Contents
<< Chapter 5 Printing, Faxing, Exporting, and Emailing   |    Chapter 7 Working with Styles >>


Introduction

What are styles?

Most people are used to writing documents according to physical attributes. For example, you might specify the font family, font size and weight (say, Helvetica 12pt, bold).

Styles are logical attributes. We use styles every day. For example, there are two styles of computers: desktop and laptop. Each has its own distinctive set of properties. You never say “my computer is a low-weight, one-piece unit with an LCD screen attached to a rectangular casing containing the computing components and the keyboard". Instead, you say “I have a laptop".

OpenOffice.org styles are a way to do the same thing for your document. Using styles means that you stop saying “font size 14pt, Times New Roman, bold, centered", and you start saying “title". In other words, styles means that you shift the emphasis from what the text looks like, to what the text is.

Why use styles?

OpenOffice.org (OOo) brings a powerful notion of styles. Styles help improve consistency in a document. They also make major formatting changes easy. For example, you may decide to change the indentation of all paragraphs or change the font of all titles. For a long document, this simple task can be prohibitive. Styles make the task easy.

inline:Frame2.png

Types of styles

OpenOffice.org Writer has five types of styles:

  • Paragraph styles affect an entire paragraph.
  • Character styles affect a block of text inside a paragraph.
  • Page styles affect page formatting (page size, margin, and the like).
  • Frame styles affect frames and graphics.
  • List styles affect numbered lists and bulleted lists.

The first three styles are the most used. Those are the styles covered in this chapter. Frame styles and list styles are discussed in Chapter 7 (Working with Styles).

These styles are available through a floating window called Styles and Formatting, shown in Figure 1. (Press F11 to see it.) The Styles and Formatting window is discussed in the next section.

inline:Frame28.png
Note Styles and Formatting is a floating window. You can drag it around the screen using the mouse, or you can dock it to the left or right side of the screen.

Using paragraph styles

First steps

OpenOffice.org uses a tool called Styles and Formatting to manage styles. The concept of styles and the Styles and Formatting window is best explained through an example.

  1. Create a new document (choose File > New > Text Document or press Control+N).
  2. Type Heading 1 in it. Make sure that the cursor remains in that same line.
  3. Click the Styles and Formatting icon inline:Graphic1.png located on the Formatting Bar or press the F11 key. This opens the Styles and Formatting window (Figure 2).
  4. Make sure the window is showing the Paragraph Styles section (click on the top-left icon of the Styles and Formatting window inline:Graphic12.png ).
inline:Frame43.png

Double-click the Heading 1 entry of Styles and Formatting. This will do two things:

  • Give the line you typed the Heading 1 style.
  • Add Heading 1 to the Apply Style menu.

The Apply Style menu is illustrated in Figure 3. It provides direct access to the styles that are currently in use in the document.

Using the Apply Style menu

The Apply Style menu lists the paragraph styles that are currently in use in the document. You can select styles from this menu, just like with the Styles and Formatting window. As an exercise, press Enter, type some text and select Heading 1 in the Apply Styles list. The text acquires the properties of the Heading 1 style.

inline:Frame5.png

Modifying paragraph styles

The power of styles lies in the ability to modify them to suit your needs. For the next example, we will need three lines of text with three OOo-supplied paragraph styles: Heading 1, Heading 2, and Heading 3. These paragraph styles could be used in formating headings in the framework for a document that will be "fleshed out" afterwards. Your document should resemble Figure 4.

inline:Frame1.png

Open a new text document for this exercise and type Title on the first line, click the Paragraph Styles icon on the Styles and Formatting window, and double-click Heading 1 in the drop-down list. Repeat this procedure for the other entries, using the proper paragraph style for each. The Heading 1 style should be applied to the "paragraph" containing the word "Title", Heading 2 to "Subtitle 1", and so on.

Note: Heading 1 uses a bold font typeface, Heading 2 uses a 14pt bold italic typeface, and Heading 3 uses a 14pt bold typeface.

Suppose you decide to make some changes to these styles:

  • Heading 1 should be centered.
  • Heading 3 should be indented.

Center Heading 1

On the Styles and Formatting window, select the Paragraph Styles icon (if it isn't already chosen), right-click on Heading 1, and choose Modify (as shown in Figure 5).

inline:Frame3.png

When the Paragraph Style window opens, choose the Alignment tab, select Center (as shown in Figure 6), and click OK.

inline:Frame6.png

Now, everything marked as Heading 1 will be centered (as shown in Figure 7). If you make another Heading 1 entry, it will be centered as well.

inline:Frame20.png

Indent Heading 3

On the Styles and Formatting window, right-click on the Heading 3 paragraph style and choose Modify (as before). When the Paragraph Style window opens, follow the steps below:

  1. Click the Indents & Spacing tab.
  2. Under the Indent section, set the indentation before the text to 1.50cm (0.6 in), as shown in Figure 8.
inline:Frame44.png

The result should resemble Figure 9.

inline:Frame11.png

Linked styles

Some OpenOffice.org styles are linked together. This means that a change in one style affects every style linked to to it. For example, every Heading style (such as Heading 1, Heading 2) is linked with a style called Heading. This relationship is illustrated in Figure 10.

inline:Frame12.png 

As an example, suppose you want to change the font of not only Heading 1, or Heading 2, but all headings. The easiest way to do that is to take advantage of this linking. Open the Styles and Formatting window (press F11) and select Heading (see Figure 11).

inline:Frame13.png

Open the Paragraph Style dialog box for the Heading style (right-click > Modify) and select the Font tab. Select a font and click OK (see Figure 12).

inline:Frame7.png

Now, the fonts of all the heading styles have been changed in a single operation. Your document should now resemble Figure 13.

inline:Frame15.png 

Creating custom styles

You have seen that the Styles and Formatting window provides several predefined styles, such as Heading 1 and Text body. But what if you need something different, like a poem style, that is not in Styles and Formatting? With OpenOffice.org you can make your own styles to suit your needs.

In this section, we will create a Poem paragraph style, and a PoemHeading paragraph style, with the following properties:

  • Poem: Centered, with font-size 10.
  • PoemHeading: Centered, bold, with font-size 12.

In addition, a PoemHeading is to be followed by a Poem. In other words, when you press Enter, the style changes to Poem.

Note The keen reader may have noticed this behavior already. After you type a heading and press Enter, the style switches back to Text body.

Creating the Poem paragraph style

Our first example is the Poem style. We use the Default style as a starting point.

  1. Click the Styles and Formatting icon inline:Graphic16.png or press F11.
  2. Click the Paragraph Styles icon (first from the left).
  3. Right-click Default and choose New (see Figure 14).
inline:Frame16.png 

This opens the Paragraph Style dialog box, with the Organizer tab selected. To create a custom style, you have to understand and configure the top three entries.

Style fields Description
Name This is the name of the style itself, like Heading 1 or Text body.
Set (type in the text box) the name to Poem.
Next Style This is the default style that follows the Poem style. When you press Enter while typing text in the Poem style, this style is used.
Set this value to Poem. When you press Enter, the text will remain in the Poem style.
Linked with If the Poem style is linked with another, say Default, then any change in Default will affect Poem, just as you saw with Heading in the previous section.
For our example, this is not the behavior we want. Set this entry to
- None -. This means that Poem is not linked with any other style.

After making these changes, your screen should look like Figure 15.

inline:Frame18.png

The next step is to configure the alignment and font properties of this style.

  • On the Alignment page, select the Center option.
  • On the Font page, select 12pt font-size.

Click OK to save the new Poem style.

Congratulations! You just made your very own style.

Creating the PoemHeading style

Create a new PoemHeading style. Use the same procedure as before, with these changes:

  • Next style: Select Poem, not PoemHeading.
  • Linked with: Heading.

The window should look like Figure 16.

inline:Frame14.png

Now set the settings of the new style:

  1. On the Alignment page, select Center.
  2. On the Font page, choose Bold and size 14pt.

Click OK to save the new PoemHeading style.

Sample poem

It is a good idea to test out your new styles and see if you are happy with them. Your poem should look similar to the one in Figure 17.

inline:Frame21.png 

Changing the formatting of your styles

One of the main advantages of styles is that they allow the document formatting to be changed after the content has been written. For example, suppose you have written a 100-page book of poetry. Then you decide you don't like the way the poems look after all. Or, perhaps, your publisher doesn't like it.

To learn about reconfiguring styles, we will make the following changes:

  • The Poem style will be indented instead of centered.
  • Add a PoemAuthor style based on Poem, except it is bold and has more indentation.

Indent Poem and PoemHeading

First, set the Poem style to left alignment:

  1. In the Styles and Formatting window, select Poem, right-click and select Modify.
  2. On the Alignment page, select Left.

Set the indentation:

  1. Click the Indents & Spacing tab.
  2. Under Indent, set the indentation before the text to 5'''cm (or about 2in).

Done! Click OK, and you should see the text change. Do the same thing for PoemHeading.

Create PoemAuthor style

The purpose of this style is to set apart the name of the author from the rest of the poem. You already know how to create a new style. Follow the same procedure as before (starting from the Poem style). Use the following configuration:

  • Name: PoemAuthor
  • Next style: Default
  • Linked with: Poem

Now, configure PoemAuthor just like you configured Poem, with the following changes:

  • Font: Bold
  • On the Indents & Spacing page:
    • Under Indent, set the Before text field to 8.00'''''cm (3.2 in).
    • Under Spacing, set the spacing above the paragraph to 0.50cm (0.2 in). This creates an extra space between the poem and the name of the author.

Figure 18 shows how the Indents & Spacing page should look at this point. Click OK to save the style. Now set the author of the poem (in the example, Robert Frost) to the newly created PoemAuthor style, as described in “First steps" on page 3.

inline:Frame31.png

Final result

After all these changes, the poem should look similar to Figure 19.

inline:Frame17.png

Tips and tricks

You can make the Styles and Formatting window display only custom styles. Click on the menu at the bottom of the Styles and Formatting window and select Custom Styles. As shown in Figure 20, Styles and Formatting only displays Poem, PoemAuthor, and PoemHeading.

inline:Frame19.png

Using page styles

Page styles are to pages what paragraph styles are to paragraphs. Just as paragraph styles can define paragraph properties (font size, color, and others), page styles can define page properties (margins, page size, header and footers, and others). However, unlike paragraphs, which can have directly applied properties, pages only have a page style and no directly applied properties.

inline:Frame33.png

What page style does a page have?

The page style for the current page is displayed on the status bar (Figure 21).

inline:Frame32.png 

Modifying a page style

Open the Styles and Formatting window and click the Page Styles button inline:Graphic3.png .

inline:Frame9.png 

Right-click the currently active page style (Figure 22) and select Modify. The resulting window is shown in Figure 23.

inline:Frame22.png

Mirrored margins for facing pages

You can set up “mirrored" margins for facing pages within one page style. More complex differences between right and left pages may require separate page styles; these are discussed in Chapter 4 (Formatting Pages).

To set up “mirrored" facing pages, go to the Page tab of the Page Style dialog box (Figure 24). Choose Mirrored for Page layout in the Layout settings section and set the inner and outer margins in the Margins section.

inline:Frame27.png

The Next Style property

You have seen the Next Style property in the context of paragraph styles. This property is especially powerful in page styles.

Setting up a title page

Consider a common scenario: you want the document to have a title page that is different from the rest of the document:

  • It should not have a header or page number.
  • The left and right margins should be the same.

For the title page, we can use the First Page page style that comes with OOo, and for the rest of the document, we can use the Default page style.

Figure 25 shows the required flow of page styles. On the Organizer page of the Default page style, leave the Next Style property set to Default. On the Organizer page of the First Page style, make sure that the Next Style property is set to Default.

inline:Frame41.png

See “Inserting a header" on page 17 for instructions on setting up the page header.

Manual page breaks

The Next Style property is enough for projects with straightforward pagination requirements (for example, reports, letterheads, and small books). But more complex projects require more control over page styles. Manual page breaks provide this control.

The idea is simple: you break a sequence of page styles and start a new sequence. To insert a page break, choose Insert > Manual Break and choose Page break. This section illustrates two scenarios where page breaks are useful.

Example: Chapters

You are writing a book that is divided into chapters. Each chapter starts with a page style called New Chapter. The following pages use the Default page style. At the end of the chapter, we return to New Chapter for the next chapter.

OOo doesn't have a New Chapter style, so you must create a custom style (see page 7). Let's suppose that you already have the page styles with the following properties:

Page style Next Style
New Chapter Default
Default Default

This can be seen visually in the flowchart in Figure 25, but where the New Chapter style replaces the First Page style.

At some point, you will want to start a new chapter. Follow these steps:

  1. Put the cursor at the end of the chapter, on a blank line of its own.
  2. Choose Insert > Manual Break. The Insert Break dialog box appears.
  3. Under Type, choose Page break and under Style, select New Chapter.
inline:Frame36.png

Figure 27 illustrates the flow of page styles when using page breaks.

inline:Frame37.png

Example: Inserting a page with special formatting

Sometimes you may need to insert a page with special formatting. For example, a landscape page or a page with more columns. This can also be done with page breaks. Suppose that the current page has the Default page style.

  1. Choose Insert > Manual Break.
  2. Select the page style (say, Special Page) in the Insert Break dialog box.
  3. Fill in the contents for this page. Then insert another page break.
  4. Then select Default again. The pagination continues on as normal, except that one page has been replaced by a different page style.

This concept is illustrated in Figure 28.

inline:Frame38.png

Page numbering

Many people first encounter page styles when they want to number pages. OpenOffice.org has a powerful system for numbering pages.

Preliminaries: fields

OpenOffice.org uses a feature called fields to manage page numbers. To insert a page number field, position the cursor where you want to insert the number and choose Insert > Fields > Page Number. The page number appears with a gray background. The gray background denotes a field.

Note The gray background is simply there to denote a field. This background is not printed. Choose View > Field Shadings (or press Ctrl+F8) to turn this feature off.

If you have seen lists in OOo, you might have noticed this gray background. OOo lists use fields. The page number field always displays the page number for the current page. If you see the words “Page number" instead of a number, press Ctrl+F9. This shortcut key toggles OOo between displaying the field's contents (what the field is for) and the field's results (what the field creates).

Note For a full introduction to fields, see Chapter 14 (Working with Fields).

Inserting a header

In OOo, headers are specified by page styles.

  1. Open the Page Style dialog box for the desired page style (right-click > Modify).
  2. Select the Header tab.
  3. Under Header, check Header on and click OK (see Figure 29).
inline:Frame24.png 

At this point you should see the (empty) header on the current page, as in Figure 30.

inline:Frame25.png 

What's so special about headers? The same text in the header appears on all pages with that page style. (You can experience this yourself by entering some text into the header.) This property of headers (or footers), along with fields, forms the basis of OOo page numbering.

Tip You can also add a header through the Insert menu: Insert > Header > '[page style]'. Likewise, for footers: Insert > Footer > '[page' style].
Caution
inline:graphics1.png
The Insert Menu can also be used for deleting a preexisting header or footer for a page style. If that page style has a check mark in front of it, pointing to it will open an OOo dialog box warning about this and asking whether you want to delete the header or footer for that particular page style.

Simple page numbering

The simplest case is to have the page number at the top of every page and nothing more. To do this, put the cursor on the header and select Insert > Fields > Page Number (Figure 31).

inline:Frame26.png 

Presto! Now, the correct page number appears on every page.

More complex variations

There are a lot of interesting variations that you can apply without further knowledge of page styles. Here are some suggestions:

  • Right-align the header to make the page number appear on the top-right:
  • Place the cursor in the header.
  • Click the Align Right icon (or right-click anywhere in the header and select Alignment > Right).
  • Add (type) the word page so the header reads page 1, page 2, and so on. This also requires using the Page Number field, discussed earlier (page 17).
  • Add the document title so the header reads, for example: Joe's favourite poems, left justified, and page x with right justification, where x is the value of the Page Number field. Consider using a tab to separate the title from the page number.
  • OOo also has a Page Count field (Insert > Fields > Page Count). Using it, you could, for example, have a header that reads page 2 of 12.

These variations are all illustrated in Figure 32.

inline:Frame10.png

Many more variations are possible. For example, you can use a footer instead of a header to make the page number appear at the bottom of the page. You can also include the chapter number with the page number: see “Numbering pages by chapter" in Chapter 4 (Formatting Pages).

Example: Restart page numbering: a preface

Some times you want to reset the page number back to 1. A typical example is the preface for a book. A standard preface has the following properties:

  • Page numbers are displayed in Roman numerals (i, ii, iii, iv, …).
  • After the preface, the document starts on a Default page.
  • The page number resets to 1, and the number format becomes Arabic (1, 2, 3, 4, ...).

Resetting the page number requires page breaks.

First, let's get the preliminary work done for the Preface style:

  1. Create a new page style and name it Preface.
  2. Set its Next Style to Preface because a preface could span multiple pages.
  3. Add a header to Preface and insert the Page Number field. Make the page numbers display as Roman numerals (i, ii, iii, iv, …):
    • Open the page style window for Preface (if not already open) and click the Header tab. Check Header on under Header.
    • Click the Page' tab. Under Layout settings, in the Format drop-down list, set the format to i, ii, iii, '. (See Figure 33.) Click OK to close the dialog box.
inline:Frame39.png

After the preface is written, we are ready to restart the page numbering in the main body of the document to Arabic numerals. Follow these steps:

  1. Make an empty paragraph at the very end of the preface.
  2. Put the cursor on the blank line.
  3. Choose Insert > Manual Break.
  4. Select Page break and choose the Default style.
  5. Select the Change page number check box and set the new value to 1. Click OK to close the dialog box.

These settings are shown in Figure 34.

inline:Frame40.png
Note You cannot assign an odd page number to a left page or an even page number to a right page. OOo strongly adheres to the convention that odd page numbers go on right-hand pages and even page numbers on left-hand pages.

This change is also reflected on the status bar. The Page section of the status bar now includes both the total page count and the entry of the page number field (Figure 35).

inline:Frame4.png

Example: Different headers on right and left pages

When you insert a header on a page style set up for mirrored pages or right-and-left pages, you can have the contents of the header be the same on all pages or be different on the right and left pages.

To allow different content in headers, clear the Same content left/right check box in the Header area on the Header page of the Page Style dialog box (Figure 36).

inline:Frame29.png

Now, you can put the page number on the left-hand edge of the left pages and on the right-hand edge of the right pages, put the document title on the right-hand page only, or make other changes. Figure 37 shows an example.

inline:Frame30.png

Using character styles

Character styles are a complement to paragraph styles. Like paragraph styles, they define text properties (font, weight, size), but they are applied to blocks of text smaller than a paragraph. For example, you can use the Emphasis character style to emphasize a word. A couple of character styles used in this document include:

  • Key strokes use the custom OOoKeyStroke style. For example, “to set OOo to full screen, press Control+Shift+J".
  • Menu paths use the custom OOoMenuPath style. For example, “to turn field shadings on or off, choose View > Field Shadings".

Why use character styles?

Beginning OOo users often wonder, “Why use character styles?" or “How is this different from pressing the bold icon to change the font typeface?" The following real life event illustrates the difference.

inline:Frame23.png

Character styles do not have as many options as paragraph styles or page styles. Their benefits are of a different nature:

  • Formatting changes
    As Jean's story illustrates, the ability to make formatting changes throughout a document can be important. Character styles provide this.
  • Consistency
    Character styles help ensure that typesetting guidelines are applied consistently.
  • Focus on content
    Was I supposed to bold keystrokes? How about menus?"
    A writer shouldn't have to remember the answers to these questions. Typesetting details distract you from the real content of your work. A properly named custom character style (such as OOoKeyStroke or OOoMenuPath) will remove this burden from you.

Other ways of using character styles are described elsewhere in the Writer Guide. These uses include making chapter numbers, page numbers, or list numbers larger than the surrounding text and formatting hyperlinks.

Applying character styles

Open the Styles and Formatting window (press F11) and click the second button in the top bar inline:Graphic14.png . The list of available character styles is displayed. To apply a character style, follow these steps:

  1. Select the block of text where you wish to apply the style.
  2. Double-click the appropriate character style in the Styles and Formatting window.

Some examples include:

inline:Frame42.png
Note One difference between character styles and paragraph styles is the need for selecting text (highlighting). Character styles require you to select the text you want to apply them to; paragraph styles do not.

Unset/undo character styles

Sometimes, you will want to remove the formatting from a block of text. You must resist the temptation to do this manually. This will only cause trouble down the road. There are two easy ways to remove character formatting:

  • Select the block of text, right-click and choose Default Formatting.
  • If you have the Styles and Formatting window open, select the block of text and double-click the Default character style.
Note The first method also works for removing manual formatting.

Migrating to character styles

For people accustomed to formatting text manually, character styles can take some getting used to. Here are some suggestions for making the transition easier:

  • Never mix character styles and manual formatting. Manual formatting supersedes character styles. If you combine them, you may end up wasting hours in frustration trying to figure out why your character styles don't work.
  • Right-clicking and choosing Default Formatting removes any text formatting (both manual and character styles).
  • Realize that clicking the Bold icon in the toolbar is not easier than double-clicking on a character style that is preset for bolding the font typeface.
  • Leave the Styles and Formatting window open to make character styles easy to access.


Content on this page is licensed under the Creative Common Attribution 3.0 license (CC-BY).
Personal tools