Replies: 3 comments 8 replies
-
I don't think we can build a TOC for tables with a protected style such as 'heading 1'. I don't understand why it did not work with style "Table Caption" that works on my computer.
|
Beta Was this translation helpful? Give feedback.
1 reply
-
Did you update the TOC? The TOC (and all word computed fields) must be refreshed (with F9). |
Beta Was this translation helpful? Give feedback.
2 replies
-
I opened your file and this is the result - I can see the TOC! |
Beta Was this translation helpful? Give feedback.
5 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
First, thank you to all of the contributors for this extremely helpful package!
I am having trouble adding a table of contents based on the captions for about 50 flextables that I am writing to a single Word doc and would be very grateful for any advice. Details and code are below.
Details
When I set the caption with
set_caption()
, I use the argumentword_stylename = "heading 1"
. Then when I try adding the table of contents withbody_add_toc()
, I use the argumentstyle = "heading 1"
.The captions and tables write to
full_tbls.docx
just fine, but when I try opening this doc in Word (Version 2302), I get this window:After I click Yes, I get this window:
After I click OK, the line "No table of contents entries found" is at the top of the doc:
I have also tried using "Table Caption" instead of "heading 1", but I get the same result. I tried using "heading 1" given Word's instruction above to "start by applying a heading style from the Styles gallery to the selected text." Any suggestions?
Code
My code is below, with the sections likely to be more important surrounded by separators likes this:
Load packages
Set flextable defaults and define section and text properties
Create flextables
Write flextables to Word
Beta Was this translation helpful? Give feedback.
All reactions