Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to reference a IPython notebook cell in markdown?

How do I reference a cell in a IPython notebook markdown?

I know how to make a reference to an external link. But is there a way to assign an ID to a cell and then refer to the cell in the markdown?

like image 219
Michael_Scharf Avatar asked Jan 22 '15 01:01

Michael_Scharf


People also ask

How do you reference a cell in Jupyter notebook?

Just add the anchor to the Markdown cell you want to refer to, and link to it using standard Markdown syntax. and the reference can be like: For more details, see [Section 1](#section_1).

How do you Markdown a cell in Jupyter?

You can change the cell type of any cell in Jupyter Notebook using the Toolbar. The default cell type is Code. To use the Keyboard Shortcuts, hit the esc key. After that, you can change a cell to Markdown by hitting the m key, or you can change a cell to Code by hitting the y key.

What is the role of a Markdown cell in a 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.

Is it possible to execute the code blocks within Markdown cells?

Using Jupyter Lab, and coding in r, the way to enter code blocks in a markdown cell is easy and has good and predictable results. Just follow the same steps each time. Press Esc key, type m for markdown cell, press Enter key. The cursor is now in the markdown cell waiting for instructions.


1 Answers

Yes, there's way to do just that in IPython.

First, define the destination in the cell you want to link with a html anchor tag and give it an Id. For example:

<a id='another_cell'></a> 

Note - When you run the above cell in markdown, it will become invisible. You can add some text above the anchor to identify the cell.

Second, create the internal hyperlink to the destination created above using Markdown syntax in another cell and run it:

[Another Cell](#another_cell) 

Now, clicking on link should take you to the destination.

like image 109
Amit Verma Avatar answered Sep 22 '22 02:09

Amit Verma