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 "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" }
If any of the IF conditions are true, the result should be "Heading 2;1;Heading 3;2;Heading 4;3;Heading 5;4;Heading 6;5".
If the IF conditions are false, "Heading 3;1;Heading 4;2;Heading 5;3;Heading 6;4" should be the result.
Do I have a syntax error? Only the second condition is always output as the result.
Best regards, Laurel
- Balou_Peters1808Copper ContributorSorry!
{ \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_KenyonBronze ContributorWhat might be your desired result?
- Balou_Peters1808Copper 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