【问题标题】:Adjusting R Markdown Title Position in PDF output调整 PDF 输出中的 R Markdown 标题位置
【发布时间】:2016-04-29 07:09:08
【问题描述】:

我正在创建 R Markdown 报告,但找不到将标题移到页面下方的方法。

这是一个最小的例子,我想将标题向下移动 5 厘米:

---
title: "This is my title to display at 5cm below the top"
output:
  pdf_document:
    includes:
      in_header: header.tex
---

\thispagestyle{titlepage}

header.tex 文件包含一些自定义样式:

\usepackage{fancyhdr}
\fancypagestyle{titlepage}{
    \fancyfoot[LE,RO]{\thepage\ of \pageref{LastPage}}
    \fancyfoot[LE,LO]{Project}
    \fancyhead[L]{\includegraphics[width=4cm]{logo.png}} 
    }

输出

请注意,我不是在谈论页边距,只是想移动标题,使其不总是在页面顶部。

【问题讨论】:

  • 顺便说一句,我已经尝试了以下但没有成功:\vspaces*{5cm}\thispagestyle{title page}
  • 如果这是您正在寻找的内容,您应该将其发布为答案。请注意,对于这种自定义,您最好编写自己的template

标签: r latex knitr r-markdown


【解决方案1】:

另一个选择是使用titling LaTeX 包,它可以轻松更改标题的样式。我在 YAML 的 header-includes 参数中包含了一些自定义内联:

---
title: "This is my title to display at 5cm below the top"
output: pdf_document
header-includes:
  - \usepackage{titling}
  - \setlength{\droptitle}{5em} 
---

# Content
And then something here...

\newpage

# Next Page
Some more text

在 YAML 中包含 LaTeX 命令对于像这样的小型编辑通常是可以的,但如果您想进行进一步的自定义,我建议您将它们保存在单独的 .tex 文件中,如 R Markdown Definitive Guide 中所述

【讨论】:

    【解决方案2】:

    这样就可以了:

    \setlength{\headsep}{5cm}
    \thispagestyle{title page} 
    

    【讨论】:

    • 感谢您分享您的解决方案。您可以accept您自己的答案将问题标记为已解决。
    • @david,你把这两行放在哪里?在 yaml 里面?
    猜你喜欢
    • 2017-10-15
    • 2021-12-09
    • 2013-03-01
    • 1970-01-01
    • 2020-10-23
    • 2019-10-01
    • 2021-04-21
    • 2018-11-19
    相关资源
    最近更新 更多