Уменьшить поля заголовков при создании PDF из Rmarkdown с использованием knitr - PullRequest
1 голос
/ 21 января 2020

Я создаю PDF-документ, используя knitr + Rmarkdown. Я установил geometry: margin=0.1in в заголовке yaml. Это поле применяется к основному тексту документа, но заголовок довольно далеко от верхней части документа, как и основной текст. Вот скриншот:

enter image description here

Вот код Rmd, который создал документ на скриншоте:

---
title: "test"
output: 
  pdf_document:
    latex_engine: xelatex
geometry: margin=0.1in
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
```

a bunch of text to demonstrate that the margin applies only to the body text of
this document, while the title (above) remains quite far from the top of the
document, and this is messing up my plan to make a document that's only one page
in length

Мне нужен этот документ быть одной страницы в длину. Огромные поля названия портят это. Как уменьшить пробел между заголовком, верхней частью документа и основным текстом?

Примечание. По причинам, я могу использовать только латексный движок xelatex здесь .

1 Ответ

2 голосов
/ 21 января 2020

Используя код LaTeX, вы можете:

  • уменьшить расстояние между заголовком и текстом с помощью \vspace{-1cm}

  • уменьшить верх поле с тем же кодом, помещенным в title в YAML

Вот ваш пример:

---
title: \vspace{-1.5cm} test
output: 
  pdf_document:
  latex_engine: xelatex
geometry: margin = 0.1in
---

\vspace{-1cm}
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
```

a bunch of text to demonstrate that the margin applies only to the body text of
this document, while the title (above) remains quite far from the top of the
document, and this is messing up my plan to make a document that's only one page in length
...