Magic in a Notebook

In the last section, we discussed how to access Unix commands from the Jupyter Notebook. The keyis to use "magic" commands, that start with a percentage sign %.

There are many more magic commands available. To see all possible magic commands available in a Jupyter notebook, type the (magic) command

  • %lsmagic

A good reference to what all these magic commands can do is here: https://ipython.org/ipython-doc/3/interactive/magics.html

With a double percentage sign %% you signal to Jupyter that the whole cell is to be interpreted accordingly. For instance a cell like this:

%%latex
\[ \int_0^1 f(x) \,dx = F(1) - F(0) \]

tells the notebook to read the whole cell as latex code, and render it accordingly.

There are similar commands for creating cells with HTML code, Ruby, Perl, JavaScript, etc etc.

(Maybe I will give a few examples here too.)

results matching ""

    No results matching ""