timvink / mkdocs-print-site-plugin

MkDocs Plugin that adds an additional page that combines all pages, allowing easy exports to PDF and standalone HTML.
https://timvink.github.io/mkdocs-print-site-plugin/
MIT License
142 stars 24 forks source link

Toc inclusion not fully documented #97

Open Anico2 opened 7 months ago

Anico2 commented 7 months ago

Hi there,

thank you for this great plugin. I am experiencing some difficulties while trying to put the TOC in the pdf. Do I need to put it into an external file and load it? If yes, under which path and where to put the path? And in which format?

Sorry about this but I haven't found any example in the documentation. Could you please provide an example?

Thanks

timvink commented 7 months ago

Hi Anico2,

Happy to hear the plugin is useful for you.

The table of contents is auto-generated, if you have it enabled in the options (which is default):

add_table_of_contents Default is true. Adds a table of contents section at the beginning of the print page (in print version, the HTML version has a different sidebar ToC). (from https://timvink.github.io/mkdocs-print-site-plugin/options.html)

So hit CTRL + P on the print site page to see the print preview of your table of contents

Anico2 commented 7 months ago

Thank you very much for your reply.

Yeah, i read that docs section. I left all the default configuration but I ended up with an empty page at the beginning of the pdf with only the 'TOC' header at the top. Since my project is only at the beginning, some pages in mkdocs raise 404 because they are still empty. Could this be the cause of the empty toc?

Thank u

timvink commented 7 months ago

I'm not sure how to help you. I recommend creating a new, small site (mkdocs new my-project) and checking if something is wrong. This plugin does require each page to have an h1 heading (the first line having something like # title) .

TiagoTalmax commented 4 weeks ago

It seems that the issue reported is related to a misunderstanding of the default configuration.
The empty page that appears in the print output is likely generated due to the inclusion of a cover page, but the path to the template for this cover page hasn't been specified.

According to my understanding, the items related to the numbering of titles and the creation of the index are in the following items:

add_table_of_contents: true # add table of contents
toc_title: 'Index' # title of table of contents
toc_depth: 5 # depth of table of contents
enumerate_headings: true # enumerate headings h1-h5
add_cover_page: false # remove cover page from print site (first page) if true, a tpl and a path to cover_page_template option are needed
cover_page_template: "path_to_cover_page_template" # use in case add_cover_page is true