r - add image in title page of rmarkdown pdf -


i attempting create rmarkdown document. have figured out way approach this, although has taken quite time. last thing able add image title page of pdf document.

the trouble have title page defined top section of yaml. below contents of example.rmd file. use knit pdf button in rstudio turn pdf.

--- title: "this document" author: "prepared by: dan wilson" date: '`r paste("date:",sys.date())`' mainfont: roboto light fontsize: 12pt documentclass: report output:    pdf_document:     latex_engine: xelatex     highlight: tango --- r markdown document. markdown simple formatting syntax authoring html, pdf, , ms word documents. more details on using r markdown see <http://rmarkdown.rstudio.com>.  when click **knit** button document generated includes both content output of embedded r code chunks within document. can embed r code chunk this:  ```{r} summary(cars) ```  can embed plots, example:  ```{r, echo=false} plot(cars) ```  note `echo = false` parameter added code chunk prevent printing of r code generated plot. 

if has tips allow me put image (logo.png) above title great.

i able solve using latex package titling

--- title: "untitled" author: "name" date: "september 19, 2015" output:   pdf_document:     includes:       in_header: header.tex ---  r markdown document. markdown simple formatting syntax authoring html, pdf, , ms word documents. more details on using r markdown see <http://rmarkdown.rstudio.com>.  when click **knit** button document generated includes both content output of embedded r code chunks within document. can embed r code chunk this:  ```{r} summary(cars) ```  can embed plots, example:  ```{r, echo=false} plot(cars) ```  note `echo = false` parameter added code chunk prevent printing of r code generated plot. 

where header.tex should include following code:

\usepackage{titling}  \pretitle{%   \begin{center}   \large   \includegraphics[width=4cm,height=6cm]{logo.png}\\[\bigskipamount] } \posttitle{\end{center}} 

and replace logo.png image use , make sure file in root directory of rmd file. can change image width , height needs. more information on available options go titling


Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -