Horizontal Rule In Jupyter Notebook



The Nbconvert tool in Jupyter converts notebook files to other formats, such as HTML, LaTeX, or reStructuredText.

  1. How To Start A Jupyter Notebook
  2. Horizontal Rule In Jupyter Notebooks
  3. Horizontal Rule In Jupyter Notebook
  4. Star In Jupyter Notebook
  5. Draw A Horizontal Line In Jupyter Notebook

You also learned how to change the default type of the cell by clicking in the cell and selecting a new cell type (e.g. Markdown) in the cell type menu in the toolbar. Furthermore, you learned that in a Jupyter Notebook file, you can double-click in any Markdown cell to see the syntax, and then run the cell again to see the Markdown format. If you are running this notebook in a live session (not on try selecting. Dev0 You can add horizontal rules: Here is a. . an asterisk starts an unordered list. and this is another item in the list + or you can also use the + character - or the - character To start an ordered list, write this: 1. This starts a list.with. numbers + this will show as number '2'. this will show as number '3.' Apache Spark is gaining traction as the defacto analysis suite for big data, especially for those using Python. Spark has a rich API for Python and several very useful built-in libraries like MLlib.

  • Jupyter Tutorial
  • IPython
  • Jupyter
  • QtConsole
  • JupyterLab
  • Jupyter Resources
  • Selected Reading

Horizontal rule in jupyter notebook

Markdown cell displays text which can be formatted using markdown language. In order to enter a text which should not be treated as code by Notebook server, it must be first converted as markdown cell either from cell menu or by using keyboard shortcut M while in command mode. The In[] prompt before cell disappears.

Header cell

A markdown cell can display header text of 6 sizes, similar to HTML headers. Start the text in markdown cell by # symbol. Use as many # symbols corresponding to level of header you want. It means single # will render biggest header line, and six # symbols renders header of smallest font size. The rendering will take place when you run the cell either from cell menu or run button of toolbar.

Following screenshot shows markdown cells in edit mode with headers of three different levels.

When cells are run, the output is as follows −

Note that Jupyter notebook markdown doesn’t support WYSWYG feature. The effect of formatting will be rendered only after the markdown cell is run.

Ordered Lists

To render a numbered list as is done by <ol> tag of HTML, the First item in the list should be numbered as 1. Subsequent items may be given any number. It will be rendered serially when the markdown cell is run. To show an indented list, press tab key and start first item in each sublist with 1.

If you give the following data for markdown −

It will display the following list −

Bullet lists

Each item in the list will display a solid circle if it starts with – symbol where as solid square symbol will be displayed if list starts with * symbol. The following example explains this feature −

The rendered markdown shows up as below −

Hyperlinks

Markdown text starting with http or https automatically renders hyperlink. To attach link to text, place text in square brackets [] and link in parentheses () optionally including hovering text. Following screenshot will explain this.

The rendered markdown appears as shown below −

Bold and Italics

To show a text in bold face, put it in between double underscores or two asterisks. To show in italics, put it between single underscores or single asterisks.

The result is as shown below −

Images

To display image in a markdown cell, choose ‘Insert image’ option from Edit menu and browse to desired image file. The markdown cell shows its syntax as follows −

Image will be rendered on the notebook as shown below −

Table

In a markdown cell, a table can be constructed using | (pipe symbol) and – (dash) to mark columns and rows. Note that the symbols need not be exactly aligned while typing. It should only take respective place of column borders and row border. Notebook will automatically resize according to content. A table is constructed as shown below −

The output table will be rendered as shown below −

Markdown Formatting

The five most important concepts to format your code appropriately when using markdown are:

  1. Italics: Surround your text with ‘_’ or ‘*’
  2. Bold: Surround your text with ‘__’ or ‘**’
  3. inline: Surround your text with ‘`’
  4. blockquote: Place ‘>’ before your text.

  5. Links: Surround the text you want to link with ‘[]’ and place the link adjacent to the text, surrounded with ‘()’

Headings

Notice that including a hashtag before the text in a markdown cell makes the text a heading. The number of hashtags you include will determine the priority of the header (‘#’ is level one, ‘##’ is level two, ‘###’ is level three and ‘####’ is level four).

H2

H3

H4

H5
H6

Alternatively, for H1 and H2, an underline-ish style:

Alt-H2

Emphasis

Emphasis, aka italics, with asterisks or underscores.

Strong emphasis, aka bold, with asterisks or underscores.

Combined emphasis with asterisks and underscores.

Strikethrough uses two tildes. Scratch this.

Lists

There are three types of lists in markdown.

Ordered list:

  1. Step 1
    1. Step 1B
  2. Step 3

Unordered list

  • CESM-POP
  • CESM-MOM
  • CESM-CAM

Task list

  • Learn Jupyter Notebooks
    • Writing
    • Modes
    • Other Considerations
  • Submit Paper

NOTE:

Double click on each to see how they are built!

Images

Here’s our logo (hover to see the title text):

Inline-style:

Star in jupyter notebook

Reference-style:

How To Start A Jupyter Notebook

Code and Syntax Highlighting

Code blocks are part of the Markdown spec, but syntax highlighting isn’t. However, many renderers – like Github’s and Markdown Here – support syntax highlighting. Markdown Here supports highlighting for dozens of languages (and not-really-languages, like diffs and HTTP headers); to see the complete list, and how to write the language names, see the highlight.js demo page.

Inline code has back-ticks around it.

Blocks of code are either fenced by lines with three back-ticks ```, or are indented with four spaces. I recommend only using the fenced code blocks – they’re easier and only they support syntax highlighting.

Again, to see what languages are available for highlighting, and how to write those language names, see the highlight.js demo page.

NotebookJupyter

Tables

Tables aren’t part of the core Markdown spec, but they are part of GFM and Markdown Here supports them.

Colons can be used to align columns.

TablesAreCool
col 3 isright-aligned$1600
col 2 iscentered$12
zebra stripesare neat$1

Blockquotes

Blockquotes are very handy in email to emulate reply text.This line is part of the same quote.

Quote break.

This is a very long line that will still be quoted properly when it wraps. Oh boy let’s keep writing to make sure this is long enough to actually wrap for everyone. Oh, you can putMarkdown into a blockquote.

Inline HTML

You can also use raw HTML in your Markdown, and it’ll mostly work pretty well.

Definition list
Is something people use sometimes.
Markdown in HTML
Does *not* work **very** well. Use HTML tags.

Horizontal Rule

Three or more…

Hyphens

Asterisks

Underscores

Line Breaks

My basic recommendation for learning how line breaks work is to experiment and discover – hit <Enter> once (i.e., insert one newline), then hit it twice (i.e., insert two newlines), see what happens. You’ll soon learn to get what you want. “Markdown Toggle” is your friend.

Here are some things to try out:

Here’s a line for us to start with.

This line is separated from the one above by two newlines, so it will be a separate paragraph.

This line is also begins a separate paragraph, but…This line is only separated by a single newline, so it’s a separate line in the same paragraph.

(Technical note: Markdown Here uses GFM line breaks, so there’s no need to use MD’s two-space line breaks.)

YouTube Videos

They can’t be added directly but you can add an image with a link to the video like this:

Horizontal Rule In Jupyter Notebooks

Or, in pure Markdown, but losing the image sizing and border:

TeX Mathematical Formulae

A full description of TeX math symbols is beyond the scope of this cheatsheet. Here’s a good reference, and you can try stuff out on CodeCogs. You can also play with formulae in the Markdown Here options page.

Here are some examples to try out:

The beginning and ending dollar signs ($) are the delimiters for the TeX markup.

Rendered Tex:

$-b pm sqrt{b^2 - 4ac} over 2a$$x = a_0 + frac{1}{a_1 + frac{1}{a_2 + frac{1}{a_3 + a_4}}}$$forall x in X, quad exists y leq epsilon$

Code Capabilities

Code cells are different than Markdown cells in that they have an output cell. This means that we can keep the results of our code within the notebook and share them. Let’s say we want to show a graph that explains the result of an experiment. We can just run the necessary cells and save the notebook. The output will be there when we open it again! Try it out by running the next four cells.

We can also print images while experimenting.

  • Even videos:

Shortcuts and tricks

Command Mode Shortcuts

There are a couple of useful keyboard shortcuts in Command Mode that you can leverage to make Jupyter Notebook faster to use. Remember that to switch back and forth between Command Mode and Edit Mode with Esc and Enter.

m: Convert cell to Markdown

y: Convert cell to Code

D+D: Delete cell

o: Toggle between hide or show output

Shift+Arrow up/Arrow down: Selects multiple cells. Once you have selected them you can operate on them like a batch (run, copy, paste etc).

Shift+M: Merge selected cells.

Shift+Tab: [press once] Tells you which parameters to pass on a function

Shift+Tab: [press three times] Gives additional information on the method

Cell Tricks

  • There are also some tricks that you can code into a cell.

?function-name: Shows the definition and docstring for that function

Horizontal Rule In Jupyter Notebook

??function-name: Shows the source code for that function

Line Magics

Line magics are functions that you can run on cells and take as an argument the rest of the line from where they are called. You call them by placing a ‘%’ sign before the command. The most useful ones are:

%matplotlib inline: This command ensures that all matplotlib plots will be plotted in the output cell within the notebook and will be kept in the notebook when saved.

%reload_ext autoreload, %autoreload 2: Reload all modules before executing a new line. If a module is edited, it is not necessary to rerun the import commands, the modules will be reloaded automatically.

Star In Jupyter Notebook

These three commands can be called together at the beginning of every notebook.

Draw A Horizontal Line In Jupyter Notebook

%timeit: Runs a line multiple times and displays the average time it took to run it.

%debug: Allows to inspect a function which is showing an error using the Python debugger.