您好,登錄后才能下訂單哦!
這期內容當中小編將會給大家帶來有關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。
官方提供的代碼會對一級標題進行編號,但實際寫文章時,一級標題往往是文章標題,無需編號,因此,我對代碼進行了簡單修改。下面是修改后的代碼:
文章內容自動編號:
/** initialize css counter */ h2 { counter-reset: h3 } h3 { counter-reset: h4 } h4 { counter-reset: h5 } h5 { counter-reset: h6 } h6 { counter-reset: h7 } /** put counter result into headings */ #write h3:before { counter-increment: h3; content: counter(h3) ". " } #write h4:before, h4.md-focus.md-heading:before /** override the default style for focused headings */ { counter-increment: h4; content: counter(h3) "." counter(h4) ". " } #write h5:before, h5.md-focus.md-heading:before { counter-increment: h5; content: counter(h3) "." counter(h4) "." counter(h5) ". " } #write h6:before, h6.md-focus.md-heading:before { counter-increment: h6; content: counter(h3) "." counter(h4) "." counter(h5) "." counter(h6) ". " } #write h7:before, h7.md-focus.md-heading:before { counter-increment: h7; content: counter(h3) "." counter(h4) "." counter(h5) "." counter(h6) "." counter(h7) ". " } /** override the default style for focused headings */ #write>h4.md-focus:before, #write>h5.md-focus:before, #write>h6.md-focus:before, #write>h7.md-focus:before, h4.md-focus:before, h5.md-focus:before, h6.md-focus:before, h7.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自動編號:
/* No link underlines in TOC */ .md-toc-inner { text-decoration: none; } .md-toc-h2 { margin-left: 0; font-size: 1.5rem; counter-reset: h3toc } .md-toc-h3 { font-size: 1.1rem; margin-left: 2rem; counter-reset: h4toc } .md-toc-h4 { margin-left: 3rem; font-size: .9rem; counter-reset: h5toc } .md-toc-h5 { margin-left: 4rem; font-size: .85rem; counter-reset: h6toc } .md-toc-h6 { margin-left: 5rem; font-size: .8rem; counter-reset: h7toc } .md-toc-h7 { margin-left: 6rem; font-size: .75rem; } .md-toc-h3:before { color: black; counter-increment: h3toc; content: counter(h3toc) ". " } .md-toc-h3 .md-toc-inner { margin-left: 0; } .md-toc-h4:before { color: black; counter-increment: h4toc; content: counter(h3toc) ". " counter(h4toc) ". " } .md-toc-h4 .md-toc-inner { margin-left: 0; } .md-toc-h5:before { color: black; counter-increment: h5toc; content: 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(h3toc) ". " counter(h4toc) ". " counter(h5toc) ". " counter(h6toc) ". " } .md-toc-h6 .md-toc-inner { margin-left: 0; } .md-toc-h7:before { color: black; counter-increment: h7toc; content: counter(h3toc) ". " counter(h4toc) ". " counter(h5toc) ". " counter(h6toc) ". " counter(h7toc) ". " } .md-toc-h7 .md-toc-inner { margin-left: 0; }
側邊欄大綱自動編號:
.outline-h2 { counter-reset: h3 } .outline-h3 { counter-reset: h4 } .outline-h4 { counter-reset: h5 } .outline-h5 { counter-reset: h6 } .outline-h6 { counter-reset: h7 } .outline-h3>.outline-item>.outline-label:before { counter-increment: h3; content: counter(h3) ". " } .outline-h4>.outline-item>.outline-label:before { counter-increment: h4; content: counter(h3) "." counter(h4) ". " } .outline-h5>.outline-item>.outline-label:before { counter-increment: h5; content: counter(h3) "." counter(h4) "." counter(h5) ". " } .outline-h6>.outline-item>.outline-label:before { counter-increment: h6; content: counter(h3) "." counter(h4) "." counter(h5) "." counter(h6) ". " } .outline-h7>.outline-item>.outline-label:before { counter-increment: h7; content: counter(h3) "." counter(h4) "." counter(h5) "." counter(h6) "." counter(h7) ". " }
效果圖
上述就是小編為大家分享的Typora自動編號的具體操作是怎樣的了,如果剛好有類似的疑惑,不妨參照上述分析進行理解。如果想知道更多相關知識,歡迎關注億速云行業資訊頻道。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。