Warm tip: This article is reproduced from serverfault.com, please click

r-RMarkdown。

(r - RMarkdown. How to reduce space between title block and start of body text)

发布于 2020-01-08 07:04:52

我一直在Mac上通过RStudio成功使用RMarkdown。

最近升级到RStudio 1.2.5019和tinytex_0.18,现在我的“标题栏”和“第一个正文/标题”之间的垂直间距增加了。

一个简单的示例(故意排除author:date:)是:

---
output: 
  pdf_document
title: "Example of Title to Body Text"
subtitle: Subtitle Places Here
---
This is the first paragraph (or heading if specified as such). It is quite a way down from the title of the document. How can this be reduced to a "single line" vertical space?

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt.

然后,我尝试使用“ titlesec”包,但无法确定要使用哪个命令来实现所需的结果。尝试的示例是:

---
output: 
  pdf_document

subparagraph: yes
header-includes: |
  \usepackage{titlesec}
  \titlespacing{\title}{0pt}{\parskip}{-\parskip}

title: "Example of Title to Body Text"
subtitle: Subtitle Places Here
---
This is the first paragraph (or heading if specified as such). It is quite a way down from the title of the document. How can this be reduced to a "single line" vertical space?

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt.

这就是当前呈现为PDF的外观。

电流输出

这就是我希望PDF看起来更像的东西(从图形程序编辑)。

所需的输出

那么,如何减小标题栏和文档正文开头之间的垂直间距?

提前致谢。

Questioner
paulr
Viewed
1
Carlos Luis Rivera 2020-01-10 22:15:00

你可以通过\vspace{}在第一段之前添加来自LaTeX的命令来减少(副标题)与第一段之间的间隔

---
output: 
  pdf_document

subparagraph: yes
header-includes: |
  \usepackage{titlesec}
  \titlespacing{\title}{0pt}{\parskip}{-\parskip}

title: "Example of Title to Body Text"
subtitle: Subtitle Places Here
---

\vspace{-5truemm}


This is the first paragraph (or heading if specified as such). It is quite a way down from the title of the document. How can this be reduced to a "single line" vertical space?

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt.