广告
返回顶部
首页 > 资讯 > 后端开发 > 其他教程 >Typora自动编号的具体操作
  • 416
分享到

Typora自动编号的具体操作

2024-04-02 19:04:59 416人浏览 薄情痞子
摘要

概述 在使用Typora写比较长的文章时,需要给章节编号,方便区分层次。如果手动编号,一旦章节顺序改变,很多章节的编号都需要一一手动修改,极其麻烦。 Typora官方提供了自动编号的

概述

在使用Typora写比较长的文章时,需要给章节编号,方便区分层次。如果手动编号,一旦章节顺序改变,很多章节的编号都需要一一手动修改,极其麻烦。

Typora官方提供了自动编号的方法:https://support.typora.io/Auto-Numbering/。本文将对官方提供的方法,以及简单改进进行介绍。

原理

这个方法的原理是,Typora基于浏览器开发(使用快捷键Shift+F12可以打开开发者工具)。因此,可以利用CSS实现自动编号。

具体操作

  • 打开Typora -> 文件 -> 偏好设置 -> 外观 -> 打开主题文件夹。
  • 在主题文件夹下新建文件base.user.css
  • Https://support.typora.io/Auto-Numbering/中提供的三份代码(分别实现文章内容自动编号、TOC自动编号、侧边栏大纲自动编号)复制到base.user.css中。
  • 重启Typora。

改进

官方提供的代码会对一级标题进行编号,但实际写文章时,一级标题往往是文章标题,无需编号,因此,我对代码进行了简单修改。下面是修改后的代码

文章内容自动编号:



h1 {
    counter-reset: h2
}

h2 {
    counter-reset: h3
}

h3 {
    counter-reset: h4
}

h4 {
    counter-reset: h5
}

h5 {
    counter-reset: h6
}


#write h2:before {
    counter-increment: h2;
    content: counter(h2) ". "
}

#write h3:before,
h3.md-focus.md-heading:before  {
    counter-increment: h3;
    content: counter(h2) "." counter(h3) ". "
}

#write h4:before,
h4.md-focus.md-heading:before {
    counter-increment: h4;
    content: counter(h2) "." counter(h3) "." counter(h4) ". "
}

#write h5:before,
h5.md-focus.md-heading:before {
    counter-increment: h5;
    content: counter(h2) "." counter(h3) "." counter(h4) "." counter(h5) ". "
}

#write h6:before,
h6.md-focus.md-heading:before {
    counter-increment: h6;
    content: counter(h2) "." counter(h3) "." counter(h4) "." counter(h5) "." counter(h6) ". "
}


#write>h3.md-focus:before,
#write>h4.md-focus:before,
#write>h5.md-focus:before,
#write>h6.md-focus:before,
h3.md-focus:before,
h4.md-focus:before,
h5.md-focus:before,
h6.md-focus:before {
    color: inherit;
    border: inherit;
    border-radius: inherit;
    position: inherit;
    left:initial;
    float: none;
    top:initial;
    font-size: inherit;
    padding-left: inherit;
    padding-right: inherit;
    vertical-align: inherit;
    font-weight: inherit;
    line-height: inherit;
}

TOC自动编号:



.md-toc-inner {
    text-decoration: none;
}
 
.md-toc-h1 {
    margin-left: 0;
    font-size: 1.5rem;
    counter-reset: h2toc
}
 
.md-toc-h2 {
    font-size: 1.1rem;
    margin-left: 2rem;
    counter-reset: h3toc
}
 
.md-toc-h3 {
    margin-left: 3rem;
    font-size: .9rem;
    counter-reset: h4toc
}
 
.md-toc-h4 {
    margin-left: 4rem;
    font-size: .85rem;
    counter-reset: h5toc
}
 
.md-toc-h5 {
    margin-left: 5rem;
    font-size: .8rem;
    counter-reset: h6toc
}
 
.md-toc-h6 {
    margin-left: 6rem;
    font-size: .75rem;
}
 
.md-toc-h2:before {
    color: black;
    counter-increment: h2toc;
    content: counter(h2toc) ". "
}
 
.md-toc-h2 .md-toc-inner {
    margin-left: 0;
}
 
.md-toc-h3:before {
    color: black;
    counter-increment: h3toc;
    content: counter(h2toc) ". " counter(h3toc) ". "
}
 
.md-toc-h3 .md-toc-inner {
    margin-left: 0;
}
 
.md-toc-h4:before {
    color: black;
    counter-increment: h4toc;
    content: counter(h2toc) ". " counter(h3toc) ". " counter(h4toc) ". "
}
 
.md-toc-h4 .md-toc-inner {
    margin-left: 0;
}
 
.md-toc-h5:before {
    color: black;
    counter-increment: h5toc;
    content: counter(h2toc) ". " counter(h3toc) ". " counter(h4toc) ". " counter(h5toc) ". "
}
 
.md-toc-h5 .md-toc-inner {
    margin-left: 0;
}
 
.md-toc-h6:before {
    color: black;
    counter-increment: h6toc;
    content: counter(h2toc) ". " counter(h3toc) ". " counter(h4toc) ". " counter(h5toc) ". " counter(h6toc) ". "
}
 
.md-toc-h6 .md-toc-inner {
    margin-left: 0;
} 

侧边栏大纲自动编号:


.outline-h1 {
    counter-reset: h2
}
 
.outline-h2 {
    counter-reset: h3
}
 
.outline-h3 {
    counter-reset: h4
}
 
.outline-h4 {
    counter-reset: h5
}
 
.outline-h5 {
    counter-reset: h6
}
 
