'breadcrumbs' in header with conditional styleref

J

jon.hertzig

Just want to toot my own horn ... been wrastling with a problem that
was reported in several outdated posts: how to get a header to show
"breadcrumbs" in a complex document, eg so that it says "Heading 1 >
Heading 2 > Heading 3 ..." for whatever's on the current page (I have
a document with 8 levels of header and was wanting to show the
navigation on each page).

The problem is that the Styleref field searches for the first occurence
of a style (eg, Heading) up or down in the entire document, not just
the current page. So if you are on a page that only goes up to H3, it
would include the H4 from several pages hence in the document. There's
no way to use the PageRef or other fields to pick up the page number of
the StyleRef that it finds... but here's how I solved it:

Creating a character style that has no attributes, HeadChar, and
applying it with global search-replace to all headings. Then searching
for the first 'HeadChar' from the bottom up (\l), and if it matches a
style level, insert that style with all the previous levels. So, for
example, for level 3: {IF {STYLEREF "Heading 3" \n \l} = {STYLEREF
"HeadChar" \n \l} "{STYLEREF "Heading 1" \n \l} {STYLEREF "Heading 1"
\p \l} > {STYLEREF "Heading 2" \n \l} {STYLEREF "Heading 2" \p \l} >
{STYLEREF "Heading 1" \n \l} {STYLEREF "Heading 1" \p \l}" }

It works!
 
J

jon.hertzig

that last conditional should have had "Heading 3" instead of "Heading
1" at the end (so it's saying, if the first heading it finds starting
its search from the current page is a level 3 heading, then show
"Heading 1 (num & text) > Heading 2 (num & txt) > Heading 3 (num &
txt)" do this for every level, and add the HeadChar to a random
paragraph on the opening pages before the first H1 appears to suppress
the breadcrumbs on those pages.
 
S

Susan J-P

Jon, I too am very interested in using a "breadcrumbs" style of page header.
I've tried to emulate your technique without much success. I do get the
headers showing, but every time it ends up displaying exactly what a plain

{STYLEREF "Heading 1" \l} > {STYLEREF "Heading 2" \l} > {STYLEREF "Heading
3" \l} > {STYLEREF "Heading 4" \l}

would show. So, for instance, on a page that shows

2.1.2 Test files
2.2 Output files

The heading shows

Source files > Output files > Test files > User interface

Where "Source files" is the prior heading 1 text and "User interface" is the
heading 4 text from several pages ahead in the document. So instead of
showing the text for heading level 2.1 (which is the parent of 2.1.2), I get
the text for heading level 2.2 as well as the text for 2.3.2.1.

After many hours/days of fiddling, I still can't figure out where I'm going
wrong.

Here's what my header code looks like:

{IF {STYLEREF "Heading 5" \n \l}={STYLEREF "breadcrumbs" \n \l}, "{STYLEREF
"Heading 1" \p \l} > {STYLEREF "Heading 2" \p \l} > {STYLEREF "Heading 3" \p
\l} > {STYLEREF "Heading 4" \p \l}" }

I found that if the Heading 5 above was a Heading 4, the entire header would
be blank for any pages where a Heading 4 actually appeared--is this right?
Using a lower-level heading (i.e. one that I didn't wish to display in the
header) seemed to work around this behavior.

Any suggestions you might have are most appreciated.

BTW, in your original post, there was a tiny but vital comma omitted from
your code (between the if/then part of the code)--it took me a while to
figure out the problem.
 
J

jon.hertzig

Hi Susan,

Here's what my code has evolved to: {StyleRef 1 \n \l} {StyleRef 1 \p
\l} {IF {StyleRef 2 \n \l } = {StyleRef HeadChar \n \l } " > {StyleRef
2 \n \l } {StyleRef 2 \p \l }"{IF {StyleRef 3 \n \l } = {StyleRef
HeadChar \n \l } " > {StyleRef 2 \n \l } {StyleRef 2 \p \l } >
{StyleRef 3 \n \l } {StyleRef 3 \p \l }" [etc.]

