PDF Table of Contents with same hierarchy as TOC

This forum is for all Flare issues related to PDF, eBook, Microsoft Word, Adobe FrameMaker, XPS, and XHTML book targets.
Post Reply
minicyclist
Propeller Head
Posts: 60
Joined: Wed Apr 09, 2014 3:51 pm

PDF Table of Contents with same hierarchy as TOC

Post by minicyclist »

Hello,

All of my topics start with a h1 variant style (h1.sectionTitle) and I want to generate a print contents page that reflects the hierarchy of the topics in the TOC. Unfortunately, as they all start with the same style, the contents page is flat with no levels, and if I check 'Use TOC depth for heading levels ', that doesn't seem to work either.

Is what I want possible? Seems like it should be....

Grateful for help.

Ian
doloremipsum
Sr. Propeller Head
Posts: 290
Joined: Mon Aug 26, 2019 2:11 pm

Re: PDF Table of Contents with same hierarchy as TOC

Post by doloremipsum »

Hmm... The 'Use TOC Depth for Heading Levels' option ought to do exactly what you want, and it does so for me.

One potential issue I can think of: Have you messed with the mc-heading-level of any of the other heading levels? Because that is how Flare 'knows' what level to put headings in the print toc, navigation bar, etc.

e.g. if your stylesheet is set up like this:

Code: Select all

.sectiontitle
{
    mc-heading-level: 1;
}
At build-time, Flare will convert h1.sectiontitle to h2.sectiontitle, which still has an mc-heading-level of 1 and will therefore still appear at the root level of the toc.
in hoc foro dolorem ipsum amamus, consectimur, adipisci volumus.
NorthEast
Master Propellus Maximus
Posts: 6363
Joined: Mon Mar 05, 2007 8:33 am

Re: PDF Table of Contents with same hierarchy as TOC

Post by NorthEast »

I use h1 for all topic headings, and set up my CSS so that print (PDF) contents will match my TOC file structure.
I use the "Use TOC depth" setting and this CSS:

Code: Select all

h1
{
	mc-heading-level: 1;
}

h1.TOC2
{
	mc-heading-level: 2;
}

h1.TOC3
{
	mc-heading-level: 3;
}

h1.TOC4
{
	mc-heading-level: 4;
}

h2, h3, h4, h5, h6
{
	mc-heading-level: 0;
}
Notes:
* Do not manually apply h1.TOC2 - h1.TOC4 in your topics. They're only used by Flare in the output; e.g. for a topic in level 2 of your TOC, the h1 in the topic is modified to a h1.TOC2.
* h2-h6 are set to heading level 0; e.g. so a real h2 in a topic doesn't appear in your contents.
minicyclist
Propeller Head
Posts: 60
Joined: Wed Apr 09, 2014 3:51 pm

Re: PDF Table of Contents with same hierarchy as TOC

Post by minicyclist »

Thanks Dolorem, Dave,

Dave I saw that on another thread. I'm not sure how to adapt it to my project as I used h1.sectionTitle as the topic title, and within the topic I use a regular h1 for subsections.

I tried the code below, but I'm not seeing the h1's only the h1.sectionTitle.

Code: Select all

h2, h3, h4, h5, h6 { mc-heading-level: 0;}

h1 { mc-heading-level: 2;}
h1.sectionTitle { mc-heading-level: 1;}

h1.TOC2 { mc-heading-level: 2;}
h1.TOC3 { mc-heading-level: 3;}
h1.TOC4 { mc-heading-level: 4;}
h1.TOC5 { mc-heading-level: 5;}
I'm guessing it's wrong!
NorthEast
Master Propellus Maximus
Posts: 6363
Joined: Mon Mar 05, 2007 8:33 am

Re: PDF Table of Contents with same hierarchy as TOC

Post by NorthEast »

It depends how you use the h1s - if a topic uses h1.sectionTitle OR h1 (but not both), then you'd use:

Code: Select all

h2, h3, h4, h5, h6 { mc-heading-level: 0;}

h1.sectionTitle, h1 { mc-heading-level: 1;}

h1.TOC2 { mc-heading-level: 2;}
h1.TOC3 { mc-heading-level: 3;}
h1.TOC4 { mc-heading-level: 4;}
h1.TOC5 { mc-heading-level: 5;}
minicyclist
Propeller Head
Posts: 60
Joined: Wed Apr 09, 2014 3:51 pm

Re: PDF Table of Contents with same hierarchy as TOC

Post by minicyclist »

Hi Dave,

Thanks for the quick reply - you're better than Madcap support! Alas, I'm only seeing the highest level topic in my PDF table of contents.

I have a simple TOC to test, with three levels:

Code: Select all

Grandparent topic
         |-----Parent topic
                      |------Child Topic
I always use h1.sectionTitle as the title of my topic, but I also use h1 within some of the topics.

I only see Grandparent topic in my PDF table of contents. Also, the h1.sectionTitles are being resized in the output according to position in hierarchy, which makes me think that it's perhaps the .sectionTitle which is causing the problem.

I tried using the CSS you sent, and also giving h1 an mc-heading-level of zero as I don't really care about those. I just want a hierarchical view of the h1.sectionTitles (which are the first title in every topic).

Can you see any issues with this?

