Skip to content

Instantly share code, notes, and snippets.

@Pakillo
Forked from jhollist/beamer_two_col.Rmd
Created November 7, 2016 17:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Pakillo/78c3c325f828747b8a76a95c7ae74eea to your computer and use it in GitHub Desktop.
Save Pakillo/78c3c325f828747b8a76a95c7ae74eea to your computer and use it in GitHub Desktop.
This .Rmd shows how to use two (or more) columns in a Beamer Presentation from RStudio
---
title: "Untitled"
author: "Jeff W. Hollister"
date: "2/2/2016"
output: beamer_presentation
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
if(!require(commonmark)){
install.packages("commonmark",repos = "https://cran.rstudio.com/")
}
create_cols <- function(md,width=rep(1/length(md),length(md))){
for(i in 1:length(md)){
if(length(md) == 1){
out<-paste0("\\begin{columns}\n\\begin{column}{",
width[i],
"\\textwidth}\n",
commonmark::markdown_latex(md[i]),
"\n\\end{column}\n\\end{columns}")
return(cat(out))
}else if(i == 1){
out<-paste0("\\begin{columns}\n\\begin{column}{",
width[i],
"\\textwidth}\n",
commonmark::markdown_latex(md[i]))
} else if(i == length(md)){
out<-c(out,paste0("\n\\end{column}\n\\begin{column}{",
width[i],
"\\textwidth}\n",
commonmark::markdown_latex(md[i]),
"\n\\end{column}\n\\end{columns}"))
} else {
out<-c(out,paste0("\n\\end{column}\n\\begin{column}{",
width[i],
"\\textwidth}\n",
commonmark::markdown_latex(md[i])))
}
}
return(cat(out))
}
download.file("https://developer.r-project.org/Logo/Rlogo-3.png","rlogo.png",
method = "curl")
```
#Test
```{r results='asis'}
create_cols(c("
- Multiple columns
- is a pain
- But now it at least works
- in Beamer and markdwon",
"![img](rlogo.png)",
"**IT KINDA WORKS**"),
width=c(0.3,0.45,0.2))
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment