suppress section numberings in nbconvert to latex?

我的梦境 提交于 2019-12-21 05:40:55

问题


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.


回答1:


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



来源:https://stackoverflow.com/questions/20264909/suppress-section-numberings-in-nbconvert-to-latex

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!