RMarkdown似乎无法在标签中生成标签

时间:2018-03-14 11:16:18

标签: r markdown r-markdown

我正在尝试使用RMarkdown制作静态网页。我想定义一个UI,它有第一层标签,然后是第一层下面的标签。我已经在RMarkdown: Tabbed and Untabbed headings处查询了类似的问题。但这个答案对我的事业没有帮助。请在下面找到我想要实现的标签结构。

| Results
* Discussion of Results

           | Quarterly Results
           * This content pertains to Quarterly Results

                      | By Product
                      * Quarterly Performance by Products

                      | By Region
                      * Quarterly Performance by Region

* Final Words about Quarterly Results

           | Yearly Results
           * This content pertains to Yearly Results

                      | By Product
                      * Yearly Performance by Products

                      | By Region
                      * Yearly Performance by Region

* Final Words about Yearly Results

这是我正在使用的.Rmd格式的脚本。但我能够实现的输出看起来像Current Scenario。我希望{Region}选项卡以外的Final Words about Quarterly ResultsFinal Words about Yearly Results分别位于季度结果和年度结果中。

---
output:
  html_document:
    theme: paper
    highlight: tango
    number_sections: false
    toc: false
    toc_float: false
---
# Result Discussion {.tabset}
We will discuss results here

## Quarterly Results {.tabset}
This content pertains to Quarterly Results

### By Product

Quarterly perfomance by Products

### By Region

Quarterly perfomance by Region


Final Words about Quarterly Results

## Yearly Results {.tabset}
This content pertains to Yearly Results

### By Product

Yearly perfomance by Products

### By Region

Yearly perfomance by Region

Final Words about Yearly Results

2 个答案:

答案 0 :(得分:1)

问题来自于最后一段(Final Words about Quarterly ResultsFinal Words about Yearly Results)属于最后一级3部分,而不属于父级别2部分。
您必须手动控制渲染的HTML的切片以获得所需的内容。

使用 pandoc< 2.0 ,唯一的意思是插入原始HTML

---
output:
  html_document:
    theme: paper
    highlight: tango
    number_sections: false
    toc: false
    toc_float: false
---
# Result Discussion {.tabset}
We will discuss results here

## Quarterly Results {.tabset}
This content pertains to Quarterly Results

<div id="quarterly-product" class="section level3">
### By Product

Quarterly perfomance by Products
</div>

<div id="quarterly-region" class="section level3">
### By Region

Quarterly perfomance by Region
</div>

Final Words about Quarterly Results


## Yearly Results {.tabset}
This content pertains to Yearly Results

<div id="yearly-product" class="section level3">
### By Product

Yearly perfomance by Products
</div>

<div id="yearly-region" class="section level3">
### By Region

Yearly perfomance by Region
</div>

Final Words about Yearly Results

如果您使用 pandoc 2.0或更高版本,则可以使用fenced divs

---
output:
  html_document:
    theme: paper
    highlight: tango
    number_sections: false
    toc: false
    toc_float: false
---
# Result Discussion {.tabset}
We will discuss results here

## Quarterly Results {.tabset}
This content pertains to Quarterly Results

::: {#quarterly-product .section .level3}
### By Product

Quarterly perfomance by Products
:::

::: {#quarterly-region .section .level3}
### By Region

Quarterly perfomance by Region
:::

Final Words about Quarterly Results


## Yearly Results {.tabset}
This content pertains to Yearly Results

::: {#yearly-product .section .level3}
### By Product

Yearly perfomance by Products
:::

::: {#yearly-region .section .level3}
### By Region

Yearly perfomance by Region
:::

Final Words about Yearly Results

答案 1 :(得分:0)

你是说这个意思吗? :

output:
  html_document:
    theme: paper
    highlight: tango
    number_sections: false
    toc: false
    toc_float: false
---
# Result Discussion {.tabset}
We will discuss results here

## Quarterly Results {.tabset}
This content pertains to Quarterly Results

### By Product

Quarterly perfomance by Products

### By Region

Quarterly perfomance by Region


##
Final Words about Quarterly Results

## Yearly Results {.tabset}
This content pertains to Yearly Results

### By Product

Yearly perfomance by Products

### By Region

Yearly perfomance by Region

##
Final Words about Yearly Results