How do I change the numbering style for headers using officer?

40 views Asked by At

I want to organize a table of contents using Roman numerals and numbers, e.g.

i.Section 1

ii.Section 2

iii.Section 3

  1. New Section 1

  2. New Section 2

    body_add_toc defaults to a arabic numeric numbering system for organizing the TOC and I can't figure out how to change it.

Changing the heading styles does not work and I can't find any related inquiries. I know how to manually do it in word but I am trying to automate documentation.

1

There are 1 answers

0
Dhruvi Kothari On

You can use this code:

<div id="toc">
  <ul>
    <li><a href="#section1">i. Section 1</a></li>
    <li><a href="#section2">ii. Section 2</a></li>
    <li><a href="#section3">iii. Section 3</a></li>
    <li><a href="#new-section1">1. New Section 1</a></li>
    <li><a href="#new-section2">2. New Section 2</a></li>
  </ul>
</div>

<div id="content">
  <h1 id="section1">Section 1</h1>
  <!-- Section 1 content here -->
  
  <h1 id="section2">Section 2</h1>
  <!-- Section 2 content here -->
  
  <h1 id="section3">Section 3</h1>
  <!-- Section 3 content here -->
  
  <h1 id="new-section1">New Section 1</h1>
  <!-- New Section 1 content here -->
  
  <h1 id="new-section2">New Section 2</h1>
  <!-- New Section 2 content here -->
</div>

The href attribute in the table of contents links to the id of the corresponding section in the content. You can customise the numbering system by changing the text inside the tags in the table of contents as per your preferences.