Three-level ToC, or Nested Parts

Hi Pressbooks community,

I’m looking to migrate an existing book into PB, and one thing I am wrestling with is the structure/navigation hierarchy. The book I have is organized into units, chapters and readings, and so far my chapters map naturally to PB parts, and readings map to PB chapters. (The readings-as-chapters mapping is especially nice because PB chapters track contributors so well.) My problem is that I haven’t run into anything that will let me express the “unit” grouping – either one more level of hierarchy up, or the ability to nest PB parts.

I’m wondering if anyone has had a similar problem, and ideally whether they’ve found a solution, say another plugin or some interesting hack using PB parts and CSS? In my book, the unit will need to have content (much like a PB part), but what’s most important is the ToC, and specifically how the print export version looks.

For example:

- Preface
- Introduction
- Unit 1
    - Chapter 1
        - Reading  1.1
        - Reading  1.2
    - Chapter 2
        - Reading  2.1
- Unit 2
    - Chapter 3
        - Reading  3.1
        - Reading  3.2

I hope this is clear, and I appreciate any help. I’m loving Pressbooks so far, this really feels like what an online reading and publishing platform ought to be. Thanks!

Hi @urbanski this is a tricky problem. You can’t nest ‘upwards’ very easily in Pressbooks, but you can actually nest one level below ‘chapter’ in Pressbooks (and can rename part and chapter to suit you). See https://guide.pressbooks.com/chapter/table-of-contents-adding-a-second-level/ & https://guide.pressbooks.com/chapter/appearance/#themeOptions for more details. In your case I think I’d probably leave the unit as a part (renamed), and the chapter as a chapter, create <h1> heading elements for each of the several readings and then turn on the two-level ToC. Hope that helps?

Hi Steel, thank you for the quick response! Offhand, do you know if there will still be some way to indicate different contributors for the different <h1> sections? Even if it’s not an out-of-the-box mechanism, I’m comfortable playing with CSS and markup to make it work.

Hmmm. Two ideas. One, you can add multiple contributors to a given chapter. Second, you could also add a heading element or even just a bolded paragraph just under the <h1> title indicating which of the contributors is responsible for that particular reading. For example:

<h1>Reading 1</h1>
<h2 class="author">Steel Wagstaff</h2>
Blah blah blah
<h1>Reading 2</h1>
<h2 class="author">Fake Person</h2>
More blah blah blah.

The contributor elements here could be anything (h2s, paragraphs, spans, etc.) and could also receive custom classes (i.e. author in the example above) if you wanted to style them consistently in some way. You can look at the existing attribution given by the contributor tool for multiple contributors in a given chapter and adapt/revise to your needs?

Hmmm, this sounds interesting. I will explore both of these approaches. Thank you for your time and advice!

My pleasure. Good luck with your project!

Hi, there. I’m interested in nesting chapters as our textbooks are comprised (in this order) of Parts > Chapters > Units > Sub-units. Unfortunately, the link listed in this discussion no longer exists. Is it because nesting is more easily integrated now? If so, please point me to how to do that. Thank you.

You can create two-level table of contents using heading 1 elements and this theme option: Appearance – Pressbooks User Guide. Hope that helps?

Thank you, Steel. Did you mean to call out a specific theme or point me to how to choose a theme? And, are you saying that the heading structure will determine the nested units? If so, that’s fine; we’re just trying to sort out how our sections will map onto PB when we move them out of our working drafts with are Google docs.

Hi @mbelair – the two level TOC should work with any theme that supports it (all but a very small number, I think). The idea would be that you simply designate top level headings as H1s in the chapter, and they’ll have links automatically created and displayed in the book’s ToC, much like the guide itself, if you look closely.

You can make this collapsible/expandible, too – there’s a web setting that lets you collapse/expand the top level sections. I’m afraid there’s no way at present to automatically generate additional levels within the Pressbooks interface at present. You’ll notice that parts themselves can contain content, however, so maybe that will stimulate some additional structure ideas?

1 Like

Thank you, Steel, this answers my question and it appears that our theme matches our structure perfectly.

1 Like