Thread: [Solved] TOC with IF Condition
View Single Post
 
Old 10-24-2024, 02:37 AM
Laurel Laurel is offline Windows 10 Office 2021
Novice
 
Join Date: Oct 2024
Posts: 2
Laurel is on a distinguished road
Angry TOC with IF Condition

Hello, a question about tables of contents with if conditions.

I have a document with chapters and subchapters. The document has two tables of contents: a short one (only the main heading) and a detailed one (with headings and page numbers). Now I want to ensure that the second detailed table of contents is not output if the short and detailed ones match.


I have the following field code:


{if {\TOC \t "Heading 2;1" \b inh_kap0_2 \o "2-2" \n "1-1" } =
{\TOC \t "Heading 2;1;Heading 3;2" \b inh_kap0_2 \o "2-3" \n "1-1" } "" {\TOC \t "Heading 2;1;Heading 3;2" \b inh_kap0_2 \o "2-3"
\n "1-1" \* mergeformat}}


This works very well. Now I would like to create a detailed and linked table of contents. But, if I add the \h switch, so


{if {\TOC \t "Heading 2;1" \b inh_kap0_2 \o "2-2" \n "1-1" } =
{\TOC \t "Heading 2;1;Heading 3;2" \b inh_kap0_2 \o "2-3" \n "1-1" } "" {\TOC \h \t "Heading 2;1;Heading 3;2" \b inh_kap0_2 \o "2-3"
\n "1-1" \* mergeformat}}


There is still no link.

I read that in \toc fields with if conditions the \h doesn't work. Is there another way to do this anyway? To reach links in the table of contents? Or works that, if at all, only via VBA code?


Thank you for your support.
Laurel
Reply With Quote