- Markdown For Jupiter Notebooks Free
- Markdown For Jupyter Notebooks Cheat Sheet
- Jupyter Notebook Markdown Latex
Markdown files¶ You can write content in regular Markdown files (e.g., files ending in.md). Jupyter Book supports any Markdown syntax that is supported by Jupyter notebooks. Jupyter Notebook Markdown is an extension of a flavour of Markdown called CommonMark Markdown. It has many elements for standard text processing, though it lacks a lot of. Text cells in Jupyter support the Markdown language and we are going to take a look at the facilities that it offers. Markdown is a set of simple markup codes that are easily transformed into HTML for rendering in a browser.
A Jupyter Notebook is a web application that allows you to write and share documents that have, at the same time, interactive code and text.
It uses a simple markdown language for text formatting and works with a lot of other languages beyond Python. Jupyter is very good if you want to execute code in an interactive way, that is why it is used for exploratory data analysis, numerical simulations, statistical modeling e even machine learning.
Because Jupyter Notebook makes it easy to run code and take notes, it is a great tool for learning Python. You can save the code and the explanation on the same place.
Let’s see how you can use Jupyter Notebook with Python on your local machine.
Installing Jupyter notebook
Start by going to Jupyter’s oficial website and finding the button Install the Notebook (Jupyter also has the Jupyter Lab, but we won’t go over that right now). On the website you will have the option to use it online, without the need to install anything, but having less control over it.
It is possible to install it in two ways, trough pip or Anaconda.
Pip is the oficial package manager for Python, trough it you can install several other packages and dependencies that you will need on your projects. If you already have Python installed and ready on your machine, just use the command
pip install notebook
and everything will be working.Anaconda is a kit of data science tools that already delivers Python with all other tools commonly used on the field. If you are new to Python and doesn’t have a functional environment yet, this is the way to have easy access to a lot of things you will eventually use. Access Anaconda’s website and follow the instructions there.
Running the Notebook
After installation is complete, run Jupyter Notebook with the command:
You will see an answer similar to that:
Jupyter Notebook’s server will be initiated on your default web browser and you will see something similar to the image below. If your browser doesn’t open automatically, try navigating to http://localhost:8889/tree
That is the initial page for Jupyter Notebook. It has three panes: Files, Running and Clusters.The default pane is Files, here you will visualize, create and open your notebooks.
Creating a Jupyter Notebook
It is very easy to create a notebook. Just click on New at the right side and then select Python 3 from the menu. The notebook will be created and open at a new tab, you will see something similar to:
Your notebook is created, but doesn’t have a title yet. Click on Untitled, at the top of the page and add the notebook’s title. When you change the title, your notebook will be saved to a new file with the same name as the notebook and the extension .ipynb. At the initial screen of Jupyter Notebook you will see your new notebook with the name you gave and the status running.
When the notebook is selected on the Files pane, some options will appear at the top, as Duplicate, Shutdown and Delete. Duplicate will create a copy of your notebook, Shutdown stops a running notebook and Delete erases it.
Working With the Jupyter Notebook
The notebook is built of cells stacked on top of each other. These cells can have two types, code and markdown.
This is a cell of type code. You can start to write Python 3 code right away inside it. As an example, writing
1 + 2
and pressing ctrl + enter
, you will see the result right underneath it.If you use
shift + enter
instead of ctrl + enter
it will show the results and automatically place your cursor on a new code cell and you can just keep coding.To change a cell type from code to markdown, just use the menu on the top or the keys:
m
to change code to markdown and y
to go from markdown to code.Once in markdown mode, you can start typing texts using a markdown similar to the one used on a README file for Github. Here IBM has a really good reference you can use.
Giving the command to execute this cell, it will change to a “compiled” text. To go back and edit it, double click on the cell to convert it back to markdown.
Editing and Command Modes
When you select a cell it can be in two modes, editing and command. Clicking a cell will make it enter command mode, this is represented by the blue border at the left of the cell. If you click on the edit area it will change into edit mode and the left border will be green.
Pressing the
esc
key on editing mode will take you to command mode.You can check all shortcuts available on Jupyter Notebook by navigating to Help→ Keyboard Shortcuts on the menu.
Checkpoints
Instead of saving the notebook at the latest version, you can create checkpoints with the current notebook state and then come back to the same state later. Checkpoints are very useful to test new things without the fear of ruining the work you have already done.
To create a checkpoint go to Save and Checkpoint at the File menu. To revert to a saved checkpoint, click on Revert to Checkpoint on the same menu.
Conclusion
Now you have learned how to use the Jupyter Notebooks to run Python code. Commonly used with libraries like numpy, pandas (you can check my intro to Pandas ?) and matplotlib, notebooks can come handy to test and validate lots of other projects. An interesting use can be validating endpoints on a API by calling the internal methods directly on a notebook.
I hope this tutorial helps you get into the world of notebooks. Please, ask any questions on the comments and I will answer ASAP.
The notebook is a document that allows as to combine text elements (headings,paragraphs, hyperlinks), equations (LaTeX), figures and interactive code. Thenotebook uses cells to divide text and code: text is formatted using markdown,and code is executed using the IPython kernel.
Markdown is a simple way toformat text; it has a plain text formatting syntax that can be converted easilyto HTML. It is easy to learn, check out the syntax in the 'Daring Fireball' (by John Gruber) webpage.
How do we start the Jupyter notebook app?
If you follow the installation steps for this workshop listed intherequired software markdown,you should have jupyter installed. If not, go to the link and follow theinstallation requirements.
All set? Let's open a terminal and type
jupyter notebook
hit enter and tadah!!Your default browser will open with the jupyter app. It should look like this:To start a new notebook click on the top right where it says New and click on
Python 3
. A new tab will appear in your browser and you will see:
The notebook opens by default with a single empty code cell. Try to writesome Python there and execute the cell by doing
[shift] + [enter]
.For example:
2 * 12
print('Hello world')
x = 5
# (notice there will be no output)print(x * 'Hi there')
What if we want to add a new cell?
To add a new cell (by default this will be a code cell) press the
+
New markdown. button intool bar. What if we want that cell to be a markdown cell?
In the tool bar you can see a dropdown menu that says Code, click there andpick Markdown. Now you can write some text using the markdown syntax and youcan write equations using mathjax. (mathjax is a webdisplay engine for mathematics that works in browsers. It supports most LaTeXsyntax.)
For example, type in a markdown cell:
$frac{d}{dx}left( int_{0}^{x} f(u),duright)=f(x)$
or
${frac {d}{dx}}arctan(sin({x}^{2}))=-2,{frac {cos({x}^{2})x}{-2+left (cos({x}^{2})right )^{2}}}$
Cool! ah?
How do we save our work?
- First, lets pick a name for our notebook. Click where it says Untitled (rightnext to the Jupyter logo) and pick the name that you want.
- You save your changes by either clicking in the floppy disk symbol in the toolbar or by doing
[Ctrl] + [s]
. This will save in the directory you are located,a.ipynb
file with the name that you pick for your file.
The two different modes: Edit mode and Command mode [1]
Edit mode:
Markdown For Jupiter Notebooks Free
- We know we are in this mode when we see a green cell border and a prompt showing in the editor area.
- We enter in edit mode by pressing
Enter
or clicking on the cell. - When we are in edit mode, we can type into the cell, like a normal text editor.
Command mode:
- We know we are in this mode when we see a grey cell border with a left bluemargin.
- We enter in command mode by pressing
Esc
or clicking outside the cell'sarea. - In command mode the certain keys are mapped to shortcuts that help with common actions.
You can find a list of the shortcuts by selecting
Help->Keyboard Shortcuts
from the notebook menu bar. Check them out and have fun!How we shut down the Kernel?
Markdown For Jupyter Notebooks Cheat Sheet
Once you close your notebook, you will see in the main Jupyter page that your notebook file has a green book symbol. You should click in the box at the left of that symbol, and then click where it says
shutdown
. Finally, go to theterminal that we use at the beginning to open the jupyter notebook and type[Ctrl] + [c]
and you are all done!Nbviewer
Nbviewer is a free webservice that allows you to share static html versions of hosted notebook files. If a notebook is publicly available, by giving its url to the Viewer, you should be able to view it [2]. You just need to host the notebook file (.ipynb extension) online and enter the public URL to the file on the nbviewer Go! box. The notebook will be rendered like a static webpage: visitors can read everything, but they cannot interact with the code.
References:
[1] Notebook Basics: Modal Editor
Jupyter Notebook Markdown Latex
[2] Nbviewer