Adjusting R Markdown Title Position in PDF output

耗尽温柔 提交于 2019-12-06 09:53:33

问题


I am creating an R Markdown report and can´t find a way to move my title down the page.

Here is a minimal example, where I would like to move the title down 5cm:

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

\thispagestyle{titlepage}

The header.tex file include some custom styling:

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

Output:

Note that I´m not talking about the margins, just want to move the title so that it is not always at the top of the page.


回答1:


Another option would be to use the titling LaTeX package which makes it easy to change the styles of the titles. I have included some customisation inline within the header-includes argument of the YAML:

---
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

Including the LaTeX commands in the YAML is generally okay for small edits like this, but if you want to make further customisations I would recommend keeping them in an a separate .tex file as explained in the R Markdown Definitive Guide




回答2:


This will do the trick:

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


来源:https://stackoverflow.com/questions/34950851/adjusting-r-markdown-title-position-in-pdf-output

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!