Jupyter中目录生成

Jupyter 中没有直接生成目录的工具,因此你需要一旦HTML的东西来生成目录。

目录

生成目录你需要两个东西

1.Destination

<a href=’#inter_link’>2.The internal hyperlink</a>

<a href=’#代码’>本文代码</a>

<a id=’needs’></a>

生成目录你需要两个东西:

  1. 目标 Destination。关键语句:
<a id='destination_tag'></a>
  1. 一个到目标的内部超链接 Internal hyperlink.关键语句:
[name shown in content](#destination_tag)

<a id=’destination’></a>

1. Destination

在需要出现在目录中的地方插入一个空的 HTML 定位标记并给他一个id, 例如:

<a id='the_destination'></a>

注意

1.id也可以使用name,但是name在HTML5中不再使用了,建议使用id。因为你可能把Notebook导出为html并放在其他地方
2.创建destination的语句最好单独放在一个cell里面,如果放在destination一个cell中,在jupyter中没用影响,但是在html中有问题。例如这里我是在“1. Destination” 之前建了一个cell输入<a id='the_destination'></a>

<a id=’inter_link’></a>

2.The internal hyperlink

有两种方式:
1.使用goode olde HTML,在名字前使用hash标识#将一个fragment identifier 放在目录中:<a href='#the_destination'>Link to the destination</a>,例如:
<a href='#inter link'>2.The internal hyperlink</a>

2.更简单的方法是使用Markdown语法:[Link to the destination](#the_destination),例如:
[2.The internal hyperlink](#inter link)

<a id=’代码’></a>

本文代码

目录中的代码:

# 目录
[生成目录你需要两个东西](#needs)

[1.Destination](#destination)

<a href='#inter_link'>2.The internal hyperlink</a>

<a href='#代码'>本文代码</a>

三个标题前分别插入的描述destination的cell:

<a id='needs'></a>
<a id='destination'></a>
<a id='linter_link'></a>
<a id='代码'></a>

    原文作者:星星有情绪
    原文地址: https://www.jianshu.com/p/0bbcf8a25ea4
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