You don't need the quotation marks within the StyleRef codes unless the
style has a space in it (like "Heading 1") --- and StyleRef recognises
a number as a heading level ('StyleRef 2' is the same as 'StyleRef
"Heading 2"'). Also, you don't need the comma in the IF-THEN
construction; the quotation marks are enough to indicate where the THEN
starts. And I realised I always want H1, so I only add the
conditionals for H2 onward.

I can't explain the anomalies you're getting... What version of Word
are you using (I've got 2003)? The tricky thing I've found is to make
sure that everything you want tagged the dummy character format
(HeadChar for me or Breadcrumbs for you) is tagged as such, and that
nothing that shouldn't be isn't. The best way to do this is to search
down for paragraphs tagged HeadChar (or Breadcrumbs).

I've also found that sometimes it doesn't work for some unknown reason
when a heading paragraph breaks over a page. Similar (I think) to what
you discovered, the workaround for me is to add a heading level below
it, eg if the 'page-broken' heading is level 2 to add a carriage return
at the end of the page, format it H3, and backspace over the numbering.

Hope that helps!

Cheers,
jh
 
J

jon.hertzig

Hi Susan,

Here's what my code has evolved to: {StyleRef 1 \n \l} {StyleRef 1 \p
\l} {IF {StyleRef 2 \n \l } = {StyleRef HeadChar \n \l } " > {StyleRef
2 \n \l } {StyleRef 2 \p \l }"{IF {StyleRef 3 \n \l } = {StyleRef
HeadChar \n \l } " > {StyleRef 2 \n \l } {StyleRef 2 \p \l } >
{StyleRef 3 \n \l } {StyleRef 3 \p \l }" [etc.]

You don't need the quotation marks within the StyleRef codes unless the
style has a space in it (like "Heading 1") --- and StyleRef recognises
a number as a heading level ('StyleRef 2' is the same as 'StyleRef
"Heading 2"'). Also, you don't need the comma in the IF-THEN
construction; the quotation marks are enough to indicate where the THEN
starts. And I realised I always want H1, so I only add the
conditionals for H2 onward.

I can't explain the anomalies you're getting... What version of Word
are you using (I've got 2003)? The tricky thing I've found is to make
sure that everything you want tagged the dummy character format
(HeadChar for me or Breadcrumbs for you) is tagged as such, and that
nothing that shouldn't be isn't. The best way to do this is to search
down for paragraphs tagged HeadChar (or Breadcrumbs).

I've also found that sometimes it doesn't work for some unknown reason
when a heading paragraph breaks over a page. Similar (I think) to what
you discovered, the workaround for me is to add a heading level below
it, eg if the 'page-broken' heading is level 2 to add a carriage return
at the end of the page, format it H3, and backspace over the numbering.

Hope that helps!

Cheers,
jh
 
J

jon.hertzig

Hi Susan,

Here's what my code has evolved to: {StyleRef 1 \n \l} {StyleRef 1 \p
\l} {IF {StyleRef 2 \n \l } = {StyleRef HeadChar \n \l } " > {StyleRef
2 \n \l } {StyleRef 2 \p \l }"{IF {StyleRef 3 \n \l } = {StyleRef
HeadChar \n \l } " > {StyleRef 2 \n \l } {StyleRef 2 \p \l } >
{StyleRef 3 \n \l } {StyleRef 3 \p \l }" [etc.]

You don't need the quotation marks within the StyleRef codes unless the
style has a space in it (like "Heading 1") --- and StyleRef recognises
a number as a heading level ('StyleRef 2' is the same as 'StyleRef
"Heading 2"'). Also, you don't need the comma in the IF-THEN
construction; the quotation marks are enough to indicate where the THEN
starts. And I realised I always want H1, so I only add the
conditionals for H2 onward.

I can't explain the anomalies you're getting... What version of Word
are you using (I've got 2003)? The tricky thing I've found is to make
sure that everything you want tagged the dummy character format
(HeadChar for me or Breadcrumbs for you) is tagged as such, and that
nothing that shouldn't be isn't. The best way to do this is to search
down for paragraphs tagged HeadChar (or Breadcrumbs).

I've also found that sometimes it doesn't work for some unknown reason
when a heading paragraph breaks over a page. Similar (I think) to what
you discovered, the workaround for me is to add a heading level below
it, eg if the 'page-broken' heading is level 2 to add a carriage return
at the end of the page, format it H3, and backspace over the numbering.

Hope that helps!

Cheers,
jh
 
J

jon.hertzig

A couple of other things... For some strange reason if it goes to H5,
when you scroll through the document in Print View, it "vibrates" and
the cursor disappears when you get to pages just before H5 headings
(I've settled for breadcrumbs down to just H4 -- any document with that
many heading levels really should be restructured anyway!). ... Also,
I put a hard space (Ctrl-Shift-Space) between the number (\n) and text
(\p) codes so that they don't wrap funny at the end of lines.


Hi Susan,

Here's what my code has evolved to: {StyleRef 1 \n \l} {StyleRef 1 \p
\l} {IF {StyleRef 2 \n \l } = {StyleRef HeadChar \n \l } " > {StyleRef
2 \n \l } {StyleRef 2 \p \l }"{IF {StyleRef 3 \n \l } = {StyleRef
HeadChar \n \l } " > {StyleRef 2 \n \l } {StyleRef 2 \p \l } >
{StyleRef 3 \n \l } {StyleRef 3 \p \l }" [etc.]

You don't need the quotation marks within the StyleRef codes unless the
style has a space in it (like "Heading 1") --- and StyleRef recognises
a number as a heading level ('StyleRef 2' is the same as 'StyleRef
"Heading 2"'). Also, you don't need the comma in the IF-THEN
construction; the quotation marks are enough to indicate where the THEN
starts. And I realised I always want H1, so I only add the
conditionals for H2 onward.

I can't explain the anomalies you're getting... What version of Word
are you using (I've got 2003)? The tricky thing I've found is to make
sure that everything you want tagged the dummy character format
(HeadChar for me or Breadcrumbs for you) is tagged as such, and that
nothing that shouldn't be isn't. The best way to do this is to search
down for paragraphs tagged HeadChar (or Breadcrumbs).

I've also found that sometimes it doesn't work for some unknown reason
when a heading paragraph breaks over a page. Similar (I think) to what
you discovered, the workaround for me is to add a heading level below
it, eg if the 'page-broken' heading is level 2 to add a carriage return
at the end of the page, format it H3, and backspace over the numbering.

Hope that helps!

Cheers,
jh
Jon, I too am very interested in using a "breadcrumbs" style of page header.
I've tried to emulate your technique without much success. I do get the
headers showing, but every time it ends up displaying exactly what a plain

{STYLEREF "Heading 1" \l} > {STYLEREF "Heading 2" \l} > {STYLEREF "Heading
3" \l} > {STYLEREF "Heading 4" \l}

would show. So, for instance, on a page that shows

2.1.2 Test files
2.2 Output files

The heading shows

Source files > Output files > Test files > User interface

Where "Source files" is the prior heading 1 text and "User interface" is the
heading 4 text from several pages ahead in the document. So instead of
showing the text for heading level 2.1 (which is the parent of 2.1.2), I get
the text for heading level 2.2 as well as the text for 2.3.2.1.

After many hours/days of fiddling, I still can't figure out where I'm going
wrong.

Here's what my header code looks like:

{IF {STYLEREF "Heading 5" \n \l}={STYLEREF "breadcrumbs" \n \l}, "{STYLEREF
"Heading 1" \p \l} > {STYLEREF "Heading 2" \p \l} > {STYLEREF "Heading 3" \p
\l} > {STYLEREF "Heading 4" \p \l}" }

I found that if the Heading 5 above was a Heading 4, the entire header would
be blank for any pages where a Heading 4 actually appeared--is this right?
Using a lower-level heading (i.e. one that I didn't wish to display in the
header) seemed to work around this behavior.

Any suggestions you might have are most appreciated.

BTW, in your original post, there was a tiny but vital comma omitted from
your code (between the if/then part of the code)--it took me a while to
figure out the problem.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top