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

command line argument for table of content. #1690

Open
sorenwacker opened this issue Dec 8, 2021 · 4 comments · May be fixed by #2178
Open

command line argument for table of content. #1690

sorenwacker opened this issue Dec 8, 2021 · 4 comments · May be fixed by #2178

Comments

@sorenwacker
Copy link

I just tried this

jupyter nbconvert --to pdf --no-input notebook.ipynb

And it is a really convenient way to remove the code cells from the PDF.

I thought it would be really nice if something like this would also exist for table of content.

E.g. :

jupyter nbconvert --to pdf --no-input --with-toc notebook.ipynb
@Plinsboorg
Copy link

Plinsboorg commented Jan 23, 2022

Hello @sorenwacker,

You can use the \tableofcontents command inside the Raw cell. This command will generate the table of contents in whatever place you like in your document.

изображение

You can see the PDF export result from my example:

изображение

If you wish to have the table of contents on a separate page you can do so by adding \newpage command in your Raw cell like that:

\newpage
\tableofcontents
\newpage

In general, I agree that the command like --with-toc would be useful. But in this case, we need to agree on where to insert the table of contents?
The first page?
The second page?
In some particular place in the text?

I would prefer the TOC at the beginning of the document right after the title, and to have an intent after it.
This result can be achieved by adding the Raw cell with the following content in the beginning of the document:

\tableofcontents
\indent

But I don't know who we need to consult to agree on a solution like that.

Note: The commands in my comment will work only with PDF export through latex. They aren't tested with any other export format.

@sorenwacker
Copy link
Author

sorenwacker commented Jan 25, 2022

Amazing. Thank you.

@ADN8B
Copy link

ADN8B commented Mar 27, 2023

My hero

@martinRenou
Copy link
Member

I would like to revive this issue and reopen it.

I believe the suggestion for a --with-toc or --toc option in nbconvert could be useful.

The solution proposed with /tableofcontents will only work with latex generated outputs.

@martinRenou martinRenou reopened this Sep 3, 2024
@HaudinFlorence HaudinFlorence linked a pull request Sep 18, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants