【问题标题】:Reduce top margin when creating PDF from Rmarkdown using knitr使用 knitr 从 Rmarkdown 创建 PDF 时减少上边距
【发布时间】:2020-12-01 11:29:24
【问题描述】:

我正在使用 knitr 和 Rmarkdown 创建 PDF 文档,但徽标和标题远离文档顶部。

如何减少首页的上边距?非常感谢。

这是我的代码:

---
title: "Title come here (there is a logo before the title)"

output:
  pdf_document:
header-includes:
  - \usepackage{titling}
  - \pretitle{\begin{center}
  -  \includegraphics[width=1.5in,height=1.5in]{logo.png}\LARGE\\}

---

【问题讨论】:

  • 您是否考虑过将徽标放在页眉中?不过,这是否回答了您的问题? stackoverflow.com/questions/13515893/…
  • 不要滥用\\作为换行符,也不要同时指定图像的宽度和高度,这会扭曲纵横比

标签: r pdf latex r-markdown knitr


【解决方案1】:

我找到了一个可行的解决方案(不确定它是否是一个“干净”的解决方案,但它确实有效):我在 - \setlength{\droptitle}{-1.1in} 中添加了一个负值

---
title: "\\vspace{0.5in} Title here"

output:
  pdf_document:
header-includes:
  - \usepackage{titling}
  - \setlength{\droptitle}{-1.1in}
  - \pretitle{\begin{center}
  -  \includegraphics[height=1.5in]{logo.png}\LARGE\\}
---

【讨论】:

    猜你喜欢
    • 2020-05-07
    • 2015-12-02
    • 2016-01-11
    • 1970-01-01
    • 1970-01-01
    • 2017-11-22
    • 2020-11-13
    • 2017-06-09
    • 2013-10-03
    相关资源
    最近更新 更多