Forum Discussion
Balou_Peters1808
Mar 16, 2023Copper Contributor
Word 2016
Hello, the following code does not give my desired result:
{ \TOC \h \t " { IF{=({ COMPARE { STYLEREF "Heading 1" \n } = 1 }*{ COMPARE { STYLEREF "Heading 2" \n } = 1.1}+{ COMPARE { STYLEREF "Headin...
Balou_Peters1808
Mar 16, 2023Copper Contributor
Sorry!
{ \TOC \h \t " { IF{=({ COMPARE { STYLEREF "Heading 1" \n } = 1 }*{ COMPARE { STYLEREF "Heading 2" \n } = 1.1}+{ COMPARE { STYLEREF "Heading 1 " \n } =1 }*{ COMPARE { STYLEREF "Heading 2" \n } = 1.2}+{ COMPARE { STYLEREF "Heading 1" \n } =2 }*{ COMPARE { STYLEREF "Heading 2" \n } = 2.1}+{ COMPARE { STYLEREF "Heading 1" \n } = 2 }*{ COMPARE { STYLEREF "Heading 2" \n } = 2.2}+{ COMPARE { STYLEREF "Heading 1" \n } = 3 }*{ COMPARE { STYLEREF "Heading 2" \n } = 3.1})} = 1 "Heading 2;1;Heading 3;2;Heading 4;3;Heading 5;4;Heading 6;5" "Heading 3;1;Heading 4 ;2;Heading 5;3;Heading 6;4" } " \b inh_kap0_1 \l "1‐7" \n "1‐1" }
{ \TOC \h \t " { IF{=({ COMPARE { STYLEREF "Heading 1" \n } = 1 }*{ COMPARE { STYLEREF "Heading 2" \n } = 1.1}+{ COMPARE { STYLEREF "Heading 1 " \n } =1 }*{ COMPARE { STYLEREF "Heading 2" \n } = 1.2}+{ COMPARE { STYLEREF "Heading 1" \n } =2 }*{ COMPARE { STYLEREF "Heading 2" \n } = 2.1}+{ COMPARE { STYLEREF "Heading 1" \n } = 2 }*{ COMPARE { STYLEREF "Heading 2" \n } = 2.2}+{ COMPARE { STYLEREF "Heading 1" \n } = 3 }*{ COMPARE { STYLEREF "Heading 2" \n } = 3.1})} = 1 "Heading 2;1;Heading 3;2;Heading 4;3;Heading 5;4;Heading 6;5" "Heading 3;1;Heading 4 ;2;Heading 5;3;Heading 6;4" } " \b inh_kap0_1 \l "1‐7" \n "1‐1" }
Charles_Kenyon
Mar 16, 2023Bronze Contributor
What might be your desired result?
- Balou_Peters1808Mar 16, 2023Copper ContributorHi Charles, I have a large Word document with many chapters. Every chapter
has its own table of contents. The tables of contents have several
Levels, from 1 to 6. They are created using bookmarks (in the example "\b
inh_kap0_1). The bookmark names are customized for each chapter.
Some chapters have their main level in the second level, others in the
third. I would like to have a nested IF link in the table of contents
achieve that for certain chapters the tables of contents start in the second
level and for other tables of contents in the third level. The
means in my example: chapters 1.1, 1.2, 2.1, 2.2 and 3.1 should begin
in the second level, all others in the third. In other words: if the
combined IF condition is true (=1), the tables of contents in the
second level and the other levels are formatted accordingly
("Heading 2;1;Heading 3;2;Heading 4;3;Heading 5;4;Heading 6;5"). If the
If the condition is false (=0), the table of contents should be in the third level
begin and the further levels are formatted accordingly ("Heading
3;1;Heading 4;2;Heading 5;3;Heading 6;4").
So:
1.1
1.1.1
1.1.1.1,
but
1.3.1
1.3.1.1
1.3.1.1.1 and so on. The OR conditions are created with the + sign. The
AND links are created with the * character. Unfortunately, my result is that the
Tables of contents always start in the third level, even if the
Condition =1 results. I may have a syntax error in the TOC
Field.
I hope I explained it clearly.
Best regards, Laurel- Charles_KenyonMar 17, 2023Bronze Contributor
Doug Robbins may be able to parse this. I'm afraid it is beyond my skill level.
One thing I would recommend would be creating the TOC fields you need and saving them in the TOC Gallery, perhaps in your template. Then use AutoText fields to incorporate them into your IF Field.
- Mar 17, 2023
Charles_Kenyon I think this is one for Macropod aka the Word Field Masochist