使用 Rmarkdown(pagedown)并更改 Table 的内容
Using Rmarkdown (pagedown) and changing Table of Contents
大家好,我正在尝试解决这个问题,但我无路可走:
这是我的代码:
---
title: "A Multi-page HTML Document"
author: "Yihui Xie and Romain Lesur"
date: "`r Sys.Date()`"
output:
pagedown::html_paged:
toc: true
toc_depth: 3
# change to true for a self-contained document, but it'll be a litte slower for Pandoc to render
self_contained: false
---
# Exercise 1{-}
<div style="width: 100%; height: 20px; border-bottom: 1px solid black; text-align: center">
<span style="font-size: 40px; background-color: white; padding: 0 10px;">
Exercicio 1 <!--Padding is optional-->
</span>
</div>
我想维护内容结构的Table。换句话说,我想单击 "Exercise 1",它会将我带到练习一的页面。 但是我希望Header是下面这个自定义的header(我想点击"Exercise 1" e只看到下面这个Exercise 1样式):
<div style="width: 100%; height: 20px; border-bottom: 1px solid black; text-align: center">
<span style="font-size: 40px; background-color: white; padding: 0 10px;">
Exercicio 1 <!--Padding is optional-->
</span>
</div>
我清楚了吗?
例如,如果我这样做:
# {-}
<div style="width: 100%; height: 20px; border-bottom: 1px solid black; text-align: center">
<span style="font-size: 40px; background-color: white; padding: 0 10px;">
Exercicio 1 <!--Padding is optional-->
</span>
</div>
我的目录中的 "Exercise 1 " 这个词消失了。
非常感谢你的帮助
劳拉
内容的 table 由 Pandoc 自动构建:其条目与章节标题严格对应。这就是为什么在最后一个示例(带有 # {-}
的示例)中,单词 "Exercise 1" 在 TOC 中消失了。
有很多方法可以实现您的目标。根据您的示例,最直接的可能是使用 CSS.
记住这个降价行
# Exercise 1{-}
指向此 HTML 片段
<div id="exercise-1" class="section level1 unnumbered">
<h1>Exercise 1</h1>
...
</div>
您可以使用以下 CSS 声明隐藏 h1
内容:
h1 {
display: none;
}
对于这么小的 CSS,您可以在 Rmd
文件中使用 knitr
CSS 引擎:
---
title: "A Multi-page HTML Document"
author: "Yihui Xie and Romain Lesur"
date: "`r Sys.Date()`"
output:
pagedown::html_paged:
toc: true
toc_depth: 3
# change to true for a self-contained document, but it'll be a litte slower for Pandoc to render
self_contained: false
---
```{css, echo=FALSE}
h1 {
display: none;
}
```
# Exercise 1{-}
<div style="width: 100%; height: 20px; border-bottom: 1px solid black; text-align: center">
<span style="font-size: 40px; background-color: white; padding: 0 10px;">
Exercicio 1 <!--Padding is optional-->
</span>
</div>
大家好,我正在尝试解决这个问题,但我无路可走:
这是我的代码:
---
title: "A Multi-page HTML Document"
author: "Yihui Xie and Romain Lesur"
date: "`r Sys.Date()`"
output:
pagedown::html_paged:
toc: true
toc_depth: 3
# change to true for a self-contained document, but it'll be a litte slower for Pandoc to render
self_contained: false
---
# Exercise 1{-}
<div style="width: 100%; height: 20px; border-bottom: 1px solid black; text-align: center">
<span style="font-size: 40px; background-color: white; padding: 0 10px;">
Exercicio 1 <!--Padding is optional-->
</span>
</div>
我想维护内容结构的Table。换句话说,我想单击 "Exercise 1",它会将我带到练习一的页面。 但是我希望Header是下面这个自定义的header(我想点击"Exercise 1" e只看到下面这个Exercise 1样式):
<div style="width: 100%; height: 20px; border-bottom: 1px solid black; text-align: center">
<span style="font-size: 40px; background-color: white; padding: 0 10px;">
Exercicio 1 <!--Padding is optional-->
</span>
</div>
我清楚了吗?
例如,如果我这样做:
# {-}
<div style="width: 100%; height: 20px; border-bottom: 1px solid black; text-align: center">
<span style="font-size: 40px; background-color: white; padding: 0 10px;">
Exercicio 1 <!--Padding is optional-->
</span>
</div>
我的目录中的 "Exercise 1 " 这个词消失了。
非常感谢你的帮助
劳拉
内容的 table 由 Pandoc 自动构建:其条目与章节标题严格对应。这就是为什么在最后一个示例(带有 # {-}
的示例)中,单词 "Exercise 1" 在 TOC 中消失了。
有很多方法可以实现您的目标。根据您的示例,最直接的可能是使用 CSS.
记住这个降价行
# Exercise 1{-}
指向此 HTML 片段
<div id="exercise-1" class="section level1 unnumbered">
<h1>Exercise 1</h1>
...
</div>
您可以使用以下 CSS 声明隐藏 h1
内容:
h1 {
display: none;
}
对于这么小的 CSS,您可以在 Rmd
文件中使用 knitr
CSS 引擎:
---
title: "A Multi-page HTML Document"
author: "Yihui Xie and Romain Lesur"
date: "`r Sys.Date()`"
output:
pagedown::html_paged:
toc: true
toc_depth: 3
# change to true for a self-contained document, but it'll be a litte slower for Pandoc to render
self_contained: false
---
```{css, echo=FALSE}
h1 {
display: none;
}
```
# Exercise 1{-}
<div style="width: 100%; height: 20px; border-bottom: 1px solid black; text-align: center">
<span style="font-size: 40px; background-color: white; padding: 0 10px;">
Exercicio 1 <!--Padding is optional-->
</span>
</div>