Difference between revisions of "Documentation/SL/How Tos/Nastavitev sloga za oštevilčevanje vrstic kode"

From Apache OpenOffice Wiki
Jump to: navigation, search
Line 83: Line 83:
 
[[Image:numlist4.png|Setting the alignment and indentation for the CodeNumbering style]]<br>''Figure 4: Setting the alignment and indentation for the CodeNumbering style.''
 
[[Image:numlist4.png|Setting the alignment and indentation for the CodeNumbering style]]<br>''Figure 4: Setting the alignment and indentation for the CodeNumbering style.''
  
<li>Do nothing on the other pages of this dialog.</li>
+
<li>Ne naredite ničesar na drugih straneh tega pogovornega okna.</li>
  
<li>Click OK to save this style.</li>
+
<li>Kliknite V redu in s tem shranite ta slog.</li>
 
</ol>
 
</ol>
  
=== Step 2. Create the paragraph style. ===
+
=== 2. korak: Ustvarite slog odstavka. ===
 
<ol>
 
<ol>
 
<li>Click the Paragraph Styles icon at the top of the Styles and Formatting window (first icon on the left).</li>
 
<li>Click the Paragraph Styles icon at the top of the Styles and Formatting window (first icon on the left).</li>

Revision as of 15:13, 5 May 2008

Template:Documentation/Howto

Ta dokument opisuje, kako nastavitev slog odstavka, ki uporablja za številčenje vrstic slog seznama (dejansko odstavke) v izpisih programske kode.

Primer pričakovanega rezultata

We want to create a program code paragraph style that numbers like this, with the numbers right-aligned, each line of code indented the same distance, and the paragraphs indented enough so that the numbers fit in the available space. (Each line of code is in a separate paragraph.)

     1  Vrstica 1 
     2  Vrstica 2 
     3  Vrstica 3 
        ... 
     8  Vrstica 8 
     9  Vrstica 9 
    10  Vrstica 10 
    11  Vrstica 11 
        ... 
   101  Vrstica 101 
  1001  Vrstica 1001

Slika 1: Primer seznama.

Navodila

Postopek ima tri korake:

Step 1. Create the list numbering style.

Step 2. Create the paragraph style.

Step 3. Apply the paragraph style to the code listing.

Before you begin, press F11 to open the Styles and Formatting window, if it is not already open.

Step 1. Create the list numbering style.

  1. Click the List Styles icon at the top of the Styles and Formatting window (fifth from the left).
  2. Right-click in the blank area below the list of styles and choose New. (You could modify one of the existing styles, but it’s easier to remember which style is for what special purpose if you create a new one.)
  3. Starting a new list style
    Figure 2: Starting a new list style.

    Note: Although the icon at the top of the Styles and Formatting window is labelled List Styles, the dialog that opens is labelled Numbering Style.

  4. On the Organizer page of the Numbering Style dialog, give the new list style a name, for example CodeNumbering.
  5. On the Options page, do this:
    1. In the Level box, choose 1.
    2. In the Numbering list, choose 1,2,3.
    3. Leave the Before and After boxes blank, or delete anything that is in them.
    4. Leave Character Style as None.
    5. Make sure Start at is 1.
    6. Show sublevels should be grayed out. Do not select the checkbox for Consecutive numbering.
    7. You do not need to do anything with any of the other levels, because this paragraph style is not going to be part of a hierarchy in an outline.

    Setting up the new CodeNumbering list (numbering) style
    Figure 3: Setting up the new CodeNumbering list (numbering) style.

  6. On the Position page, do this:
    1. In the Level box, choose 1.
    2. For Indent, choose 0.5cm. (You may need to adjust this later.)
    3. For Spacing to text, choose 1.0cm.
    4. For Minimum space..., choose 0.4cm.
    5. For Numbering alignment, choose Right.

    Setting the alignment and indentation for the CodeNumbering style
    Figure 4: Setting the alignment and indentation for the CodeNumbering style.

  7. Ne naredite ničesar na drugih straneh tega pogovornega okna.
  8. Kliknite V redu in s tem shranite ta slog.

2. korak: Ustvarite slog odstavka.

  1. Click the Paragraph Styles icon at the top of the Styles and Formatting window (first icon on the left).
  2. Right-click and choose New.
  3. On the Organizer page of the Paragraph Style dialog:
    1. Give the new paragraph style a name. We’ll call it ProgCode.
    2. In the Next Style box, choose ProgCode (that will make the following paragraph also be in this style, until you choose a different style).
    3. In Linked with, I recommend choosing -None-.
    4. Category should be Custom Styles, though I think that doesn't matter.

    Creating the ProgCode paragraph style
    Figure 5: Creating the ProgCode paragraph style.

  4. On the Font page, choose the font you want, perhaps Courier New, and the size.
  5. On the Indents & Spacing page, leave all the boxes showing 0.00cm.
  6. On the Numbering page, choose from the list the CodeNumbering style you just created.
  7. Associating the paragraph style with a numbering style
    Figure 6: Associating the paragraph style with a numbering style.

  8. You should not need to do anything on the other pages of this dialog.
  9. Click OK to save this style.

Step 3. Apply the paragraph style to the code listing.

If you have already entered the lines of code, select them and double-click ProgCode in the Styles and Formatting window. All the lines should now be numbered, indented, and in the correct font.

Note: If you have previously been applying manual formatting to these paragraphs, first select all the paragraphs, right-click, and choose Default Formatting; then apply the ProgCode style.

If you are starting a new block of code, apply the ProgCode style to the first line (either before or after entering it). Then when you press Enter at the end of that line, the next line will appear in the same ProgCode style but with the next number in the list sequence.

Restarting numbering (if required)

If you have more than one list in a chapter, the second and subsequent lists may continue numbering from the previous list. To restart at 1, place the cursor anywhere in the paragraph you want numbered 1, right-click and choose Restart numbering.

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