Typora設(shè)置標(biāo)題自動(dòng)添加序號(hào)

僅供學(xué)習(xí),轉(zhuǎn)載請(qǐng)注明出處

打開(kāi)文件 - 偏好設(shè)置 - 打開(kāi)主題文件夾

設(shè)置css樣式

創(chuàng)建一個(gè)空文件,命名為base.user.css。

里面粘貼如下內(nèi)容保存后重啟Typora,輸入標(biāo)題時(shí)會(huì)自動(dòng)出現(xiàn)序號(hào)。

/** initialize css counter */
#write {
counter-reset: h1
}
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 h1:before {
counter-increment: h1;
content: counter(h1) ". "
}
#write h2:before {
counter-increment: h2;
content: counter(h1) "." counter(h2) ". "
}
#write h3:before,
h3.md-focus.md-heading:before /** override the default style for focused headings */ {
counter-increment: h3;
content: counter(h1) "." counter(h2) "." counter(h3) ". "
}
#write h4:before,
h4.md-focus.md-heading:before {
counter-increment: h4;
content: counter(h1) "." counter(h2) "." counter(h3) "." counter(h4) ". "
}
#write h5:before,
h5.md-focus.md-heading:before {
counter-increment: h5;
content: counter(h1) "." counter(h2) "." counter(h3) "." counter(h4) "." counter(h5) ". "}
#write h6:before,
h6.md-focus.md-heading:before {
counter-increment: h6;
content: counter(h1) "." 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;
}

效果如下:

另外,如果需要去除序號(hào)后面 . 號(hào)的版本

/** initialize css counter */
#write {
counter-reset: h1
}
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 h1:before {
counter-increment: h1;
content: counter(h1) " "
}#write h2:before {
counter-increment: h2;
content: counter(h1) "." counter(h2) " "
}
#write h3:before,
h3.md-focus.md-heading:before /** override the default style for focused headings */ {
counter-increment: h3;
content: counter(h1) "." counter(h2) "." counter(h3) " "
}
#write h4:before,
h4.md-focus.md-heading:before {
counter-increment: h4;
content: counter(h1) "." counter(h2) "." counter(h3) "." counter(h4) " "
}
#write h5:before,
h5.md-focus.md-heading:before {
counter-increment: h5;
content: counter(h1) "." counter(h2) "." counter(h3) "." counter(h4) "." counter(h5) " "
}
#write h6:before,
h6.md-focus.md-heading:before {
counter-increment: h6;
content: counter(h1) "." 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;
}

效果如下:

參考文獻(xiàn)

Typora設(shè)置標(biāo)題自動(dòng)添加序號(hào)


最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • 工具: 語(yǔ)言 實(shí)現(xiàn)思路通過(guò)猜測(cè)、debugserver、theos對(duì)簽名函數(shù)進(jìn)行確認(rèn)。實(shí)現(xiàn)服務(wù)端腳本,在custo...
    董二千閱讀 1,751評(píng)論 0 0
  • 在描繪18-19世紀(jì)西方戰(zhàn)爭(zhēng)的影片中,經(jīng)常會(huì)看到,兩方戰(zhàn)士,齊刷刷的站成一條直線,一方舉槍瞄準(zhǔn),聽(tīng)著軍官指令開(kāi)槍,...
    阿中2016閱讀 407評(píng)論 0 1
  • 今天,我給大家講一部電影,電影名叫《胖子行動(dòng)隊(duì)》 開(kāi)始,是一個(gè)叫郝英俊的人,在一個(gè)日本醫(yī)院講他的故事,他其實(shí)是一個(gè)...
    有點(diǎn)意思的嗬閱讀 395評(píng)論 0 2
  • 為避免有人找我撕逼,先聲明正文和現(xiàn)實(shí)毫無(wú)聯(lián)系,我只是寫(xiě)寫(xiě)《V字仇殺隊(duì)》的影評(píng)而已。影評(píng)這種事,其實(shí)和那道...
    大笑東流閱讀 343評(píng)論 0 0
  • 有一天,風(fēng)暴突然席卷我的家園,我從夢(mèng)中驚醒,看見(jiàn)我的競(jìng)爭(zhēng)對(duì)手倒在血泊中,盡管我無(wú)數(shù)次想要他失敗、無(wú)數(shù)次想看他落魄的...
    乃徹閱讀 195評(píng)論 0 1

友情鏈接更多精彩內(nèi)容