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 & 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!