Currently there seem to be two ways to do presentations in R:
RStudio presentations, with .Rpres extension
rmarkdown, with .Rmd extension
To me, it looks like the latter is slightly more powerful. The input format is very similar, yet not identical. I'm thinking about converting an RStudio presentation to rmarkdown. What's the best way to do this? How about the conversion back?
On that note, I'd really like to see an "in-pane" preview for rmarkdown presentations in RStudio, just like for RStudio presentations. I wonder why this isn't implemented -- the preview forcibly shows up in a modal window. Technical issues?
To change from .Rpres to .Rmd you need to change file extension (easy) and the front matter of the markdown document (slightly more involved).
A .Rpres file places the front matter on the first slide:
Untitled
=============================
author: Your Name Here
date: 4 July, 2015
while a .Rmd document places the front matter in a special block:
---
title: "Untitled"
author: "Your Name Here"
date: "04 July, 2015"
output: ioslides_presentation
---
The rest of your presentation code remains in rmarkdown, and should require minimal work to convert.
Some exceptions that I can think of immediately include
ioslides/slidify don't support columns via *** (a real shame, as this is so convenient)
Rpres doesn't support citations and a bibliography (also a shame)
Additionally, when converting you will need to look for any speciall CSS or other directives that are only supported by one framework.
Related
Here is the problem:
I developed a tool with R Markdown that process and generate some company monthly report.
I've been trying to automate the location of a CSS file that styles this report by using this code:
---
title: "Gerador de Relatórios VANT"
author: 'Empresa: International Paper Brasil'
date: 'Equipe: P&D'
output:
html_document:
css: !expr paste(dirname(dirname(rstudioapi::getSourceEditorContext()$path)), 'CSS/vant_style.css', sep = '/')
---
I don't know for sure, but I think maybe I cannot use use the function rstudioapi::getSourceEditorContext()$path because when knitting the document, it runs in another session.
I want to do so because I have to share with my boss and with some colleagues and I don't want they need to change anything here, in css file.
Is there anyway to do what I need?
PS: I'm doing this way because I have so many folders in my project which is not only the tool folder but a lot more data and annotations, I understand it would be easier to leave everything in only one folder.
I have begun using Rmd to render Powerpoint presentations consistently, using the YAML tags and more importantly, a reference Powerpoint to ensure standardized / consistent formatting:
output: powerpoint_presentation: slide: reference_doc: "reference.pptx". When I want to share a PPT document as a reference for my peers / students however, I want to be able to have my slides available as a .pdf file.
I have had success using shell commands in R using LibreOffice's soffice command, however I am not always at a workstation with that available. Is there a portable solution / executable I can call, or additional Rmd tags for rendering a document with a .pptx reference document, but rendered as a .pdf file?
I believe you have to specifiy output: beamer_presentation in the header.
Take a look at this: https://rmarkdown.rstudio.com/formats.html
I am writing a paper in R markdown and need to format it with this .cls file supplied by an academic journal.
A minimal .tex file compiles perfectly well with the above cls file.
My .tex file (compiled on ShareLaTeX with clv3.cls saved in same directory):
\documentclass[shortpaper]{clv3}
\usepackage[utf8]{inputenc}
\title{Paper title}
\author{Name Surname}
\date{May 2018}
\begin{document}
\maketitle
\section{Introduction}
Some text.
\end{document}
However a comparable minimal document in R markdown, using the same cls file, fails to compile in Rstudio, with the following error: ! Package geometry Error: \paperwidth (0.0pt) too short.
My Rmd file (with clv3.cls file saved in same directory):
---
title: "Paper title"
author: "Name Surname"
documentclass: clv3
classoption: shortpaper
output: pdf_document
---
# Introduction
Some text.
Why is this error induced when I try to use this class file with an R markdown document and how may I fix it?
I've tried manually specifying a pagewidth setting in the YAML header, but I don't really know what I'm doing. This seems undesirable anyway, since the normal LaTeX document works fine without it (and surely page width is something that should be specified by a journal, not manually overwritten by an author).
I do not know where exactly the clv3.cls class and the default pandoc template clash. However, that template does so many things that do not make sense when writing with a specific style, that is best to use your own template. Using clv3-template.tex
\documentclass[shortpaper]{clv3}
\usepackage[utf8]{inputenc}
$if(title)$
\title{$title$}
$else$
\title{}
$endif$
$if(author)$
\author{$for(author)$$author$$sep$ \\ $endfor$}
$else$
\author{}
$endif$
\begin{document}
$if(title)$
\maketitle
$endif$
$body$
\end{document}
together with
---
title: "Paper title"
author: "Name Surname"
output:
pdf_document:
template:
clv3-template.tex
---
# Introduction
Some text.
should be a good starting point.
The accepted answer works perfectly for the minimal example presented. However it breaks again pretty quickly as the document is made more complex (for example, inserting a bibliography and in-text citations). I'd like to expand a little on my solution for the potential benefit of any future readers, as I found it a bit of steep learning curve:
The issue here is that Pandoc has a LaTeX template, which it uses to produce PDF documents. This is separate from a .cls class file, which defines a document class. Like Ralf Stubner says, something about my particular class file was not cooperating with Pandoc's default template. This is probably super basic and obvious to many, but I had not appreciated this extra step nor understood the distinction between these files.
If one does not wish to deal with raw LaTeX, it seems there are quite a few templates out there for various kinds of documents (see, for example, the rticle package). Using R Markdown to produce a PDF document in a particular custom format (such as for a particular journal) will require construction of a LaTeX template, however. This can be done by either of two ways:
Tinkering with an existing template until you get what you need, either by finding Pandoc's default template and starting from there (see comment by user2554330 for location) or by cloning someone else's template on Github etc.
Writing a template from scratch. In this case, Ralf Stubner's minimal example above plus this section of the Pandoc manual will be informative.
In my case, I went with the latter option. I have saved my eventual template as an R package which can be installed using devtools::install_github("JaydenM-C/CLtemplate"). So if anyone else would ever like to author a document for Computational Linguistics using this particular document style, this may save you some time.
I built an interactive shiny presentation in Rstudio. Header of the .Rmd file is:
---
title: "title"
author: "author"
date: "date"
output:
ioslides_presentation:
mathjax: "http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"
runtime: shiny
---
I generate really nice slides with interactive elements. No problem. However, I cannot knit the document as html or pdf files. I think this's by design since I specifically select "runtime: shiny". Is there an alternative way to capture the presentation as pdf/html file even if it means loss of the interactive elements? The only solution I could come up with is capture a screenshot for every slide from the browser and save it separately. But this's laborious...
You can Knit on-demand screenshots of the app by following these instructions.
Is there a way to create an R presentation from the command line?
https://support.rstudio.com/hc/en-us/articles/200486468-Authoring-R-Presentations
I have the following R Presentation file stored in my_file.RPres file.
Title
========================================================
author: Me
date: Jan 9, 2015
transition: none
css: template.css
This is my presentation.
Is there any way to specify on rmarkdown::render(), knit(), pandoc(), or another R command, that this is an "R Presentation" .RPres file, and not ioslides_presentation, beamer_presentation, or slidy_presentation?
My .RPres file does not have any YAML metadata on the header, and the .css file was created based on the html file generated by RStudio with "Preview" and "Save As a Web page...".
I asked this question in on RStudio Support Community page, and the 'official' answer was no. A colleague looked at the code on github and verified the method is only called from the drop down UI. Looks like to do this you would have to actually compile your own wrapper.