R markdown 如何减少Rmarkdown pdf_输出中标题和内容之间的空间

R markdown 如何减少Rmarkdown pdf_输出中标题和内容之间的空间,r-markdown,R Markdown,我正在使用Rmarkdown输出pdf文件。代码如下: --- title: | | This is title | | \vspace{-5truemm}Supplementary Material\vspace{-5truemm} author: 'xxx^[Correspondence to: xxx. Email: xxx]' geometry: margin=0.3in fontfamily: mathpazo fontsize: 11pt documentclass: a

我正在使用Rmarkdown输出pdf文件。代码如下:

---
title: |
  | This is title
  |
  | \vspace{-5truemm}Supplementary Material\vspace{-5truemm}
author: 'xxx^[Correspondence to: xxx. Email: xxx]'
geometry: margin=0.3in
fontfamily: mathpazo
fontsize: 11pt
documentclass: article
urlcolor: blue
output: 
  pdf_document:
    toc: true
    toc_depth: 4
    number_sections: yes
subparagraph: yes
header-includes: |
  \usepackage{titlesec}
  \titlespacing{\title}{0pt}{\parskip}{-\parskip}
---

\vspace{-5truemm}

# Introduction
This is introduction...

# Installation
This is installation...

## test1

### subtest1
我想知道如何减少标题(补充材料)和内容(不是正文,因为我将toc设置为true)之间的空间

非常感谢

如中所述,您可以使用以下软件包:

\usepackage{tocloft}
\setlength{\cftbeforetoctitleskip}{-\baselineskip}
所以,完整的例子是这样的

---
title: |
  | This is title
  |
  | \vspace{-5truemm}Supplementary Material\vspace{-5truemm}
author: 'xxx^[Correspondence to: xxx. Email: xxx]'
geometry: margin=0.3in
fontfamily: mathpazo
fontsize: 11pt
documentclass: article
urlcolor: blue
output: 
  pdf_document:
    toc: true
    toc_depth: 4
    number_sections: yes
subparagraph: yes
header-includes: |
  \usepackage{titlesec}
  \titlespacing{\title}{0pt}{\parskip}{-\parskip}
  \usepackage{tocloft}
  \setlength{\cftbeforetoctitleskip}{-\baselineskip}
---

<!-- 
The following \vspace{} changes the spacing 
between the first section ("Introduction" here)
and the last line of the title ("Supplementary Material")
-->
\vspace{-5truemm}

# Introduction
This is introduction...

# Installation
This is installation...

## test1

### subtest1
---
标题:|
|这是标题
|
|\vspace{-5truemm}补充资料\vspace{-5truemm}
作者:'xxx^[通信地址:xxx.电子邮件:xxx]'
几何图形:边距=0.3英寸
家庭:mathpazo
字体大小:11磅
文档类:文章
颜色:蓝色
输出:
pdf\U文件:
toc:没错
toc_深度:4
部分数量:是
分段:是
标题包括:|
\usepackage{titlesec}
\标题空间{\title}{0pt}{\parskip}{-\parskip}
\使用包{tocloft}
\setlength{\cftbeforetoctitleskip}{-\baselineskip}
---
\vspace{-5truemm}
#导言
这是导言。。。
#装置
这是安装。。。
##测试1
###子测验1
请注意,
\vspace{}
前面的
#引言
会更改间距 在第一部分之间(此处介绍) 标题的最后一行(补充材料)。 因此,
\vspace{}

标题和目录之间的空间。

完美!非常感谢你!很高兴听到你的成功!如果这个解决方案是值得的,别忘了投票,哈哈