Skip to content

Instantly share code, notes, and snippets.

@magican
Last active December 17, 2015 03:58
Show Gist options
  • Save magican/5546776 to your computer and use it in GitHub Desktop.
Save magican/5546776 to your computer and use it in GitHub Desktop.
Table of contents in the IPython Notebook. At the moment I simply use a custom menu CSS style in a markdown cell. The menu is always fixed and I can easily navigate. But you have to write the contents yourself.
{
"metadata": {
"name": "ipnb_table_of_contents"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
"cell_type": "raw",
"metadata": {},
"source": [
"The code, which you shoul mark as markdown cell to achieve the nice green menu on your right"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"Custom menu CSS style in a markdown cell \n",
"<style>\n",
" #menu {\n",
" position: fixed;\n",
" right: 0;\n",
" top: 50%;\n",
" width: 15em;\n",
" margin: -2.5em 0 0 0;\n",
" z-index: 5;\n",
" background: hsla(80, 90%, 40%, 0.7);\n",
" color: white;\n",
" font: Georgia, \"Times New Roman\", Times, serif;\n",
" font-weight: normal;\n",
" font-size: 100%;\n",
" text-align: left;\n",
" border: solid hsla(80, 90%, 40%, 0.5);\n",
" border-right: none;\n",
" padding: 0.5em 0.5em 0.5em 2.5em;\n",
" box-shadow: 0 1px 3px black;\n",
" border-radius: 3em 0.5em 0.5em 3em;\n",
" }\n",
" #menu li { margin: 0 }\n",
" #menu a { color: inherit }\n",
"\n",
" /* Make menu absolute, not fixed, on IE 5 & 6 */\n",
" #menu { position: absolute }\n",
" *>#menu { position: fixed }\n",
" \n",
" ol.nested\n",
" {\n",
" counter-reset: item\n",
" }\n",
" li.nested\n",
" {\n",
" display: block\n",
" }\n",
" li.nested:before\n",
" {\n",
" content: counters(item, \".\") \". \";\n",
" counter-increment: item\n",
" }\n",
"</style>\n",
"\n",
"<ol class=\"nested\" id=\"menu\">\n",
" <li class=\"nested\"><a href=\"#item_1\">item 1</a></li>\n",
" <li class=\"nested\"><a href=\"#item_2\">item 2</a>\n",
" <ol class=\"nested\">\n",
" <li class=\"nested\"><a href=\"#subitem_1\">subitem 1</a></li>\n",
" <li class=\"nested\"><a href=\"#subitem_2\">subitem 2</a></li>\n",
" </ol></li>\n",
" <li class=\"nested\"><a href=\"#item_3\">item 3</a>\n",
"</ol>"
],
"language": "python",
"metadata": {},
"outputs": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Custom menu CSS style in a markdown cell \n",
"<style>\n",
" #menu {\n",
" position: fixed;\n",
" right: 0;\n",
" top: 50%;\n",
" width: 15em;\n",
" margin: -2.5em 0 0 0;\n",
" z-index: 5;\n",
" background: hsla(80, 90%, 40%, 0.7);\n",
" color: white;\n",
" font: Georgia, \"Times New Roman\", Times, serif;\n",
" font-weight: normal;\n",
" font-size: 100%;\n",
" text-align: left;\n",
" border: solid hsla(80, 90%, 40%, 0.5);\n",
" border-right: none;\n",
" padding: 0.5em 0.5em 0.5em 2.5em;\n",
" box-shadow: 0 1px 3px black;\n",
" border-radius: 3em 0.5em 0.5em 3em;\n",
" }\n",
" #menu li { margin: 0 }\n",
" #menu a { color: inherit }\n",
"\n",
" /* Make menu absolute, not fixed, on IE 5 & 6 */\n",
" #menu { position: absolute }\n",
" *>#menu { position: fixed }\n",
" \n",
" ol.nested\n",
" {\n",
" counter-reset: item\n",
" }\n",
" li.nested\n",
" {\n",
" display: block\n",
" }\n",
" li.nested:before\n",
" {\n",
" content: counters(item, \".\") \". \";\n",
" counter-increment: item\n",
" }\n",
"</style>\n",
"\n",
"<ol class=\"nested\" id=\"menu\">\n",
" <li class=\"nested\"><a href=\"#item_1\">item 1</a></li>\n",
" <li class=\"nested\"><a href=\"#item_2\">item 2</a>\n",
" <ol class=\"nested\">\n",
" <li class=\"nested\"><a href=\"#subitem_1\">subitem 1</a></li>\n",
" <li class=\"nested\"><a href=\"#subitem_2\">subitem 2</a></li>\n",
" </ol></li>\n",
" <li class=\"nested\"><a href=\"#item_3\">item 3</a>\n",
"</ol>"
]
}
],
"metadata": {}
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment