是否可以删除RMarkdown .pdf中的内容标题?

时间:2017-04-20 01:02:08

标签: r latex r-markdown

我使用RStudio和RMarkdown生成报告。我现在想编辑部分文件。我的RMarkdown文件如下:

animate()

是否可以删除标题"内容"在TOC页面上?我希望在此页面上保留所有其他标题,但仅删除"内容"标题。

我知道我可以编辑"目录"通过以下行:

--
title: <center> <h1>Call Centre Report</h1> </center>
mainfont: Arial
output:
  pdf_document:
    latex_engine: xelatex
sansfont: Arial
fig_crop: false
toc: true
classoption: landscape
fontsize: 14pt
geometry: margin=0.5in
header-includes:
- \usepackage{booktabs}
---
<style>
  .main-container {
    max-width: 1200px !important;
  }
</style>

```{r global_options, R.options=knitr::opts_chunk$set(warning=FALSE, message=FALSE)}
```
\newpage
# Iris 
```{r fig.width=18, fig.height=7, echo=FALSE, comment=" "}
library(ggplot2)
ggplot(data = iris, aes(x = Sepal.Length, y = Sepal.Width, colour = Species)) +
   geom_point() +
   theme_classic()
```
<br>
<br>
```{r, echo=FALSE, results='asis'}
library(knitr)
library(xtable)

t1 <- kable(subset(iris, Sepal.Length=="5.1", select = Petal.Length:Species),
            format = "latex", booktabs = TRUE, row.names = FALSE)
t2 <- kable(subset(chickwts, feed=="horsebean", select = weight:feed), 
            format = "latex", booktabs = TRUE, row.names = FALSE)
t3 <- kable(subset(mtcars, gear=="4", select = disp:wt), 
            format = "latex", booktabs = TRUE, row.names = FALSE, digits=2)

cat(c("\\begin{table}[!htb]
    \\begin{minipage}{.35\\linewidth}
      \\centering",
        t1,
    "\\end{minipage}%
    \\begin{minipage}{.35\\linewidth}
      \\centering",
        t2,
    "\\end{minipage}%
    \\begin{minipage}{.35\\linewidth}
      \\centering",
        t3,
    "\\end{minipage} 
\\end{table}"
)) 
```

但只是将其留空(下方),仍占用空间:

- \renewcommand{\contentsname}{Some Text Here}

2 个答案:

答案 0 :(得分:2)

我试图解决一个类似的问题,以及其他一些问题。使用评论,我最终得到了下面的代码。目录现在可以放在任何地方,没有“目录”字样,也没有空格。

---
output:
  pdf_document:
    fig_caption: true
    number_sections: true
header-includes:
    - \renewcommand{\contentsname}{}

title: Title Name
author: Author Name
---

Some text 

Some more text 

\vspace{-1cm}
\tableofcontents

# Section Name 

Some more text 

\newpage

# Section 2 Name 

## Subsection 2.1

答案 1 :(得分:-2)

您可以尝试删除YAML元数据中的行toc:true。它适用于我的案例。