An Example Notebook¶
This notebook is meant for testing conversion to other formats.
It contains Markdown cells, code cells with different kinds of outputs and raw cells with different formats.
Markdown¶
We can use emphasis, boldface, preformatted text
.
It looks like strike-out text is not supported: [STRIKEOUT:strikethrough].
- Red
- Green
- Blue
- One
- Two
- Three
Equations¶
Equations can be formatted really nicely, either inline, like \(\text{e}^{i\pi} = -1\), or on a separate line, like
Tables¶
A | B | A and B |
---|---|---|
False | False | False |
True | False | False |
False | True | False |
True | True | True |
Links to Other Notebooks¶
Relative links to local notebooks can be used: a link to a notebook in a subdirectory, a link to an orphan notebook (latter won’t work in LaTeX output, because orphan pages are not included there).
This is how a link is created in Markdown:
[a link to a notebook in a subdirectory](subdir/another.ipynb)
Markdown also supports reference-style links: a reference-style link, another version of the same link.
These can be created with this syntax:
[a reference-style link][mylink]
[mylink]: subdir/another.ipynb
Links to sub-sections are also possible, e.g. this subsection.
This link was created with:
[this subsection](subdir/another.ipynb#A-Sub-Section)
You just have to remember to replace spaces with hyphens!
BTW, links to sections of the current notebook work, too, e.g. beginning of this section.
This can be done, as expected, like this:
[beginning of this section](#Links-to-Other-Notebooks)
Code Cells¶
An empty code cell:
In [1]:
A cell with no output:
In [1]:
None
A simple output:
In [2]:
6 * 7
Out[2]:
42
The standard output stream:
In [3]:
print('Hello, world!')
Hello, world!
Normal output + standard output
In [4]:
print('Hello, world!')
6 * 7
Hello, world!
Out[4]:
42
The standard error stream is highlighted and displayed just below the code cell. The standard output stream comes afterwards (with no special highlighting). Finally, the “normal” output is displayed.
In [5]:
import logging
logging.warning('I am a warning and I will appear on the standard error stream')
print('I will appear on the standard output stream')
'I am the "normal" output'
WARNING:root:I am a warning and I will appear on the standard error stream
I will appear on the standard output stream
Out[5]:
'I am the "normal" output'
Special Display Formats¶
TODO: tables? e.g. Pandas DataFrame?
In [6]:
from IPython.display import display, Image, SVG, Math, YouTubeVideo
Local Image Files¶
In [7]:
i = Image(filename='images/notebook_icon.png')
i
Out[7]:

In [8]:
display(i)

For some reason this doesn’t work with Image(...)
:
In [9]:
SVG(filename='images/python_logo.svg')
Out[9]:
Image URLs¶
In [10]:
Image(url='https://www.python.org/static/img/python-logo-large.png')
Out[10]:

In [11]:
Image(url='https://www.python.org/static/img/python-logo-large.png', embed=True)
Out[11]:

In [12]:
Image(url='http://jupyter.org/assets/nav_logo.svg')
Out[12]:
In [13]:
Image(url='https://www.python.org/static/favicon.ico')
Out[13]:
In [14]:
Image(url='http://python.org/images/python-logo.gif')
Out[14]:

Math¶
In [15]:
eq = Math(r"\int_{-\infty}^\infty f(x) \delta(x - x_0) dx = f(x_0)")
eq
Out[15]:
In [16]:
display(eq)
In [17]:
%%latex
\begin{equation}
\int_{-\infty}^\infty f(x) \delta(x - x_0) dx = f(x_0)
\end{equation}
In [18]:
YouTubeVideo('iV2ViNJFZC8')
Out[18]:
Raw Cells¶
Cells with the cell type “Raw NBConvert” can have different formats. This information is stored in the notebook metadata. To select the format from within Jupyter, switch the cell toolbar to “Raw Cell Format”.
By default (if no cell format is selected), the cell content is included (without any conversion) in both the HTML and LaTeX output. This is typically not useful at all.Raw cells in “reST” format are interpreted as reStructuredText and parsed by Sphinx. The result is visible in both HTML and LaTeX output. This way, links from Jupyter notebooks to reST pages are possible, e.g. A Normal reStructuredText File.
Raw cells in “Markdown” format are interpreted as Markdown and the result is included in both HTML and LaTeX output. Since the Jupyter Notebook also supports “normal” Markdown cells, this might not be useful at all.
Raw cells in “HTML” format are only included in HTML output (without any conversion). This might not be very useful, since raw HTML code is also allowed within “normal” Markdown cells.
Raw cells in “LaTeX” format are only included in LaTeX output.
Raw cells in “Python” format are not shown at all (nor acted upon in any way).