Jupyter General

Help

To see parameters: SHIFT + TAB For help use ? before or after the command. For autocompletion: TAB + TAB Merge cells, select cells then: Shift + M `To see all available functions in numpy that havesinin their name:np.sin?`

Markdown

For raw text use:

```text

and close with

<```> but without the <> (that's the only one text that can't be displayed I guess!)

To add some empty vertical space one can use:

&nbsp;

or add a new line use \_ where _ denotes space.

Magic commands

To autoreload edited python files (doesn’t include class signatures changes, these you have to re-import):

%load_ext autoreload
%autoreload 2

nbimporter

To import methods from another jupyter notebook:

pip install nbimporter

For more see here.

nbconvert

nbconvert is a command line tool that can convert notebooks to other formats. To convert to pdfs, use the following command:

jupyter nbconvert --to pdf notebook.ipynb

and it will create a pdf file with the same name as the notebook (in the case above notebook.pdf).

You will need to install MikTeX or TeX Live to convert to pdf (MikTex is smaller and easier to install).

One quirk is that it doesn’t render images properly, I found it works only if the image is referred to in markdown as:
![image](images/image.png).

The following WILL NOT work however:
- ![](images/image.png) apparently image caption is necessary to reference it.
- ![image](images/image.png){width=500px} this will fail to render properly, image will be squished weirdly


Another option is to use `notebook-as-pdf` package (this will install `nbconvert` as well, and bunch of other packages).
From [here](https://towardsdatascience.com/jupyter-notebook-to-pdf-in-a-few-lines-3c48d68a7a63):

```python
pip install -U notebook-as-pdf

wait to finish installation. Then:

pyppeteer-install
pip uninstall pypdf2
pip install "pypdf2<3.0"

Then run the following command line: jupyter-nbconvert --to PDFviaHTML <jupyter_notebook_file.ipynb> this will create PDF file with the same name jupyter_notebook_file.pdf (ignore the warning on IPython3 lexer unavailable). To rename a file: mv old_name new_name

Unfortunately only command line works, Download as option in a browser doesn’t.

Extensions

conda install -c conda-forge jupyter_contrib_nbextensions

After installation and restart, you will see nbextensions tab, most notable extensions are collapsable headings, table of context 2 (toc2), spellcheck.