我正在使用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)之间的空间。
非常感谢!
答案 0 :(得分:1)
如TeXSO中所述,您可以使用以下软件包:
\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{}
之前的# Introduction
会改变间距
在第一部分(此处是简介)之间
标题的最后一行(补充材料)。
因此,\vspace{}
与
标题和目录之间的空格。