如何在r标记中自定义以字母开头的节标题
虽然我们可以通过在YAML标题中添加选项如何在r标记中自定义以字母开头的节标题,r,r-markdown,R,R Markdown,虽然我们可以通过在YAML标题中添加选项number\u sections:true来自动化数字部分,但我想知道是否可以在r markdown中更改标题样式。例如,我们可以用下面这样的字母来定制它吗 A.A节 A.1小节 A.1.1第1小节 A.1.2第1小节 B.第B节 B.1小节 B.1.1小节 回答pdf\u文档 将此行保存在外部文件中(例如,inheader.tex): 并在文档标题中插入文件,其中包含: --- title: "Lettered sections" output:
number\u sections:true
来自动化数字部分,但我想知道是否可以在r markdown
中更改标题样式。例如,我们可以用下面这样的字母来定制它吗
A.A节
A.1小节
A.1.1第1小节
A.1.2第1小节
B.第B节
B.1小节
B.1.1小节
回答pdf\u文档
将此行保存在外部文件中(例如,inheader.tex
):
并在文档标题中插入文件,其中包含:
---
title: "Lettered sections"
output:
pdf_document:
number_sections: true
includes:
in_header: inheader.tex
---
回答html\u文档
格式
tl;博士
编织此Rmd
文件:
---
title: "Lettered sections"
output: html_document
---
```{css, echo=FALSE}
.header-section-number {
display: none;
}
body {
counter-reset: counter-level-1;
}
h1:not(.title) {
counter-increment: counter-level-1;
counter-reset: counter-level-2;
}
h1:not(.title)::before{
content: counter(counter-level-1, upper-alpha) ". ";
}
h2 {
counter-increment: counter-level-2;
counter-reset: counter-level-3;
}
h2::before {
content: counter(counter-level-1, upper-alpha) "." counter(counter-level-2) " ";
}
h3 {
counter-increment: counter-level-3;
}
h3::before {
content: counter(counter-level-1, upper-alpha) "." counter(counter-level-2) "." counter(counter-level-3) " ";
}
```
# Section
## Subsection
### Sub subsection
### Sub subsection
## Subsection
# Section
## Subsection
### Sub subsection
## Subsection
解释编号节是本机的
pandoc
选项。似乎pandoc
不支持分层标题定制
因此,HTML输出有三个选项:
- 深入研究
并开发一个新的编写器,因为分层标题被声明为整数。注:为了方便标题定制,有一个李>pandoc
- 使用CSS修改HTML呈现
- 使用Javascript修改HTML元素。这对于toc:true可能是必需的
.CSS
的外部文件中,并使用此YAML标题将其包含在HTML报告中:
---
title: "Lettered sections"
output:
html_document:
css: "filename.css"
---
附加说明可以使用数字或字母以外的其他计数器,有关列表,请参阅。
您还可以使用定义自己的计数器集。输出格式是什么?@romles、html或pdf即可。对于pdf,我尝试创建一个带有定制样式的header.tex,并将其包含在YAML中,但没有效果(可能是因为我生锈的乳胶技能)。对于html,我认为定制CSS可能是可行的,但我没有html方面的经验。有什么提示吗?我有一个关于html和css的答案。我不明白为什么这个问题被否决了。@romles,也许标题不够清楚?这些很有用!感谢优雅的解决方案,尤其是使用LaTex命令!
---
title: "Lettered sections"
output:
html_document:
css: "filename.css"
---