Ask Your Question
1

How to exclude some chapters from automatic numbering of headings?

asked 2015-07-22 17:04:12 +0200

datka gravatar image

updated 2015-07-23 10:00:08 +0200

I have a text which is structured the following way:

1. Introduction     
2. Chapter 1 
2.1. Sub-chapter x
2.2. Sub-chapter y
3. Chapter 2.
3.1. Sub-chapter z
4. Conclusion
5. Bibliography

The numbering are automatic. However, would like to cancel automatic numbering of headings and sub-headings in the Introduction, Conclusion etc. What is the most elegant (non-manual) way to achieve something like this:

Introduction    
1. Chapter 1 
1.1. Sub-chapter x
1.2. Sub-chapter y
2. Chapter 2.
2.1. Sub-chapter z
Conclusion
Bibliography

For now, I succeeded to "restart numbering" (from the right-click menu) from Chapter 1 and backspace-delete the number of heading of Introduction but its sub-chapters are still numbered... Is there an elegant way (perhaps with Styles) to exclude whole chapters from automatic numbering of headings while keeping the numbering structure of the remaining chapters intact?

edit retag flag offensive close merge delete

4 Answers

Sort by » oldest newest most voted
1

answered 2015-07-23 08:22:55 +0200

pierre-yves samyn gravatar image

Hi

@datka you're right, the solution is to use dedicated paragraph styles.

The attached TitleNoNumber.odt can be done quickly:

  • Display the styles window (sidebar or F11)
  • Right click in the paragraph styles list on Heading 1 then New
  • Organizer tab give an explicit name (Title1NoNumber in the example)
  • Outline & Numbering tab, Outline level listbox select Level 1
  • Same to create Title2NoNumber starting from Heading 2 for Level 2

These styles have same properties as the Title styles (same look) and will be included in the table of contents.

Just apply these styles to the paragraphs concerned (Introduction, Conclusion, etc.)

Regards

edit flag offensive delete link more

Comments

Outline numbering is best set via Tools > Outline Numbering...

oweng gravatar imageoweng ( 2016-02-29 12:46:34 +0200 )edit
0

answered 2015-08-16 00:28:47 +0200

Hi-Angel gravatar image

updated 2015-08-16 00:36:33 +0200

Actually you don't need to create a new style. You could just click right mouse button for a "Heading" with unwanted numbering, next in the popup menu choose «Paragraph… → Numbering style → None».

Sometimes it is grayed out for some reason, though… Anyway, I wrote a function in PyUNO which was always working for me — even if the submenu for some reason grayed out. I'll leave it here if anybody would want it:

HEADING1 = "Heading 1"
HEADING2 = "Heading 2"

def removeNumberingSomeHeading1s(text):
    """Removes numbering from the first Heading1 (intro), then skips two heading1s (chapters), and
removes from the rest Heading1s and Heading2s"""
    enumeration = text.createEnumeration()
    heading1s = 0
    while enumeration.hasMoreElements():
        par = enumeration.nextElement()
        if ( par.supportsService("com.sun.star.text.Paragraph") and
            par.ParaStyleName != None):
            if par.ParaStyleName == HEADING1:
                heading1s = heading1s + 1
            if ((heading1s > 3 or heading1s == 1) and
                par.ParaStyleName == HEADING1 or
                par.ParaStyleName == HEADING2):
                    par.setPropertyValue("NumberingStyleName", "NONE")

