Skip to content

Commit

Permalink
DOC: Mention \nbsphinxstartnotebook and \nbsphinxstopnotebook
Browse files Browse the repository at this point in the history
  • Loading branch information
mgeier committed Oct 23, 2018
1 parent c1964ce commit 95eb068
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 11 deletions.
12 changes: 5 additions & 7 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,20 +63,18 @@
.. raw:: latex
\nbsphinxstartnotebook{\scriptsize\strut
\nbsphinxstartnotebook{\scriptsize\noindent\strut
\textcolor{gray}{The following section was generated from
{\sphinxcode{\sphinxupquote{\strut{}{{ docname | escape_latex }}}}}\relax
\dotfill }}
\sphinxcode{\sphinxupquote{\strut {{ docname | escape_latex }}}} \dotfill}}
"""

# This is processed by Jinja2 and inserted after each notebook
nbsphinx_epilog = r"""
.. raw:: latex
\nbsphinxstopnotebook{\scriptsize
\noindent\strut\textcolor{gray}{\dotfill\sphinxcode{\sphinxupquote{\relax
{{ env.doc2path(env.docname, base='doc') | escape_latex }}}}
ends here.}}
\nbsphinxstopnotebook{\scriptsize\noindent\strut
\textcolor{gray}{\dotfill\ \sphinxcode{\sphinxupquote{\strut
{{ env.doc2path(env.docname, base='doc') | escape_latex }}}} ends here.}}
"""

# Input prompt for code cells. "%s" is replaced by the execution count.
Expand Down
19 changes: 15 additions & 4 deletions doc/prolog-and-epilog.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -92,19 +92,30 @@
"You can also use separate content for HTML and LaTeX output, e.g.:\n",
"\n",
"```python\n",
"nbsphinx_prolog = \"\"\"\n",
"nbsphinx_prolog = r\"\"\"\n",
"{% set docname = env.doc2path(env.docname, base=None) %}\n",
"\n",
".. only:: html\n",
"\n",
" Go there: https://example.org/notebooks/{{ docname }}\n",
"\n",
".. only:: latex\n",
".. raw:: latex\n",
"\n",
" The following section was created from :file:`{{ docname }}`.\n",
" \\nbsphinxstartnotebook{The following section was created from\n",
" \\texttt{\\strut{}{{ docname }}}:}\n",
"\"\"\"\n",
"\n",
"nbsphinx_epilog = r\"\"\"\n",
".. raw:: latex\n",
"\n",
" \\nbsphinxstopnotebook{\\hfill End of notebook.}\n",
"\"\"\"\n",
"```\n",
"\n",
"Note the use of the `\\nbsphinxstartnotebook` and `\\nbsphinxstopnotebook` commands.\n",
"Those make sure there is not too much space between the \"prolog\" and the beginning of the notebook and, respectively, between the end of the notebook and the \"epilog\".\n",
"They also avoid page breaks, in order for the \"prolog\"/\"epilog\" not to end up on the page before/after the notebook.\n",
"\n",
"For a more involved example for different HTML and LaTeX versions, see the file [conf.py](conf.py) of the `nbsphinx` documentation."
]
}
Expand All @@ -125,7 +136,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.7rc1"
"version": "3.6.7"
}
},
"nbformat": 4,
Expand Down

0 comments on commit 95eb068

Please sign in to comment.