Typora自動(dòng)編號(hào)的具體操作
概述
在使用Typora寫(xiě)比較長(zhǎng)的文章時(shí),需要給章節(jié)編號(hào),方便區(qū)分層次。如果手動(dòng)編號(hào),一旦章節(jié)順序改變,很多章節(jié)的編號(hào)都需要一一手動(dòng)修改,極其麻煩。
Typora官方提供了自動(dòng)編號(hào)的方法:https://support.typora.io/Auto-Numbering/。本文將對(duì)官方提供的方法,以及簡(jiǎn)單改進(jìn)進(jìn)行介紹。
原理
這個(gè)方法的原理是,Typora基于瀏覽器開(kāi)發(fā)(使用快捷鍵Shift+F12可以打開(kāi)開(kāi)發(fā)者工具)。因此,可以利用CSS實(shí)現(xiàn)自動(dòng)編號(hào)。
具體操作
- 打開(kāi)Typora -> 文件 -> 偏好設(shè)置 -> 外觀 -> 打開(kāi)主題文件夾。
- 在主題文件夾下新建文件
base.user.css
。 - 將https://support.typora.io/Auto-Numbering/中提供的三份代碼(分別實(shí)現(xiàn)文章內(nèi)容自動(dòng)編號(hào)、TOC自動(dòng)編號(hào)、側(cè)邊欄大綱自動(dòng)編號(hào))復(fù)制到
base.user.css
中。 - 重啟Typora。
改進(jìn)
官方提供的代碼會(huì)對(duì)一級(jí)標(biāo)題進(jìn)行編號(hào),但實(shí)際寫(xiě)文章時(shí),一級(jí)標(biāo)題往往是文章標(biāo)題,無(wú)需編號(hào),因此,我對(duì)代碼進(jìn)行了簡(jiǎn)單修改。下面是修改后的代碼:
文章內(nèi)容自動(dòng)編號(hào):
/** initialize css counter */ h1 { counter-reset: h2 } h2 { counter-reset: h3 } h3 { counter-reset: h4 } h4 { counter-reset: h5 } h5 { counter-reset: h6 } /** put counter result into headings */ #write h2:before { counter-increment: h2; content: counter(h2) ". " } #write h3:before, h3.md-focus.md-heading:before /** override the default style for focused headings */ { 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) ". " } /** override the default style for focused headings */ #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自動(dòng)編號(hào):
/* No link underlines in 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; }
側(cè)邊欄大綱自動(dòng)編號(hào):
.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) ". " }
效果圖
到此這篇關(guān)于Typora自動(dòng)編號(hào)的文章就介紹到這了,更多相關(guān)Typora自動(dòng)編號(hào)內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
DedeCMS 5.7 sp1遠(yuǎn)程文件包含漏洞(CVE-2015-4553)
這篇文章主要介紹了DedeCMS 5.7 sp1遠(yuǎn)程文件包含漏洞(CVE-2015-4553)的相關(guān)知識(shí),本文圖文并茂給大家介紹的非常詳細(xì),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2019-08-08最新Listary?v5.00.2843注冊(cè)碼?親測(cè)可用
listary是?windows?下一款可以快速搜索所有程序、文件,并且可以快速啟動(dòng)程序和打開(kāi)相應(yīng)文件的優(yōu)秀的搜索軟件,絕對(duì)比系統(tǒng)自帶搜索速度快很多,而且查詢(xún)功能豐富,本文給大家分享Listary?v5.00.2843注冊(cè)碼,感興趣的朋友一起看看吧2022-07-07詳解MD5算法的原理以及C#和JS的實(shí)現(xiàn)
MD5?是哈希算法(散列算法)的一種應(yīng)用。這篇文章主要和大家介紹一下MD5算法的原理以及C#和JS的實(shí)現(xiàn),文中的示例代碼講解詳細(xì),需要的可以參考一下2023-03-03fastjson到底做錯(cuò)了什么?為什么會(huì)被頻繁爆出漏洞?(推薦)
前段時(shí)間,fastjson被爆出過(guò)多次存在漏洞,很多文章報(bào)道了這件事兒,并且給出了升級(jí)建議。本文給大家分享fastjson的releaseNote以及部分源代碼。感興趣的朋友跟隨小編一起看看吧2020-07-07關(guān)于idea+centos7+zookeeper報(bào)錯(cuò)connectionloss,timeout問(wèn)題
這篇文章主要介紹了idea+centos7+zookeeper報(bào)錯(cuò)connectionloss,timeout問(wèn)題,本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2021-01-01互聯(lián)網(wǎng)科技大佬推薦的12本必讀書(shū)籍
12本互聯(lián)網(wǎng)科技大佬推薦的必讀書(shū)籍,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2018-03-03jenkins通過(guò)sshPut傳輸文件時(shí)報(bào)錯(cuò)Permission?denied的SftpException的問(wèn)題及解決
使用jenkins的ssh插件傳輸文件至遠(yuǎn)程機(jī)器的指定目錄,php程序打包后,經(jīng)過(guò)zip壓縮為oms.zip,這篇文章主要介紹了jenkins通過(guò)sshPut傳輸文件的時(shí)候,報(bào)錯(cuò)Permission?denied的SftpException,需要的朋友可以參考下2023-08-08IDEA出現(xiàn)java:程序包javax.servlet不存在問(wèn)題解決方法
這篇文章主要給大家介紹了關(guān)于IDEA出現(xiàn)java:程序包javax.servlet不存在問(wèn)題的解決方法,這個(gè)錯(cuò)誤提示意味著你的Java程序中缺少了javax.servlet這個(gè)包,文中通過(guò)圖文介紹的非常詳細(xì),需要的朋友可以參考下2023-11-11ISO-8859-1 、Latin-1 西歐編碼介紹及應(yīng)用
這篇文章主要介紹了ISO-8859-1 、Latin-1 西歐編碼介紹及應(yīng)用,需要的朋友可以參考下2016-06-06