Is there an elegant way to add a chapter heading above h1?

This forum is for all Flare issues related to styles, stylesheets and XML.
Post Reply
spordelia
Propeller Head
Posts: 19
Joined: Mon Nov 11, 2013 1:02 pm

Is there an elegant way to add a chapter heading above h1?

Post by spordelia »

Here's my conundrum: sometimes I create longer guides with chapters, and sometimes I create shorter docs that do not have chapters. For longer guides, I want to be able to inject chapter headings above my h1s as needed. But I don't want this to impact my existing heading styles (i.e. bump them all down one level so that h1s are suddenly styled like h2s, etc. as with the "Use TOC depth for heading levels" setting). But I do need the chapter headings to appear above h1s in the TOC.

I suspect this isn't possible, but before I create two separate stylesheets to handle this the way I want, I'm wondering if anyone has successfully found a way to achieve this.
ChoccieMuffin
Senior Propellus Maximus
Posts: 2630
Joined: Wed Apr 14, 2010 8:01 am
Location: Surrey, UK

Re: Is there an elegant way to add a chapter heading above h

Post by ChoccieMuffin »

Ah, I think I might be able to help!

We used to have a style called p.ChapterNumber, which looked like this:

Code: Select all

p.ChapterNumber
	{
		font-variant: small-caps;
		mc-auto-number-offset: 6pt;
		font-size: 9pt;
		margin-left: 0;
		margin-top: 0pt;
		margin-bottom: 28pt;
		mc-auto-number-format: 'CH:Chapter {chapnum}';
		text-transform: uppercase;
		letter-spacing: 6px;
		page-break-after: avoid;
	}
When I wanted to have a chapter number I inserted a paragraph with an empty space in before my H1 and formatted it as p.ChapterNumber, then conditioned it as print only because it didn't make sense having it in my online output (I'm guessing you could now do that automatically by adding the condition to the style.) I also had p.LessonNumber and p.AppendixNumber that just used a different mc-auto-number-format.

Hope that gets you along the right track.
Started as a newbie with Flare 6.1, now using Flare 2023.
Report bugs at http://www.madcapsoftware.com/bugs/submit.aspx.
Request features at https://www.madcapsoftware.com/feedback ... quest.aspx
spordelia
Propeller Head
Posts: 19
Joined: Mon Nov 11, 2013 1:02 pm

Re: Is there an elegant way to add a chapter heading above h

Post by spordelia »

Oh, that is helpful. Were you able to get the chapter title to appear in the table of contents? The other issue I'm encountering is that if I try to add the chapter heading as an mc-heading-level 1, everything else still gets bumped down. Or do you just not have the chapter title in the TOC?
doloremipsum
Sr. Propeller Head
Posts: 290
Joined: Mon Aug 26, 2019 2:11 pm

Re: Is there an elegant way to add a chapter heading above h

Post by doloremipsum »

Unfortunately the mc-heading-level determines BOTH the print table of contents level AND the heading level in the document (if the Use TOC Depth is turned on). TOC level 1 = h1 = print table of contents level 1, because they all =mc-heading-level 1.

You could avoid the 'push down' effect by putting you chapter headings (in a separate topic!) on the same TOC level as the h1s. Then they would also be at the same level in the print TOC, but it does get most of what you want.
in hoc foro dolorem ipsum amamus, consectimur, adipisci volumus.
ChoccieMuffin
Senior Propellus Maximus
Posts: 2630
Joined: Wed Apr 14, 2010 8:01 am
Location: Surrey, UK

Re: Is there an elegant way to add a chapter heading above h

Post by ChoccieMuffin »

spordelia wrote:Oh, that is helpful. Were you able to get the chapter title to appear in the table of contents? The other issue I'm encountering is that if I try to add the chapter heading as an mc-heading-level 1, everything else still gets bumped down. Or do you just not have the chapter title in the TOC?
I'm sorry, I completely misread your original post. I used this to insert chapter NUMBERS in the topics, not separate HEADINGS.

So I've had another think, and here's a suggestion. You'll have to give it a go, but it ought to work!

* In your condition tag set, create a new condition (say "Primary.Long_Guides_Only").
* In your stylesheet, create a new h1 style (say h1.Long_Guides_Only) and add the new condition to the new style using "mc-conditions" attribute.
* In your topics, add a new line with the chapter heading above your existing heading, and apply the style h1.Long_Guides_Only.
* In your targets for short guides, EXCLUDE the condition Primary.Long_Guides_Only, in your targets for long guides, INCLUDE that condition (or just don't select EXCLUDE - depends how you use conditions in your targets, but that's a different discussion)

If you do that, you should be able to use the same TOCs in your targets for both long and short guides.

BUT...

You'd need to check how x-refs to the topics that have these extra lines in would work, I'm not sure what your x-ref to a topic with two h1 lines would resolve to if you exclude the condition. Have a play though, it might work...

If sticking two h1s in the same topic doesn't work, you may have to also do as doloremipsum suggests and have your chapter heading (formatted as h1.Long_Guides_Only) in a separate topic but I can't work out in my head how you'd deal with chapter breaks in your TOC. I think that if you put your chapter break in your TOC on the topic that contains just the chapter heading, it should work, but I suggest you have a play and see what happens.

Hope that's given you something to think about.
Started as a newbie with Flare 6.1, now using Flare 2023.
Report bugs at http://www.madcapsoftware.com/bugs/submit.aspx.
Request features at https://www.madcapsoftware.com/feedback ... quest.aspx
spordelia
Propeller Head
Posts: 19
Joined: Mon Nov 11, 2013 1:02 pm

Re: Is there an elegant way to add a chapter heading above h

Post by spordelia »

Thanks for the thoughtful responses!

The best solution I was able to come up on my own is the same thing doloremipsum recommended. I'm just not crazy about the way the TOC looks with chapter headings at the same level as the h1 headings, but I too haven't found any other way around this without bumping the styling of all the other headings down a notch.

I've worked for a company in the past where we did double topic headings, and I found it a huge pain to maintain, so I'm thinking I don't want to get tangled into that web again, especially since I don't see that solving the issue of the injected chapter headings making h1s appear like h2s.

I'm leaning toward just maintaining two different stylesheets, one for documents without chapters, and one for documents with chapters. Then I can set up the chapter headings at the TOC1 level, h1 chapters at TOC2, etc. The TOC will appear the way I want, and my headings won't get altered on me. Not the most fun solution, but probably the cleanest for these two different document types.

Thanks again for talking me through this!
Post Reply