.outline-h2>.outline-item>.outline-label:before {
    counter-increment: h2;
    content: counter(h2) ". "
}
 
.outline-h3>.outline-item>.outline-label:before {
    counter-increment: h3;
    content: counter(h2) "." counter(h3) ". "
}
 
.outline-h4>.outline-item>.outline-label:before {
    counter-increment: h4;
    content: counter(h2) "." counter(h3) "." counter(h4) ". "
}
 
.outline-h5>.outline-item>.outline-label:before {
    counter-increment: h5;
    content: counter(h2) "." counter(h3) "." counter(h4) "." counter(h5) ". "
}
 
.outline-h6>.outline-item>.outline-label:before {
    counter-increment: h6;
    content: counter(h2) "." counter(h3) "." counter(h4) "." counter(h5) "." counter(h6) ". "
}

效果图

在这里插入图片描述

到此这篇关于Typora自动编号的文章就介绍到这了,更多相关Typora自动编号内容请搜索编程网以前的文章或继续浏览下面的相关文章希望大家以后多多支持编程网!

--结束END--

本文标题: Typora自动编号的具体操作

本文链接: https://www.lsjlt.com/news/159275.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

本篇文章演示代码以及资料文档资料下载

下载Word文档到电脑,方便收藏和打印~

下载Word文档
猜你喜欢
  • Typora自动编号的具体操作
    概述 在使用Typora写比较长的文章时,需要给章节编号,方便区分层次。如果手动编号,一旦章节顺序改变,很多章节的编号都需要一一手动修改,极其麻烦。 Typora官方提供了自动编号的...
    99+
    2022-11-12
  • Typora自动编号的具体操作是怎样的
    这期内容当中小编将会给大家带来有关Typora自动编号的具体操作是怎样的,文章内容丰富且以专业的角度为大家分析和叙述,阅读完这篇文章希望大家可以有所收获。概述在使用Typora写比较长的文章时,需要给章节编号,方便区分层次。如果手动编号,一...
    99+
    2023-06-21
  • python实现一般游戏的自动点击具体操作
    需要的软件: pycharm(pycharm安装步骤) 沙盒软件,例如:sandbox(百度搜索自行安装,如有需要可留言),360隔离沙盒 你的游戏 具体...
    99+
    2022-11-12
  • 使用shell脚本自动备份MySQL数据库的具体操作
    不知道大家之前对类似使用shell脚本自动备份MySQL数据库的具体操作的文章有无了解,今天我在这里给大家再简单的讲讲。感兴趣的话就一起来看看正文部分吧,相信看完使用shell脚本自动备份MySQL数据库的...
    99+
    2022-10-18
  • Win8如何管理自动登录的凭据具体该怎么操作
      我用的是Win8系统,现在我想管理自动登录的凭据,请问怎么在Windows 8中管理自动登录的凭据   Win8管理自动登录的凭据的方法如下:   1、鼠标移到屏幕右下角,右方会出现如图所示选项。   2、点击&l...
    99+
    2023-06-06
    Win8 自动登录 凭据
  • C++实现WPF动画的具体操作方法
    本篇文章为大家展示了C++实现WPF动画的具体操作方法,内容简明扼要并且容易理解,绝对能使你眼前一亮,通过这篇文章的详细介绍希望你能有所收获。C++编程语言的应方式非常广泛,可以帮助我们轻松的实现许多功能需求。很多人都习惯使用Blend来帮...
    99+
    2023-06-17
  • 解决Java启动qq的具体操作步骤
    要使用Java启动QQ,您需要按照以下步骤进行操作:1. 下载并安装Java Development Kit (JDK):您可以从O...
    99+
    2023-08-23
    Java
  • 编译Python正则表达式的具体操作方法
    这期内容当中小编将会给大家带来有关编译Python正则表达式的具体操作方法,文章内容丰富且以专业的角度为大家分析和叙述,阅读完这篇文章希望大家可以有所收获。现在我们已经看了一些简单的正则表达式,那么我Python正则表达式在实际应用中如何使...
    99+
    2023-06-17
  • pytorch 实现变分自动编码器的操作
    本来以为自动编码器是很简单的东西,但是也是看了好多资料仍然不太懂它的原理。先把代码记录下来,有时间好好研究。 这个例子是用MNIST数据集生成为例子 # -*- coding: ...
    99+
    2022-11-12
  • windows系统中实现磁盘满额自动邮件报警的具体思路及操作步骤是怎样的
    windows系统中实现磁盘满额自动邮件报警的具体思路及操作步骤是怎样的,相信很多没有经验的人对此束手无策,为此本文总结了问题出现的原因和解决方法,通过这篇文章希望你能解决这个问题。  Windows系统下,如果出现在软件中的磁盘满了,那么...
    99+
    2023-06-14
  • Python编程的简易版自动化工具ADB的工作原理以及用法
    本篇文章为大家展示了Python编程的简易版自动化工具ADB的工作原理以及用法,内容简明扼要并且容易理解,绝对能使你眼前一亮,通过这篇文章的详细介绍希望你能有所收获。前言ADB,中文名安卓调试桥,它是一种功能多样的命令行工具,可用于执行各种...
    99+
    2023-06-15
  • Win10系统下设置自动宽带连接/拨号上网的操作步骤图文详解
      绝大部分家庭电脑用户都是采用“宽带连接”方式来连接网络的,当我们电脑在开机后需要手动选择“宽带连接”登录才能连接网络,但很多用户都觉得开机选择这样的拨号上网也会显得麻烦...
    99+
    2023-06-13
    宽带连接 拨号上网 宽带 系统 操作步骤 图文
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作