Rmarkdown: image at bottom of title page - r

I am creating a title sheet for a pdf document in Rmarkdown. I would like to be able to put the image line.png at the bottom of the title page.
Please can someone help me with this. The code I have used thus far is as follows:
---
title: "Some title"
author: "Prepared by: Anon"
date: '`r paste("Date:",Sys.Date())`'
output: pdf_document
---
\pagenumbering{gobble}
\centerline{\includegraphics[height=3in]{picture_folder/line.png}}
\clearpage

RMarkDown is a tool that allow you to rapidly sketch a neat and tidy text with embedded data. I possess books written with RMD, and I even wrote a couple of article myself! In any case, to proper use its full potential, and finely manage images and more personal settings, it is quite common to embed HTML code in RMD. Your question is beautifully answered here, and reports as example:
<img style="float: bottom;" src="yourimage.jpg">
Continue your RMD document
If you need a quick HTML reference for images management, I suggest you to consult this page. It is short and precise. It should help you to solve the most common problems with images alignment.

Related

R markdown landscape-only word document

I am trying to knit an .Rmd file to a word document that is entirely in landscape format.
Based on this post, I have tried using a reference doc. I created a Word document, changed the layout to landscape and saved it in the same folder as the .Rmd. However, this doesn't seem to work for me. Maybe I am missing something and saving a file in landscape format is not enough?
Previously, I was using the HTML comments/tags <!---BLOCK_LANDSCAPE_START---> and <!---BLOCK_LANDSCAPE_STOP---> from {officedown}, but since those can only be placed before and after code chunks, the title of the document would end up on a separate page that is portrait. Also, it gives a last page that is blank and portrait and that I don't know how to get rid of.
The current YAML header looks as follows:
---
title: "Summary Report"
output:
officedown::rdocx_document:
reference_docx: landscape_template.docx
---
I am also sure that the reference file is used because I get a warning in the console about not having set a Figure style:
Warning message:
paragraph style for plots "Figure" has not been found in the reference_docx document. Style 'Normal' will be used instead.
Does anyone have any suggestions on what I am missing?
After reaching out to the developer of {officedown} on GitHub, here is the very simple solution to the problem:
YAML header of .Rmd file:
---
output:
officedown::rdocx_document:
page_size:
orient: "landscape"
---

IN R MARKDOWN, How Can I add a background image (HTML output)?

I'm trying to put an image as background for my R markdown document (HTML output) Instead of the black background. I Was searching everywhere in the documentation on how to do this but I can't seem to find any answer as it's my first time working with R Markdown.
I can't seem to know how to put the background image and how to divide it that way so I can have my content in the middle
I'm also trying to attach a Hyperlink to tablist option,in the Picture2 as you can see "Source" as for when I click on it, it directs me to an external page
but ## [Source] ("github.com/example") isn't working which was the syntax in the documentation.
this is my code till now ..
I hope you can help me with these two questions,
it's again : - How to set a background image to an HTML output on the whole page like the black background
and how can I make the click on " Source " or TabItem directs me to an external link?
Thank you
---
title: "Title"
author: "Nessy"
date: "2 3 2020"
output:
rmarkdown::html_document:
theme: lumen
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
# {.tabset .tabset-fade}
## Analysis
## Source
Just posting the answers here so it can be marked as "answered." (Kindly mark this as answer when you're done and if this satisfies you).
1) Regarding background theme check this out: https://rpubs.com/thaufas/555157
2) Try [github](someurl) with no space in between. EDIT:
Regarding opening the link in markdown there try these links R Markdown - Hyperlink outside Rmd file or Linking to url with rmarkdown using Knit Word in Rstudio.

Multiple headers/footers when using custom TeX in r bookdown