Though I am using it in a script with another things, I guess you can use it as a macro in the LO itself (I didn't try). Also I guess you'd need to update TOC after the work is done.

I'll also leave here a full working test code that I used. But note that for the test code to work you need to start libreoffice as a server before, like soffice "--accept=socket,host=localhost,port=8100;urp;" --headless --invisible

import uno

# that's like a consts, but they isn't since consts not allowed in python 😝
HEADING1 = "Heading 1"
HEADING2 = "Heading 2"

def removeNumberingSomeHeading1s(text):
    """Removes numbering from the first Heading1 (intro), then skips two heading1s (chapters), and
removes from the rest Heading1s and Heading2s"""
    enumeration = text.createEnumeration()
    heading1s = 0
    while enumeration.hasMoreElements():
        par = enumeration.nextElement()
        if ( par.supportsService("com.sun.star.text.Paragraph") and
            par.ParaStyleName != None):
            if par.ParaStyleName == HEADING1:
                heading1s = heading1s + 1
            if ((heading1s > 3 or heading1s == 1) and
                par.ParaStyleName == HEADING1 or
                par.ParaStyleName == HEADING2):
                    par.setPropertyValue("NumberingStyleName", "NONE")

localContext = uno.getComponentContext()

resolver = localContext.ServiceManager.createInstanceWithContext(
                "com.sun.star.bridge.UnoUrlResolver", localContext )

smgr = resolver.resolve( "uno:socket,host=localhost,port=8100;urp;StarOffice.ServiceManager" )
remoteContext = smgr.getPropertyValue( "DefaultContext" )
desktop = smgr.createInstanceWithContext( "com.sun.star.frame.Desktop",remoteContext)

file = desktop.loadComponentFromURL("file:///tmp/test.odt" ,"_blank", 0, ())
removeNumberingSomeHeading1s(file.Text)
file.storeAsURL("file:///tmp/test3.odt",())
file.dispose()
edit flag offensive delete link more
0

answered 2015-08-13 07:32:51 +0200

Hi, I had exactly the same issue and my solution was to use two different Paragraph Styles.

I have created a "Chapter" style where I put my formatting and then in the Outline & Numbering tab I set it with Level 1 for the outline Number 1 for the Numbering style

Second I created a "Unnumbered Chapter" style based on the previous Chapter (so that I don't have to reformat it, plus in the future you just change Chapter and it cascades to this one too). I went into Outline & Numbering tab and set this one: Level 1 for the outline None for the numbering style

This way the look consistently, the both appropriately show up in the Index of the book, but only the former has numbering and the latter that doesn't affect them.

edit flag offensive delete link more
0

answered 2015-07-23 02:46:54 +0200

Alex Kemp gravatar image

updated 2015-08-09 17:06:18 +0200

If you are using fields (of whatever kind) within the Headings to number your chapters, then give yourself a pat on the back, as you have started off exactly correct to get it right. You now need one piece of information & a little bit of instruction to (hopefully) be able to structure it all the way that you wish.

The piece of information:

Numbering information is held within the Header/Footer of each Page Style. That is both how to re-start numbering & also how to have unique, identical text, etc. at the head of (for example) each page of specific chapters.

The little bit of instruction:

(for the sake of ease of instruction, I'm going to assume that you have a large run of text, all with the same page-style, that together composes a number of chapters)
(please note that each & every one of these steps needs to be followed for this to work)

  1. Re-name the page style at the beginning of the 1st chapter "chap01"
    (Naturally, Header needs to be switched ON in the Header tab)
  2. Click on Styles & Formatting in the Side-panel
    (alternative): press F11
  3. Select 'Page Styles' + select 'chap01'
  4. Click New Style from Selection & select New Style from Selection
    (so good they named it twice)
  5. Enter 'chap02' & press OK
  6. Now place the cursor at the very beginning of Chapter 2
  7. Enter: Menu:-Insert Manual Break...
    (select) Page Break
    (click on drop-down & select) chap02
    (press) OK

You currently now have the identical styles for chapters 1 + 2, but the actual styles are different. Therefore, if you do not want Chapter-1 to be numbered, just miss out the field in it's header. If you wish for a different numbering style then change it. If you want different text then enter it (it will stop at Chapter-2). And so on & on for each chapter.

The info given for numbering-fields given in the previous paragraph also holds true for text within Headers and/or Footers. Text is repeated within all pages that have the same Page Style.

Re-numbering

If you want a chapter to be re-numbered, then you need to take slightly different steps at step 7 above:-

  1. Go (menu):FormatParagraphText Flow tab
  2. check Break + Insert and With page style
    (select 'chap02')
    (adjust page number as desired)

If this helps then please tick the answer (✔).

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2015-07-22 17:04:12 +0200

Seen: 3,369 times

Last updated: Aug 16 '15