Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ipython notebook anchor link to refer a cell directly from outside

I am writing documentation for a notebook-based framework. When referring to important cells in a demo-notebook, can I point to a particular cell by using some sort of anchor?

For example if I have the demo-notebook at 127.0.0.1/mydemo, is it possible to refer to the input cell In[10] by some anchor tag like 127.0.0.1/mydemo#In10

like image 856
nom-mon-ir Avatar asked May 19 '13 02:05

nom-mon-ir


People also ask

How do I reference another 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).


2 Answers

Creating internal links within Markdown works quite well in practice for me. For example, you can make a table of contents by making a list in a markdown cell at the top of the page.

*[jump to code cell 2](#cell2)
*[jump to code cell 3](#cell3)
*[jump to code cell 4](#cell4)

Then you just insert a markdown cell right above the code cell you want to link to (say code cell 2). Just add one line of code:

<a id="cell2"></a>

See this tutorial for more explanation: http://nbviewer.ipython.org/github/rasbt/python_reference/blob/master/tutorials/table_of_contents_ipython.ipynb

like image 85
ahwillia Avatar answered Sep 19 '22 17:09

ahwillia


I like to use headers to organize my notebooks, such as

#My title

in a markdown cell. In another location, I can then refer to this cell using

[Link to my title](#My-title)

in markdown (looks like you should replace spaces with hyphens).

I got this from a more complete answer here.

like image 33
beardc Avatar answered Sep 22 '22 17:09

beardc