我正在编写rmarkdown,并导出到odt和html。我可以在生成的html中获得一个目录,也可以在生成的odt中获得一个目录,但我不能同时在两者中获得一个目录,因为代码似乎是互斥的。
如何在odt和html中从相同的Rmd文件生成目录
下面是我在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下面是我在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
发布于 2019-08-19 16:18:21
在这里发布一个变通的方法。但我仍然对更好的答案感兴趣。
作为一种解决办法,我在odt模板中将toc重命名为odt-toc,将toc-title重命名为odt-toc-title。
更详细地说,我使用这个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用我已经替换的default odt-template的修改版本
$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>https://stackoverflow.com/questions/57552445
复制相似问题