Autonumbering: Exercise <Module Num>-<Number>

This forum is for all Flare issues related to styles, stylesheets and XML.
Post Reply
DurtyMat
Sr. Propeller Head
Posts: 224
Joined: Wed Aug 22, 2007 8:09 am
Location: ClrH2o, Fl

Autonumbering: Exercise <Module Num>-<Number>

Post by DurtyMat »

Hola,


I'm trying to get the exercise to automatically include the module number in the exercise title, so it looks something like this:

Exercise <Module Number>-<Number>

The module's are not chapters so I can't include the <chapnum> tag.

The module style is using this mc-auto-number-format: GM:Module {n+}:

I'm having issues with the exercise mc-auto-number-format. I tried this: Exercise {GM}-{n+}: but the {GM} doesn't work.

Any suggestions?
Flare: I bought it ... so that means I can break it, right?
LTinker68
Master Propellus Maximus
Posts: 7247
Joined: Thu Feb 16, 2006 9:38 pm

Re: Autonumbering: Exercise <Module Num>-<Number>

Post by LTinker68 »

The G is just a flag indicating it's a global counter. The M is the ID, or name, of the sequence. You would apply that mc-auto-number-format to a header, such as h1. Each time you use an h1 tag, regardless if it's the top of a topic, middle, specified as a chapter or not -- that h1 tag will use that format and will increment the numbering accordingly. The mc-auto-number-format of GM:Module {n+} will resolve to Module 1, Module 2, Module 3, etc.

To reference one of those headings, you would insert a cross-reference to it. Flare will insert a bookmark in that heading automatically, and depending on how you format the xref tag will determine the text used in the xref. So in a topic, you'd go to Insert > Cross-Reference. In the screen that appears, you'd navigate to the topic containing the heading you want to xref to, then you'd select the h1 tag heading in that topic, then you'd select an xref format or create your own. You'll see the topic you're cross-referencing to open and a bookmark be added to the h1 tag.
Image

Lisa
Eagles may soar, but weasels aren't sucked into jet engines.
Warning! Loose nut behind the keyboard.
DurtyMat
Sr. Propeller Head
Posts: 224
Joined: Wed Aug 22, 2007 8:09 am
Location: ClrH2o, Fl

Re: Autonumbering: Exercise <Module Num>-<Number>

Post by DurtyMat »

I don't think I described what I am trying to get the exercise style to do. I want the exercise style to look something like this:

Exercise 1-1

where the first 1 is based on the last module number. I could be wrong, but if I created the xref style the way you suggested it, I would get something like this:

Exercise Module x: Stepping Stones-1

Right?
Flare: I bought it ... so that means I can break it, right?
LTinker68
Master Propellus Maximus
Posts: 7247
Joined: Thu Feb 16, 2006 9:38 pm

Re: Autonumbering: Exercise <Module Num>-<Number>

Post by LTinker68 »

No. What you would need to do is have two heading tags that have the same ID for the mc-auto-number format. The first heading tag you use at the very beginning of that "chapter", which will be used to increment the number before the hyphen. The second heading tag you use will increment the number after the hyphen. For instance, the stylesheet code might look something like this:

Code: Select all

h1 { mc-auto-number-format:'GE:Module {n+}'; }
h2 { mc-auto-number-format:'GE:Exercise {n}-{n+}'; }
Then your topics might be set up like the following:
e1intro.htm -- h1 tag resolves to "Module 1" -- with text that says something like, "This section contains all the exercises for Module 1".
e1-1.htm -- h2 tag resolves to "Exercise 1-1"
e1-2.htm -- h2 tag resolves to "Exercise 1-2"
e2intro.htm -- h1 tag resolves to "Module 2"
e2-1.htm -- h2 tag resolves to "Exercise 2-1"
e2-2.htm -- h2 tag resolves to "Exercise 2-1"

Because the h1 and h2 tags' auto-number formats are set as global counters (G) and have the same ID (E), their numbering scheme is remembered, so the h2 knows to use whatever value was given to the last h1 in the project. Note that the text after the GE is different (Module versus Exercise) -- it's only the E that's really important as far as tying the two tags together.

Note also that when you're in the authoring environment, the h1s will always say Module 1 and the h2s will always say Exercise 0-1, Exercise 0-2, and so on, depending on the order you've added them to the TOC. That's because it's not until build time that it resolves all the sequencing with all the conditional tags to determine which topics will be included and what the sequence is as a result.

Hope that helps.
Image

Lisa
Eagles may soar, but weasels aren't sucked into jet engines.
Warning! Loose nut behind the keyboard.
DurtyMat
Sr. Propeller Head
Posts: 224
Joined: Wed Aug 22, 2007 8:09 am
Location: ClrH2o, Fl

Re: Autonumbering: Exercise <Module Num>-<Number>

Post by DurtyMat »

This is perfect! Thanks for the help.
Flare: I bought it ... so that means I can break it, right?
Post Reply