r-markdown - rmarkdown 包括目录
问题描述
我正在写作rmarkdown
并正在导出到odt
和到html
. 我可以在 generatedhtml
中获得一个 TOC,我可以在 generated 中获得一个 TOC odt
,但是我不能同时在两者中获得一个 TOC,因为代码似乎是互斥的。
如何Rmd
在两者中从同一个文件生成 TOCodt
和html
?
这是我获取 TOC 的方法odt
:
---
title: Test TOC
toc: yes
toc-title: TOC
output:
odt_document:
keep_md: true
html_document:
number_sections: true
---
# Just a test document
With some text
这是我获取 TOC 的方法html
:
---
title: Test TOC
output:
odt_document:
keep_md: true
html_document:
toc: yes
toc-title: TOC
number_sections: true
---
# Just a test document
With some text
如果我将两者结合起来,我会在html
.
我正在使用rmarkdown 1.12
和pandoc-2.7.3
解决方案
在此处发布解决方法。但我仍然对更好的答案感兴趣。
作为一种解决方法,我在模板中重命名为toc
asodt-toc
和toc-title
as 。odt-toc-title
odt
更详细地说,我使用这个Rmd
文件:
---
title: Test TOC
odt-toc: yes
odt-toc-title: TOC
output:
odt_document:
keep_md: true
html_document:
toc: yes
toc-title: TOC
number_sections: true
---
# Just a test document
With some text
使用我已替换的默认 odt 模板的修改版本
$if(toc)$
经过
$if(odt-toc)$
和
<text:index-title-template text:style-name="Contents_20_Heading">$toc-title$</text:index-title-template>
经过
<text:index-title-template text:style-name="Contents_20_Heading">$odt-toc-title$</text:index-title-template>
推荐阅读
- tensorflow - 使用 Bazel 运行时,我应该在哪里保存 Tensorflow 的 .pb 图?
- visual-studio - Azure VM 中的 Visual Studio 2017 - 不是更改 IE 安全区的方法
- c# - 字符串到char数组c#导致错误
- django - 弹性beantalk上的Python27 Django应用程序部署“ImportError:不支持按文件名导入”
- django - Django表单集:在保存表单/数据之前分配值
- python - Facebook 需要 v3.0 API
- ruby-on-rails - Rails在自定义删除方法中删除依赖记录
- android - 通过消息发送丢弃的 pin
- wordpress - 两个 WordPress 网站的媒体文件夹相同吗?
- javascript - Javascript regex:有没有办法在带有前缀和后缀的字符串中检索字符串?