Created
February 3, 2016 18:51
-
-
Save jhollist/690bbbc5569dec9371bc 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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
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