I'm creating a PDF document using knitr and Rmarkdown but the logo-and-title are far from the top of the document.
How to reduce the top margin on the first page ? Many thanks in advance.
This is my code:
---
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\\}
---
I found a solution that works (not sure if it's a "clean" solution, but it does the job): I added a negative value in - \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\\}
---
Related
I am trying to get the n of m pages to work in R markdown but am stuck so any help will be appreciated and thanks in advance.
I have set up my document so far as follows, and this works fine - creates the .pdf with the font I want to use etc.
---
title: "********************"
author: "******************"
output:
pdf_document:
latex_engine: xelatex
header-includes:
- \usepackage{fontspec}
- \setmainfont{Arial}
- \usepackage{geometry}
- \usepackage{fancyhdr}
- \usepackage{lastpage}
- \fancyhf{}
- \fancyfoot[R]{\thepage \hspace{1pt} of \pageref{LastPage}}
bibliography: ***********.bib
csl: https:***********************
It seems, that it is ignoring the -\fancyfoot... line because the output is the same when I comment this line out. I know I am missing something, but have run out of ideas and things to search for.
I hope someone can see what I am doing wrong.
Thanks again
I am new to Rmarkdown, Beamer presentations and the like and have been having some trouble inserting my logo to the header. I don't exactly know how the code works, Here is the code I am trying to use for my header, but it is giving me a "Undefined Control Sequence" error.
---
title: "Lifewerks Reporting Numbers 2021-2022"
date: "`r Sys.Date()`"
header-includes:
- \usepackage{subfig}
- \logo{\incudegraphics[width = 3cm]{sfp-logo.png}}
output: beamer_presentation
---
Any help or resources that I could learn from would be greatly appreciated! Thank you!!
there is a small typo, it should be \includegraphics [the l is missing]
if you want the image just on the first page, I would use \titlegraphic instead of \logo (the later would add the image to all frames)
---
title: "Lifewerks Reporting Numbers 2021-2022"
date: "`r Sys.Date()`"
header-includes:
- \titlegraphic{\includegraphics[width = 3cm]{example-image-duck}}
output:
beamer_presentation:
keep_tex: true
---
test
Given the code below, which currently outputs the page number on top of the page, I would like it to output the PDF page count as in Page 1 of 3. I have done a lot of searching but haven't found any way to include the total page number.
Question Is this possible to do w/ in R Markdown ? If not, are there any workarounds ?
I have googled this and haven't found anything obvious such as YAML or TeX solutions, however, I may be missing something or not searching for the correct things.
RMarkdown Code
---
title: "R Markdown Example With Numbered Sections"
output:
bookdown::pdf_document2:
toc: true
toc_depth: 6
number_sections: true
includes:
in_header: header.tex
header-includes:
- \usepackage{fancyhdr}
- \pagestyle{fancy}
- \fancyhead[RO,RE]{\thepage}
- \fancyhead[LO,LE]{Header Message}
- \fancyfoot[LE,LO]{Footer Messge on the Left}
- \fancyfoot[LE,RO]{Footer Messge on the Right}
---
\thispagestyle{fancy}
# Example R Rarkdown : Numbered Sections
## R Markdown
### Description
Some description text
\newpage
#### Details
Details go here.
\newpage
## Plots
Plots go here
\newpage
Last page
Current header
Desired Header
Make sure you have the lastpage package installed.
Then modify your header includes to look like this:
header-includes:
- \usepackage{fancyhdr}
- \usepackage{lastpage}
- \pagestyle{fancy}
- \fancyhead[RO,RE]{\thepage\ of \pageref{LastPage}}
- \fancyhead[LO,LE]{Header Message}
- \fancyfoot[LE,LO]{Footer Messge on the Left}
- \fancyfoot[LE,RO]{Footer Messge on the Right}
How to add background colors to specific section of the text while creating PDF reports using rmarkdown. Something like below
i tried something like this but it is working in latex but not in rmarkdown
\titleformat{\section}{\sffamily\Large\bfseries\rlap{\color{DarkGreen!90}\rule[-0.5ex]{\linewidth}{3ex}\vspace{-3ex}}\sffamily\Large\color{white}}{\thesection}{1em}{}
this is how it looks in latex
this is in rmarkdown
---
title: "Untitled"
output: pdf_document
header-includes:
- \usepackage{amsfonts,amssymb,amsmath}
- \usepackage[table, svgnames]{xcolor}
- \usepackage{titlesec}
- \usepackage{sectsty}
- \usepackage{xcolor, soul}
- \sectionfont{\color{red}}
- \subsectionfont{\color{green}}
- \subsubsectionfont{\color{blue}}
- \titleformat{\section}{\sffamily\Large\bfseries\rlap{\color{DarkGreen!90}\rule[-0.5ex]{\linewidth}{3ex}\vspace{-3ex}}\sffamily\Large\color{white}}{\thesection}{1em}{}
---
\section{Highlights}
# Section
Two problems:
rmarkdown already loads xcolor without paying attention to the options you need. As a workaround you could trick markdown by passing the necessary options to all packages
sectsty will destroy all changes you do via titlesec. Don't load them both
---
title: "Untitled"
output:
pdf_document:
keep_tex: true
classoption: svgnames
header-includes:
- \usepackage{amsfonts,amssymb,amsmath}
- \usepackage{titlesec}
- \usepackage{soul}
- \titleformat{\section}{\sffamily\Large\bfseries\rlap{\color{DarkGreen!90}\rule[-1.5ex]{\linewidth}{3ex}\vspace{-3.5ex}}\sffamily\Large\color{white}}{\thesection}{1em}{}
---
\section{Highlights}
# Section
I am trying to learn Rmarkdown, but there is something that's quite elusive. I am trying to put my name at the top of every page of the PDF I print, however I also get the various headers from the text in the markdown file in the header, and it often overlaps and makes everything unreadable. I learned the basics from another thread on here, but still struggling. I only want my name in the header. I tried to modify it like what you see below, but then I don't get anything at all. This is my YAML:
---
title: "Something"
author: "something"
date: "42 42 42"
output: pdf_document
includes:
in_header: {My name}
fontsize: 12pt
header-includes:
\usepackage{setspace}
\onehalfspacing
---
Anyone who could write it so that I get only my name at the top of the page? Also, the onehalfspacing is the same as setting spacing to 1.5 in word right?
I think there is a conceptual problem: The things you put in includes: in_header: in the yaml are the files included in the preamble of your tex document, similar to what you have in header-includes:. This is not in any way related to the headline of your document.
If you like to change this, have a look at the fancyhdr latex package
Please also note that the syntax for multiline header-includes: is wrong in your example. You need to prefix each line with -
---
title: "Something"
author: "something"
date: "42 42 42"
output: pdf_document
fontsize: 12pt
header-includes:
- \usepackage{setspace}
- \onehalfspacing
- \usepackage{fancyhdr}
- \fancyhead[c]{your name}
- \pagestyle{fancy}
- \setlength{\headheight}{15pt}
---
test
\newpage
test