"Chapter #" System Variable in TOC

This forum is for all Flare issues related to PDF, eBook, Microsoft Word, Adobe FrameMaker, XPS, and XHTML book targets.
Post Reply
jacortes
Propeller Head
Posts: 45
Joined: Thu Oct 16, 2008 1:11 pm

"Chapter #" System Variable in TOC

Post by jacortes »

How do I get the words "Chapter [chapter number variable]" to appear in the printed TOC? This should be a layup, but it is driving me nuts.

I have a Page Layout with the words "Chapter [variable=System.ChapterNumber]" on the First page and tagged as an H1. It appears nicely above the Chapter Name (also an H1) when I generate, but the printed TOC does not pick it up. The printed TOC only sees the Chapter Name in the topic.

I've tried moving the "Chapter [variable=System.ChapterNumber]" next to the Chapter Name in the topic and conditionalizing it for Print only, but when I generate, it says "Chapter [undefined system variable]".

Any ideas?
LTinker68
Master Propellus Maximus
Posts: 7247
Joined: Thu Feb 16, 2006 9:38 pm

Re: "Chapter #" System Variable in TOC

Post by LTinker68 »

The TOC only picks up the heading tag in the topic itself, not the content you place in the page layout.

I haven't tried this myself, but you should (theoretically) be able to modify the p.TOC1 style in the stylesheet. In the mc-auto-number format field (in the AutoNumber group in Advanced view) type Chapter with a space after it. If it works, then all of your top-level headings will have the word Chapter before the heading text. The only downside is that it'll use that style for all top-level TOC entries, including ones you may not want it to be on, like Glossary or Index.

However, you can do what you want if you change your approach slightly. I use an auto-number format on my h1 tag that includes "Chapter" in the auto-number format plus an auto-incrementing number and a couple of spaces. I have a span class associated with that auto-number format that changes the Chapter and number to a different font. When I insert an h1 tag into a topic, the Chapter and number appear in Garamond, for example, and the heading text appears in Georgia, for example. I then left-click into the tag after the number and press Shift + Enter to insert a soft line break, which puts Chapter n on one line and the heading text on another. (I've put in a feature request to be able to enter soft line breaks from within the mc-auto-number-format field.) So in my topics they appear as two lines, but in the generated TOC they appear as one line (it seems to ignore the soft line break in my topic).
Image

Lisa
Eagles may soar, but weasels aren't sucked into jet engines.
Warning! Loose nut behind the keyboard.
jacortes
Propeller Head
Posts: 45
Joined: Thu Oct 16, 2008 1:11 pm

Re: "Chapter #" System Variable in TOC

Post by jacortes »

Lisa,
Thank you! I previously tried the solution in your middle paragraph, and that didn't work. I just tried the solution in your last paragraph and I am almost there...except that all my chapter numbers are "1."

I am probably using the worng variable.

I thought the {chapnumber} variable in the style would work (because we set the chapter number in the Property for each topic in the TOC), but it doesn't. It didn't increment for each successive chapter. I also tried {n+} and {n}. Do I really need two styles? One that sets the counter to {n=1} and one to increment for successive chapters {n+}?
LTinker68
Master Propellus Maximus
Posts: 7247
Joined: Thu Feb 16, 2006 9:38 pm

Re: "Chapter #" System Variable in TOC

Post by LTinker68 »

You can either use {n+} in the h1 tag's mc-auto-number-format field, or you could use the {chapnum} variable in place of the {n+}. The n+ doesn't do anything with the numbering via the TOC's Properties screen, but the chapnum variable does.

Also, is the 1 you're seeing in the output or just in the XML Editor? It'll always be 1 in the XML Editor (unless you have two h1 tags in the same topic) because it doesn't know what the final number will be until it builds the output.
Image

Lisa
Eagles may soar, but weasels aren't sucked into jet engines.
Warning! Loose nut behind the keyboard.
jacortes
Propeller Head
Posts: 45
Joined: Thu Oct 16, 2008 1:11 pm

Re: "Chapter #" System Variable in TOC

Post by jacortes »

Thanks. I am generating my output and viewing the numbers in the pdf. Neither of those variables seem to be working.

When I use the {ChapterNumber} variable, I set the Auto Number property for the first chapter to "Reset to 1." Then, I set each successive chapter to "continue from previous." They all still generate as "1." For giggles, I set the first chapter to "Reset to 3." And then, they all said "3" after I generated.

The {n+} variable doesn't seem to work either. You use this solution? Is there somewhere to set the initial value of n?
jacortes
Propeller Head
Posts: 45
Joined: Thu Oct 16, 2008 1:11 pm

Re: "Chapter #" System Variable in TOC

Post by jacortes »

I have now created two styles in the Print Medium: ChapterFirst and Chapter.

The Auto-number-format style for ChapterFirst is: Chapter {n=1}
The Auto-number-format style for Chapter is: Chapter {n+}

This does not work. I generated and was still looking at "Chapter 1" for all Chapter topics. If I change the ChapterFirst style to {n=5}, the first Chapter says, "Chapter 5" the next chapters say "Chapter 1."


I also tried:

The Auto-number-format style for ChapterFirst is: Chapter {n}
The Auto-number-format style for Chapter is: Chapter {n+}

This is closer becuase the first Chapter says "Chapter 0" and the next Chapter says, "Chapter 1" and so on. So at least I can tell there's a connection in the variable settings. (Now if only I actually needed a Chapter 0!) :D


This shouldn't be that hard. I'm close to tapping out...
LTinker68
Master Propellus Maximus
Posts: 7247
Joined: Thu Feb 16, 2006 9:38 pm

Re: "Chapter #" System Variable in TOC

Post by LTinker68 »

jacortes wrote:The {n+} variable doesn't seem to work either. You use this solution? Is there somewhere to set the initial value of n?
You need to specify that the "n" is a global counter and give the format an ID so all instances that use that format are grouped. So your mc-auto-number-format field for the h1 tag would look something like GA:Chapter {n+}. "G" indicates it's a global counter, "A" is the identifier for that sequence, and "Chapter" is static text that's entered before the number. You don't have to specify the starting value for n unless you want to change its value mid-stream. In this case, it will automatically start at 1, and will keep incrementing throughout the project, although you won't see that until the output. It keeps track of the numbers through several means -- the "G" for global counter, the "A" that keeps the sequence together, and the position of n in the octet (first octet in this case). If you were to do outline numbering instead, then your h1, h2, h3 tags would look something like:

Code: Select all

h1 { mc-auto-number-format:'GA:{n+}'; }
h2 { mc-auto-number-format:'GA:{n}.{n+}'; }
h3 { mc-auto-number-format:'GA:{n}.{n}.{n+}'; }
The "A" used in all three headings groups them all together, and the octet positions are incremented in relation to each other. So the first octet is used for incrementing the number when it encounters another h1, but if it encounters an h2 or h3 then it uses the last value of n in that position. The second octet increments when it encounters another h2, but uses its last value when you insert an h3 tag. The third octet increments when you insert the next h3.

Does that make it more clear?
Image

Lisa
Eagles may soar, but weasels aren't sucked into jet engines.
Warning! Loose nut behind the keyboard.
jacortes
Propeller Head
Posts: 45
Joined: Thu Oct 16, 2008 1:11 pm

Re: "Chapter #" System Variable in TOC

Post by jacortes »

Lisa,
This worked. Thank you for your help.

For posterity, to get the words "Chapter #" to appear in your TOC when you direct to pdf, you should:

1. Amend the mc-auto-number-format property for your H1 style with the following text: GA:Chapter {n+}

This will add the text: "Chapter" and a number before your topic title. If you only want this to appear in the pdf, amend the Print Medium in your stylesheet (not the Default Medium).

2. If you desire, you can press Shift+Enter after the automated text to put a non-breaking line between the automated text and the topic title.

You can also conditionalize the non-breaking line as print-only by clicking the <br> tag in your topic title.
Diana_BB
Sr. Propeller Head
Posts: 147
Joined: Mon Oct 22, 2007 11:46 am
Location: Dallas, TX

Re: "Chapter #" System Variable in TOC

Post by Diana_BB »

Lisa,
I tried this and got it to work, but I have to do something different with my Contents for PDFs. I have to make my Flare template match as closely as possible as a peer team who uses FrameMaker. We've worked out many style issues and compromises and now I have to implement as much as possible in Flare (and report what I can't do).

My first pages for chapters/appendixes use a simple number/letter next to the title, so adding "Chapter #" doesn't work for me.

This is what a chapter looks like:
chapter_example.png
This what I need my Contents to look like (if possible):
contents_example.png
Is there a way to make the page number appear at the beginning of the line (as shown in the Contents mockup above), so there is no need for a leader? Or, if the page number must be on the right, can I make it show up at the end of the topic titles?

I really try to make things simple, but I keep getting requirements that add complications. The upside is that I learn something new all the time. :roll:

Any ideas?
Thanks,
Diana
You do not have the required permissions to view the files attached to this post.
Image
LTinker68
Master Propellus Maximus
Posts: 7247
Joined: Thu Feb 16, 2006 9:38 pm

Re: "Chapter #" System Variable in TOC

Post by LTinker68 »

So far as I know, you can't specify where the page number falls on the line. I think the only option is on the right side of the topic title. I tried playing with the mc-leader attributes for the TOC1 tag (located under Unclassified when in Advanced view and Show: Property Groups), but it didn't seem to have an affect. I didn't really play with it that much, though. If I use a TOC proxy in a topic and build WebHelp output, then I see there is a div class called MCTocProxy that's used, a table class called GenTOCTable1, and td classes called mcReset, GenTOCText1, and GenTOCPageText1. There's also a hyperlink class called TOCPageNumber.

So there are a bunch of styles in use that don't show up in the stylesheet, but I'm not sure how to get it to not appear in a table, which is really what's separating the topic titles from the page number. You might have to ask MadCap Support about that.
Image

Lisa
Eagles may soar, but weasels aren't sucked into jet engines.
Warning! Loose nut behind the keyboard.
Diana_BB
Sr. Propeller Head
Posts: 147
Joined: Mon Oct 22, 2007 11:46 am
Location: Dallas, TX

Re: "Chapter #" System Variable in TOC

Post by Diana_BB »

Thanks for trying, Lisa!

I've played with the right margins, too--just not appealing. I'll work out something.

Diana
Image
Post Reply