Loved bookdown. However, I'm porting my book from LaTeX into bookdown, and would like some help with headers/footers.
I have a custom code that generates headers and footers in my LaTeX:
% HEADER AND FOOTER MANIPULATION
% for normal pages
\nouppercaseheads
\headsep = 0.16in
\makepagestyle{mystyle}
\setlength{\headwidth}{\dimexpr\textwidth+\marginparsep+\marginparwidth\relax}
\makerunningwidth{mystyle}{\headwidth}
\makeevenhead{mystyle}{}{\textls[100]{\textsf{\small\scshape\thetitle}}}{}
\makeoddhead{mystyle}{}{\textls[100]{\textsf{\small\scshape\leftmark}}}{}
\makeevenfoot{mystyle}{}{\textls[100]{\textsf{\small\thepage}}}{}
\makeoddfoot{mystyle}{}{\textls[100]{\textsf{\small\thepage}}}{}
\clearmark{section} % removing section in the headers
\makeatletter
\makepsmarks{mystyle}{%
\createmark{chapter}{left}{nonumber}{\#chapapp\ }{.\ }}
\makeatother
% for pages where chapters begin
\makepagestyle{plain}
\makerunningwidth{plain}{\headwidth}
\makeevenfoot{plain}{}{}{}
\makeoddfoot{plain}{}{}{}
\pagestyle{mystyle}
% END HEADER AND FOOTER MANIPULATION
I placed my entire LaTeX preamble in preamble.tex (and I've not added content to the book just yet). It renders the following:
The render should actually look like this:
Also, here's what's in the YAML in index.Rmd.
documentclass: memoir
papersize: smalldemyvo
indent: yes
microtypeoptions:
- protrusion
- tracking
fontfamily: Alegreya
fontfamilyoptions:
- osf
fontsize: 11pt
output:
bookdown::pdf_book:
template: null
I'm new to bookdown, but I did read the documentation. I feel I need help with two things.
How do I remove the auto-generated headers and footers?
How do I make "Contents" disappear from the ToC table?
Thank you!
By default, bookdown uses some built-in template(s). If you need more adjustments, you could make your own .tex files (preamble.tex, before_body.tex, after_body.tex, template.tex) and specify them in the yaml part of index.Rmd like this:
bookdown::pdf_book:
includes:
in_header: preamble.tex
before_body: before_body.tex
after_body: after_body.tex
template: template.tex
bookdown merges preamble.tex, before_body.tex, and after_body.tex with the main body (marked as $body$ in template.tex) of your book into one .tex file in the structure under the control of template.tex, and compile it into a pdf book with pandoc and LaTex.
In your case, you have to insert your custom code into template.tex in the right way. #yihui's demo shows a good example.
For more examples to customize these .tex files, I would suggest that you could either look into the 'bookdownplus' package I developed, which gives you 19 examples showing how to tailor a LaTeX template into bookdown's frame, or read Chapter 8.3 Create Your Own Templates in the bookdownplus textbook.
Edited answer
bookdown has built-in templates (decided mostly by documentclass and/or Pandoc). Refer the Theming and Templates sections of bookdown documentation.
An example to learn from, as #pzhao suggested, is the template in the bookdown-chinese repo. Observe the variables that bring in data from the Rmd files. They're enclosed between $$, such as $body$. _output.yml has a reference to this template. This way, you override the default template, thereby eliminating duplicate headers/footers. Your LaTeX template decides what forms part of your headers/footers. An example is the LaTeX code in my question.
The appearance of Contents in the ToC table can also be controlled by tweaking your custom LaTeX template. I use the memoir class, and help to remove self-reference can be found here. My custom LaTeX template already took care of it, so it fixed itself as soon as I figured out how to use my custom template.

outline/toc on the left and contents on the right layout using rmarkdown

I was checking out how to include a nice table of contents / document outline in my rmarkdown document (with html output).
Well, the "standard" approach:
html_document:
toc: true
It works, but I do not like it (not even tweaking options and themes).
But actually, in several pages of the documentation (e.g. http://rmarkdown.rstudio.com/html_document_format.html), they use a very nice layout that includes a table of contents / document outline to the left of the page and the contents of the right (and the outline syncs with the contents part, Highlighting where on the contents you currenly are).
This is EXACTLY what I want. And I guess they did it using rmarkdown. But I cannot find how to do it.
I've check that documentation page, as well as rmarkdown gallery, flex dashboard, web sites among others. But I can't seem to figure it out how to do it.
Well, using web sites I would be able to do it, but it seems overly complicated for what I want (you need to have several pages, and at least index.Rmd file and the _site.yml file).
Instead, I guess there should be an option to simply tell rmarkdown to take my single document and put the section headers in a nice frame to the left, as in the example page from RStudio.
Have you tried this approach? It works for me and it's also on the homepage, you provided:
---
title: "Untitled"
output:
html_document:
toc: true
toc_float: true
---
# header 1
# header 2
# header 3
With a little bit of text, it looks like that:

In RStudio, making slide deck with RMarkdown, how can I easily change the theme?

I'm writing an .rmd file in RStudio, and using the Knit button to create a slide deck. I have two options, it appears, ioslides and slidy. I don't really like the default look-and-feel of either. (I think ioslides uses screen real estate inefficiently, and slidy feels like a graphic designer wasn't involved.)
I did a web search for alternative templates/styles/themes, and came upon pages like this gallery, but the tools there seem to be for use outside RStudio, as completely independent projects. In other words, they're not just themes for what I've got, but entirely other solutions that would change my workflow.
Is there a simple way to tell RStudio to use a different template/theme with either ioslides or slidy? For example, can I download a CSS file from somewhere, and point RStudio to it with the css: option in the yaml header of my .rmd file? If so, is there a gallery of such CSS templates?
Here's what I ended up doing. It's not as smooth as I'd like it to be, but it's decent. I'm glad to entertain better answers.
Download any of the style files linked to from this knitrBootstrap code into the same folder as your R Markdown file.
Edit it so that the URL at the start of the file begins with http: so that knitr knows not to look on your filesystem for the additional resources (fonts), but on the Web.
Edit it further to remove any pipes (|) in that URL, because knitr can't handle them (as far as I can tell). (Remove everything after the pipe, too.)
Edit it further to change everything of the form url('../fonts/***.eot'); to now instead be of the form url('https://netdna.boostrapcdn.com/bootswatch/3.0.0/fonts/***.eot');.
Link to it from your R Markdown file with the css: attribute in the YAML header.
Have you tried using the built in Bootswatch themes? They're fairly limited, but in doing so you can quickly customise many elements.
e.g
title: "Test"
author: "John"
date: "5 June 2017"
output:
slidy_presentation:
fig_width: 12.5
font_adjustment: -1
theme: readable
Other themes may be found here Bootswatch.
edit: removed a typo

Resources