Typora设置标题自动标号

Typora由于默认标题无法自动标号,每次编辑时需要手动处理。为实现标题自动编号,需要进行相关操作。

一 官方说明

在这里插入图片描述

To achieve this, add the following to your base.user.css or [theme].user.css in the theme folder.

/** 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;
}

4.1、Auto-Numbering in TOC
If you want TOC entities to be displayed auto-numbered, you could try http://pastebin.com/NYugSbXk posted by a Typora user.
 

/**************************************
 * Header Counters in TOC
 **************************************/

/* No link underlines in TOC */
.md-toc-inner {
    text-decoration: none;
}

.md-toc-content {
    counter-reset: h1toc
}

.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-h1:before {
    color: black;
    counter-increment: h1toc;
    content: counter(h1toc) ". "
}

.md-toc-h1 .md-toc-inner {
    margin-left: 0;
}

.md-toc-h2:before {
    color: black;
    counter-increment: h2toc;
    content: counter(h1toc) ". " counter(h2toc) ". "
}

.md-toc-h2 .md-toc-inner {
    margin-left: 0;
}

.md-toc-h3:before {
    color: black;
    counter-increment: h3toc;
    content: counter(h1toc) ". " counter(h2toc) ". " counter(h3toc) ". "
}

.md-toc-h3 .md-toc-inner {
    margin-left: 0;
}

.md-toc-h4:before {
    color: black;
    counter-increment: h4toc;
    content: counter(h1toc) ". " 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(h1toc) ". " 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(h1toc) ". " counter(h2toc) ". " counter(h3toc) ". " counter(h4toc) ". " counter(h5toc) ". " counter(h6toc) ". "
}

.md-toc-h6 .md-toc-inner {
    margin-left: 0;
}

/**************************************
 * Header Counters in Content
 **************************************/

