Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refreshing Table of Contents after document generation #105

Open
achempion opened this issue Jan 20, 2022 · 6 comments
Open

Refreshing Table of Contents after document generation #105

achempion opened this issue Jan 20, 2022 · 6 comments
Labels
cross-references cross-references and numberings

Comments

@achempion
Copy link
Contributor

achempion commented Jan 20, 2022

Screen Shot 2022-01-20 at 12 59 45

Is your feature request related to a problem? Please describe.
You can create a document with multiple headings and then use a docx feature called "Table of Contents" which will display table of contents based on those headings.

In LIbreOffice it's located here: Insert -> Table of Contents and Index -> Table of Contents, Index or Bibliography...
If you change the headings, you can regenerate table of contents in with Tools -> Update -> Update all

Some headings & sections in stencil can be hidden with if clause, which means table of contents becomes outdated.

Describe the solution you'd like
It would be nice to make stencil refresh table of contents after document gets compiled.

Describe alternatives you've considered
It's possible to resolve this issue manually by introducing additional step in the rendering process, by running virtualized libreoffice and asking it to refresh the contents.

@achempion
Copy link
Contributor Author

Also, I've noticed that when I trigger Table of Contents update for generated document it adds additional symbol before each heading.

I zoomed document a bit to make it more prominent
Screen Shot 2022-01-20 at 13 08 39

@erdos erdos added the cross-references cross-references and numberings label Jan 21, 2022
@erdos
Copy link
Owner

erdos commented Jan 25, 2022

Also, I've noticed that when I trigger Table of Contents update for generated document it adds additional symbol before each heading.

hello @achempion, could you please attach an example document with this effect?

@achempion
Copy link
Contributor Author

example.docx

@erdos
Copy link
Owner

erdos commented Feb 2, 2022

Hello @achempion, thank you for the detailed issue and the example and sorry for the late answer.

About the original issue:

The problem with TOC generation is that apart from parsing the structure of the document, it also needs to calculate page numbers. Page numbers depend on many factors: the layout of the document, spacing and even the font used. You can check it yourself: If you open a large docx document (like a long book with hundreds of pages) in Word and in LibreOffice, it is likely that the total number count will not match in the two programs, despite the standardization of the OOXML format and the decades of engineering work put in improving compatibility.

Therefore, correct TOC generation is not in the scope for this small library.

About regenerating TOC in virtualized LibreOffice:

I think this should be the correct solution to your problem. The TOC should be generated in the last step (immediately preceding printing or exporting to PDF) so the page numbers in the table will be in sync with the actual page numbers.

The bug you found about the extra / character is quite concerning though, I will take a look at that soon.

@erdos
Copy link
Owner

erdos commented Feb 8, 2022

hello @achempion, how do you trigger refresh of Table Of Contents?
I am in LibreOffice 7.2.5.2 and both Right Click on TOC> Update Index and Tools menu > Update > Update All produce a correct TOC to me without the extra / characters. Could you describe your process?

@achempion
Copy link
Contributor Author

I'm triggering update with Tools menu > Update > Update All

Screen.Recording.2022-02-08.at.23.34.19.mov

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cross-references cross-references and numberings
Projects
None yet
Development

No branches or pull requests

2 participants