Closed MajoroMask closed 5 years ago
Hi, thanks for reporting this.
No table of contents entries found.
Did you clicked on 'yes' when the document opened and Word shown the dialog box? (in case of, you need to clik on yes so that Word can build the TOC).
Closing that for now as I am not able to reproduce - will reopen if necessary
Thanks for your reply @davidgohel. I did click "yes" and let Word build TOC every time I open an officer generated document. Besides I've tried to change body_add_toc()
argument level = 3
to level = 1
, but the problem still exists.
I also tried to open the same .docx
on Windows 10 (Office version Microsoft Word for Office 365 MSO (16.0.11231.20164) x64
), didn't help.
This is the .docx
I generated. I think this could be of help.
test_graphic_toc.docx
Same issue. Carefull checking reveals the fact: to_wml
function inside body_add_toc
adds extra ";1" to style name. Example:
> body_add_toc
function (x, level = 3, pos = "after", style = NULL, separator = ";")
{
bt <- block_toc(level = level, style = style, separator = separator)
out <- to_wml(bt, add_ns = TRUE)
body_add_xml(x = x, str = out, pos = pos)
}
<bytecode: 0x560c074cc0e0>
<environment: namespace:officer>
> bt<-block_toc(level=3, style = "MISC: Table Caption Header 8pt", separator = ";")
> str(bt)
List of 4
$ level : num 3
$ style : chr "MISC: Table Caption Header 8pt"
$ seq_id : NULL
$ separator: chr ";"
- attr(*, "class")= chr [1:2] "block_toc" "block"
> out <- to_wml(bt, add_ns = TRUE)
> out
[1] "<w:p> ... TOC \\h \\z \\t \"MISC: Table Caption Header 8pt;1\" ... </w:p>"
Fixing this manually helps, so it looks like some bug in to_wml function
This old thread has been automatically locked. If you think you have found something related to this, please open a new issue and link to this old issue if necessary.
Minimum instance:
The codes runs just fine. Thing is when opening the output
.docx
(MS Office for Mac version16.22
), MS word warnings meCreating a table of contents? Start by applying a heading style from the Styles gallary to the selected text.
And the toc field showsNo table of contents entries found.
These warning(s) can be reproduced when opening the
.docx
on a Win10 platform (Office version16.0.11029.20104 x64
). So I'm thinking these may be introduced by certain MS Office update.PS:
sessionInfo()