/** 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;
}

4.2、Auto-Numbering Outline panel
To show auto-numbering in Typora’s Outline panel, disable the collapsable outline panel in the preferences panel and then try https://pastebin.com/XmYgBbaz.
 

.sidebar-content {
    counter-reset: h1
}

.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-h1>.outline-item>.outline-label:before {
    counter-increment: h1;
    content: counter(h1) ". "
}

.outline-h2>.outline-item>.outline-label:before {
    counter-increment: h2;
    content: counter(h1) "." counter(h2) ". "
}

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

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

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

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

二 具体操作

1 打开主题文件夹

打开typora,先点击“文件”,再点击“偏好设置”,再点击“外观”,最后点击“打开主题文件”来到如下界面。

 

 2 修改主题文件

  • 在此路径下新建“base.user.css”,将上面三份代码复制到到文档里面,保存后退出。

3 重启Typora

三 注意

1. 开始编号标题必须是一级标题格式。否则编号出错

2. 有几个数字代表几级标题。如1.代表一级标题。1.1.1代表三级标题

3. 设置为标题格式后输入内容即可对标题编辑

参考链接

1. typora设置标题自动编号_落花逐流水的博客-优快云博客_typora标题自动编号

2. 设置typora标题、目录、大纲自动编号_MTpanda酉生的博客-优快云博客_typora标题自动编号

<think>好的,用户的问题是如何创建文档或生成文档的步骤,需要我根据要求进行网络搜索并生成答案。首先,我需要理解用户的意图。用户可能想了解从零开始创建文档的基本步骤,或者是使用特定工具生成文档的方法,比如Microsoft Word、Google Docs、Markdown工具等。用户可能是一个需要编写文档的职场新人、学生,或者开发者需要技术文档指导。 接下来,我需要确定用户的具体需求。问题中提到“创建或生成文档”,这可能包括不同的场景,比如文本文档、技术文档、自动化生成等。考虑到用户可能没有明确指定工具,我应该涵盖多种常见方法,确保答案具有普适性和实用性。同时,用户可能需要步骤化的指导,所以需要分点说明,避免使用第一人称和步骤词汇如“首先”、“然后”。 根据要求,需要调用网络搜索工具检索相关信息。我需要查找创建文档的通用步骤,以及不同工具的特定方法。例如,使用办公软件如Word或Google Docs的基本流程,使用Markdown编写文档并转换为其他格式,以及自动化生成文档的工具如Sphinx、Docusaurus等。还需要检查是否有关于API文档生成工具如Swagger或Javadoc的信息,因为这些可能对开发者用户有帮助。 整合信息时,要确保结构清晰,分多个方法或步骤,每个部分换行。例如,可以分为使用办公软件、Markdown工具、自动化工具等不同方法。每个方法下再分步骤,比如准备内容、选择工具、编辑排版、保存分享等。同时,要注意格式要求,如代码块和公式的格式,但用户的问题可能不涉及代码或公式,所以这部分可能较少。 需要避免引用集中在末尾,所以每个步骤中的关键点需要直接融入内容中。例如,在说明使用Markdown时,可以内联示例代码,并用代码块展示Markdown语法。同时,要检查是否满足每个步骤间的换行,不使用有序列表的编号,而是用项目符号或标题。 生成相关问题部分时,要基于用户的原问题和回答内容。例如,用户询问创建文档的步骤,相关问题可能涉及如何高效编辑、协作工具推荐、自动化生成技术文档的方法等。需要确保至少三个相关问题,并且格式正确,使用“§§相关问题§§:”作为标题,每个问题用数字标号。 最后,验证整个回答是否符合所有要求:没有第一人称,步骤词汇,正确格式,相关问题部分正确等。确保信息准确,覆盖不同用户可能的需求,如普通用户和开发者,提供多种方法,实用且可操作。</think>### 如何创建或生成文档的详细方法 --- #### 方法一:使用办公软件创建标准文档(以Microsoft Word为例) **工具准备** - 安装Microsoft Office或使用在线版Word - 明确文档类型(报告、合同、简历等) **内容编排** 打开Word后选择空白文档或模板,通过以下功能区操作: - **文字编辑**:在光标处直接输入内容 - **格式调整**:使用“开始”选项卡调整字体、段落样式 - **插入元素**:通过“插入”选项卡添加表格、图片、页眉页脚 - **自动保存**:开启“文件 > 选项 > 保存”中的自动保存功能 **输出文档** 完成编辑后执行: ```bash Ctrl+S # 本地保存 文件 > 导出 > 创建PDF/XPS # 生成不可编辑版本 ``` --- #### 方法二:使用Markdown生成结构化文档 **语法基础** ```markdown # 标题 - 列表项 **加粗文本** [链接文字](URL) ``` **工具链配置** 1. 安装VS Code或Typora编辑器 2. 创建`.md`文件并编写内容 3. 使用Pandoc转换格式: ```bash pandoc input.md -o output.docx # 转Word pandoc input.md -o output.pdf --pdf-engine=xelatex # 转PDF ``` **自动化扩展** - 集成Git版本控制 - 使用MkDocs生成静态网站文档: ```yaml # mkdocs.yml示例 site_name: 项目文档 nav: - 首页: index.md - 配置指南: configuration.md ``` --- #### 方法三:通过代码自动生成技术文档 **API文档生成(以Swagger为例)** 1. 在代码中添加注解: ```java @ApiOperation(value = "获取用户信息") public User getUser(@ApiParam("用户ID") String id) { ... } ``` 2. 使用Swagger UI渲染: ```bash mvn springfox-boot:run # SpringBoot项目启动后访问/swagger-ui ``` **数据库文档生成** - 使用SchemaSpy分析数据库结构: ```bash java -jar schemaspy.jar -t mysql -db mydb -u root -p 1234 -o ./docs ``` --- #### 方法四:云端协作文档生成 **Google Docs实时协作** 1. 访问`docs.google.com`新建文档 2. 点击“分享”按钮设置协作权限 3. 使用“版本历史”追踪修改记录 **Notion模板化生成** - 选择知识库/项目计划模板 - 通过`/`命令快速插入数据库、看板等组件 --- ### 文档质量优化建议 **排版规范** - 使用$1.5\times$行距提升可读性 - 图片添加`图1: 架构图`格式的题注 **版本控制** - 文件名添加日期标识:`项目报告_20230820_v2.docx` - 使用Git管理Markdown文档变更历史 ---
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值