4

Is it possible with nbconvert --> latex --> PDF to suppress section numberings?

Essentially I would like to keep the simple font size distinctions that the markdown header syntax (#, ##, etc.), and ipynb section headings provide (nbconvert --to latex appears to treat these same), and still use these to define section headings, but without the numberings. Then I also have the option of adding my own numbers manually.

I can cope with losing some aspects of general latex document structuring and functionality. Ideally though I would like to keep that information, and just suppress the numberings in the PDF.

Cheers.

J Grif
  • 1,003
  • 2
  • 12
  • 16
  • which IPython version do you use? – Jakob Nov 28 '13 at 15:06
  • Possible duplicate of [How to remove heading numbers in Jupyter during pdf conversion?](https://stackoverflow.com/questions/35077571/how-to-remove-heading-numbers-in-jupyter-during-pdf-conversion) – esmail Mar 24 '19 at 17:24

1 Answers1

8

You can simply use the stared version of the LaTeX heading tags (section*, subsection*).
To do so, you have to create a custom template (e.g. secnum.tplx) which could look like the following

for IPython 1.x:

((*- extends 'latex_article.tplx' -*))

((* block h1 -*))section*((* endblock h1 -*))
((* block h2 -*))subsection*((* endblock h2 -*))
((* block h3 -*))subsubsection*((* endblock h3 -*))
((* block h4 -*))paragraph*((* endblock h4 -*))
((* block h5 -*))subparagraph*((* endblock h5 -*))

for IPython 2.x:

((*- extends 'article.tplx' -*))

((* block h1 -*))\section*((* endblock h1 -*))
((* block h2 -*))\subsection*((* endblock h2 -*))
((* block h3 -*))\subsubsection*((* endblock h3 -*))
((* block h4 -*))\paragraph*((* endblock h4 -*))
((* block h5 -*))\subparagraph*((* endblock h5 -*))

for IPython 3.x:

As IPython 3.x removed the heading cell type these approaches are no longer applicable here.

((* extends 'article.tplx' *))

((* block commands *))
\setcounter{secnumdepth}{0} % Turns off numbering for sections
((( super() )))
((* endblock commands *))

Note that stared headings will not be present in the TOC.
To use these templates, call them during the conversion like
ipython nbconvert --to=latex --template=secnum.tplx file.ipynb

Jakob
  • 19,815
  • 6
  • 75
  • 94