I wonder if the reason is that my title is a variant of h1? I could do a blanket search and replace of h1.sectionTitle to a different type, and try that instead.
doloremipsum
Sr. Propeller Head
Posts: 290
Joined: Mon Aug 26, 2019 2:11 pm

Re: PDF Table of Contents with same hierarchy as TOC

Post by doloremipsum »

Ok, I've worked out the issue:
When Flare makes the heading levels follow the TOC, it does so by shifting them down or up an h-level. h1 becomes h2, h2 becomes h3, etc. If the heading has a class, it keeps that class, e.g. h1.myclass becomes h2.myclass, etc.

So in your situation:
Grandparent h1.sectiontitle remains h1.sectiontitle, which has mc-heading-level 1 and will therefore appear in the top level of the print table of contents. No problems.

H1 within a topic is not in the TOC, so Flare doesn't do anything to it. It has an mc-heading-level of 1 by default (so it will appear at the top level of the TOC). I guess you can set it however you want, but it would be a weird decision. Note that whatever you set for this is fixed: Flare will only change the first heading in a topic.

Parent/Child h1.sectiontitle follow their TOC level and shift down to h2.sectiontitle and h3.sectiontitle respectively. In your code, you have defined h2, h3 {mc-heading-level: 0}. h2.sectiontitle inherits that, so it doesn't have a heading level and will not appear in your TOC.

My recommendations:
h1.sectiontitle is fine.
Remove the css setting h2,h3 {mc-heading-level:0;}. You actually do want these to appear in your TOC.
Create a new class (e.g. h1.subheading or even p.subheading) for use inside your topics. Using a generic class is a minefield because any changes you make to it will flow down to other classes. Give that class whatever heading level you like, but be aware that this will not follow the TOC.
in hoc foro dolorem ipsum amamus, consectimur, adipisci volumus.
NorthEast
Master Propellus Maximus
Posts: 6363
Joined: Mon Mar 05, 2007 8:33 am

Re: PDF Table of Contents with same hierarchy as TOC

Post by NorthEast »

Ok, I forgot one really important bit of information - you must not set a master stylesheet on the target (or in Project Properties), it needs to be set as (default).
If you do use a master stylesheet, there's a bug in Flare that for some reason breaks the TOC depth / mc-heading-level from working in this kind or setup. It's a wierd bug that I reported to MadCap many many years ago, but I doubt it'll ever be fixed.

So if your topics contain both h1.sectionTitle and h1, then set h1 to heading level 0 (so they're not included in the contents), which leaves just h1.sectionTitle as heading level 1.
h1, h2, h3, h4, h5, h6 { mc-heading-level: 0;}

h1.sectionTitle { mc-heading-level: 1;}

h1.TOC2 { mc-heading-level: 2;}
h1.TOC3 { mc-heading-level: 3;}
h1.TOC4 { mc-heading-level: 4;}
h1.TOC5 { mc-heading-level: 5;}
This does work. I've tried it.

In the output, the h1.sectionTitle style is mofified as follows, according to TOC level:
1> h1.sectionTitle
2>> h1.TOC2
3>>> h1.TOC3
4>>>> h1.TOC4
5>>>>> h1.TOC5

So you just need to style h1.TOC2, etc. to look the same as h1.sectionTitle.
minicyclist
Propeller Head
Posts: 60
Joined: Wed Apr 09, 2014 3:51 pm

Re: PDF Table of Contents with same hierarchy as TOC

Post by minicyclist »

Amazing! It must have been the master stylesheet was that was breaking it.

A genuinely innovative solution - thanks Dave Lee! Our PDF table of contents now look so much better. Where do I send the cheque? :)

One thing that baffles me... whay doesn't Flare use the TOC to generate the toc proxy?! Seems crazy to use the documents themselves and then modify the headings. Zero points for that feature Madcap!
NorthEast
Master Propellus Maximus
Posts: 6363
Joined: Mon Mar 05, 2007 8:33 am

Re: PDF Table of Contents with same hierarchy as TOC

Post by NorthEast »

minicyclist wrote:One thing that baffles me... whay doesn't Flare use the TOC to generate the toc proxy?! Seems crazy to use the documents themselves and then modify the headings. Zero points for that feature Madcap!
Absolutely. That was my reaction when I first used Flare 10 years ago.

The process for generating print Contents from heading levels is complicated, and also unneccessary because you've already had to create a TOC file.

So it's a bit crazy that you can't just use that TOC file to define your print Contents.
ChoccieMuffin
Senior Propellus Maximus
Posts: 2632
Joined: Wed Apr 14, 2010 8:01 am
Location: Surrey, UK

Re: PDF Table of Contents with same hierarchy as TOC

Post by ChoccieMuffin »

Dave Lee wrote:
minicyclist wrote:One thing that baffles me... whay doesn't Flare use the TOC to generate the toc proxy?! Seems crazy to use the documents themselves and then modify the headings. Zero points for that feature Madcap!
Absolutely. That was my reaction when I first used Flare 10 years ago.

The process for generating print Contents from heading levels is complicated, and also unneccessary because you've already had to create a TOC file.

So it's a bit crazy that you can't just use that TOC file to define your print Contents.
Feature request, folks!
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
Post Reply