I want to add an image as a header on the upper right corner of every page of my word document, using r-markdown with R-Studio.
I found a solution accepted by community here, but there is only the proper command in Latex described, there is no working example. For me the offered solution did not work.
Therefore I provide my sample code:
---
title: "2014 Report"
author: "My Name"
date: "Monday, October 06, 2014"
output:
word_document:
fontsize: 10pt
header-includes:
- \usepackage{wallpaper}
abstract: This is my abstract
---
Test
\ThisURCornerWallPaper{0.1}{header.png}
Here is some text.
That code produced the following output:
As one can see, there is no picture included in the document. Can somebody provide me with an actually working example (other ideas that do the job are also welcome)?
Related
I am trying to integrate footnotes AND a logo on the frontpage of a Rmarkdown generated PDF.
I try this:
---
title : "My report"
date : November 4th, 2022
author: "Author 1[^note1]"
documentclass : report
keep_tex : true
header-includes:
- \usepackage{titling}
- \pretitle{\begin{center}
\includegraphics[width=2in,height=2in]{logo.png}\LARGE\\}
- \posttitle{\end{center}}
output : pdf_document
---
[^note1]: Writing, Research, Editing
Inspired by this procedure to integrate the logo:
https://bookdown.org/yihui/rmarkdown-cookbook/latex-logo.html
And this for the footnotes:
https://stackoverflow.com/a/62514739/12398676
However, I am getting this error:
! Argument of \reserved#a has an extra }.
<inserted text>
\par
l.69 ...or 1\footnote{Writing, Research, Editing}}
Error: LaTeX failed to compile logo_footnote.tex. See https://yihui.org/tinytex/r/#debugging for debugging tips. See logo_footnote.log for more info.
Execution halted
Anyone has an idea of what is going wrong?
EDIT: the solution provided by samcarter_is_at_topanswers.xyz
... is one step closer to the solution but not quite there.
I now have a logo and author name, but the author name is overlayed with the date
EDIT2: In the solution provided by samcarter_is_at_topanswers.xyz I get a similar display problem even without a logo
---
title : "My report"
date : November 4th, 2022
documentclass : report
keep_tex : true
header-includes:
- \AtBeginDocument{\author{Author 1\protect\footnote{Writing, Research, Editing}}}
output :
pdf_document:
keep_tex: true
---
test
You can work around the problem like this:
---
title : "My report"
date : November 4th, 2022
documentclass : report
keep_tex : true
header-includes:
- \AtBeginDocument{\author{Author 1\protect\footnote{Writing, Research, Editing}}}
- \usepackage{titling}
- \pretitle{\begin{center}
\includegraphics[width=2in,height=2in]{example-image-duck}\LARGE\par}
- \posttitle{\end{center}}
output :
pdf_document:
keep_tex: true
---
test
I am trying to write a report.tex theists using TexMAKER,and I need to include a lot of r,
So I run my chunk code file with this preamble in Rmarkdow
title: "rcode"
author: ".."
date: "..."
output:
pdf_document:
keep_tex: yes
fig_caption: yes
html_document: default
then include the rcode.pdf output file in my original report.tex file using the command \includepdf[]{rcode.pdf}
this method is not so good because the page numbering in my report.pdf gets mixed up with the numbering of the Rmardown pdf output rcode.pdf,
So I am wondering if there is a new way to extract the rcode.tex code then include it in my report.tex file ?
Or is the better way just to start wring all of the theisis report in the rmardown file with out having any Latex complications ?
thanks for the help
I am struggling what what is likely a trivial markdown matter. I am hoping to avoid YAML and additional header templates and such if I can. So my question is straightforward and I welcome your feedback. For an R Markdown knitted as a PDF, how can I repeat the title and date on each printed page?
Alternatively I am happy to use headers using the '#' syntax. But if I can use the title parameters that would be preferred.
The Header thus far:
---
title: "Dashboard"
date: '`r paste(Sys.Date(), " to ", Sys.Date()+14)`'
output:
pdf_document:
latex_engine: xelatex
mainfont: Calibri
geometry: margin=1cm
classoption: landscape
params:
set_title: !r test_title
header-includes:
- \usepackage{titling}
- \pretitle{\begin{flushleft}\huge}
- \posttitle{\end{flushleft}}
- \preauthor{\begin{flushleft}}
- \postauthor{\end{flushleft}}
- \predate{\begin{flushleft}\large}
- \postdate{\end{flushleft}}
---
From the rmarkdown cookbook:
When a Rmd document is compiled, all of its metadata in the YAML section
will be stored in the list object rmarkdown::metadata. You can use this object
in your R code. For example, rmarkdown::metadata$title gives you the title
of the document.
This is my Rmarkdown code:
---
title: "My Title"
header-includes:
- \usepackage{calligra}
- \usepackage[T1]{fontenc}
output:
pdf_document:
latex_engine: xelatex
---
# Section 1
This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see <http://rmarkdown.rstudio.com>.
When you click the **Knit** button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:
I was studying the best way to change fonts in Rmarkdown. In texlive the installed calligra package appears and calligra-type1 also.
When I run the script with the calligra package it generates the pdf but the font does not match the calligra font.
And when I run the script for calligra-type1 the pdf is not even generated.
Any help, guys?
The calligra.sty does not set-up the Calligra as default font, but you can do so by adding
\renewcommand{\rmdefault}{calligra}
to header-includes.
BTW, there is no need to call fontenc.sty, since calligra.sty does so already. In addition, using xelatex is not necessary here.
I am new to the markdown. I want to write a report with python code and I would like to add title, author and date. I tried to use this code
---
title: My Title
author: My author
---
But this is not working. Can anyone suggest how to sort this problem.
Just by the syntax, it should be the right markdown format and pandoc should be able to format it. Try using this code:
import pypandoc
mytext = """
---
title: My Title
author: My author
--- """
pypandoc.convert_text(mytext,'pdf',format='markdown',
outputfile="output.pdf",
extra_args=['--pdf-engine','pdflatex'])
It should give you output.pdf that looks like this: