John,
Thanks for offering your help. I have a very common problem and no
solution for it. In technical documentation for projects in civil
engineering (at least here in Slovenia), you have very strict
specification for footer content. If the Heading on the page is of
level 2, then footer needs to display heading 2, and if Heading on the
page is of level 1, then footer needs to display heading 1. As far as I
know, nobody in Slovenia has succeeded to automatize this thing and
everybody are making separate sections for EACH heading 1 or heading 2
part of document. Which is, as you might suspect, a laborous effort!
Anyways, by looking on Internet I found something that was very good
aproximation for what I was looking for. It was the following code field:
{IF {STYLEREF "Heading 2" \n }<{STYLEREF "Heading 1" \n } {STYLEREF
"Heading 1" \n } {STYLEREF "Heading 2" \n }}
Obviously, the idea is to display LAST heading available from the point
of view of code field. This has one big mistake, for all Headings 1
that come before FIRST Heading 2, it displays that FIRST Heading 2. The
reason lays in the fact that in such cases Word - after not finding any
Heading 2 BEFORE particular code field - starts searching AFTER
particular code field. So you get
1 3.1
2 3.1
3 3.1
3.1 3.1
3.2 3.2
4 4
4.1 4.1
I found a better solution though, that is code:
{IF "{STYLEREF "Heading 1" \n}.2"<{STYLEREF "Heading 2" \h} {STYLEREF
"Heading 1" \n} {IF {STYLEREF "Heading 1" \n}>{STYLEREF "Heading 2" \n}
{STYLEREF "Heading 1" \n} {STYLEREF "Heading 2" \n} }
The idea is that first Heading 2 has "1" for second number, so first I
check if current Heading 1 is smaller that level 1 of (possibly first)
Heading 2. This gives the following result:
1 1
2 2
3 3.1
3.1 3.1
3.2 3.2
4 4
4.1 4.1
This is much better, but both pages with "3" and "3.1" get "3.1" in the
footer. After a closer inspection, the reason is very simple. On both
pages that contain "3" and "3.1" you have the same value for {STYLEREF
"Heading 1" \n} ("3") and {STYLEREF "Heading 2" \n} ("3.1") so you
CANNOT DISTINGUISH between two pages!!! Therefore solution has to be
found outside of the scope of STYLEREF code.
Another idea I got is to put hidden code in the beginning of the
document, which finds PAGE NUMBER of the first Heading 2 and then refer
to it. It is no problem to find the title of first Heading 2. Being in
the beginning of the document, {STYLEREF "Heading 2" \n} will certainly
found first Heading 2 name ("3.1"). But how to get page "4" out of
Heading name "3.1"? If I can manage to do THAT, then I have a solution
to the problem and possibly the whole civil engineering society of
Slovenia will be grateful.
So this is the problem. Do you find it interesting enough to solve it?
Best regards,
Marko.