Skip to content

Instantly share code, notes, and snippets.

@jakob-r
Created November 19, 2019 14:45
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 jakob-r/78d2647584eb2610ae5809e2d53dc9a1 to your computer and use it in GitHub Desktop.
Save jakob-r/78d2647584eb2610ae5809e2d53dc9a1 to your computer and use it in GitHub Desktop.
Shows how to use svg with multiple layers as animation steps
\documentclass{beamer}
\usepackage[absolute,overlay]{textpos}
\usepackage{import}
\setbeamercolor{background canvas}{bg=gray}
\setkeys{Gin}{width=\linewidth} % default of includegraphics width
\begin{document}
<<beamerscape_setup, cache=TRUE, include=FALSE>>=
beamerscape_script = "./assets/beamerscape"
if (!file.exists(beamerscape_script)) {
dir.create(dirname(beamerscape_script))
download.file("https://raw.githubusercontent.com/x49/beamerscape/python/bin/beamerscape", beamerscape_script)
system(paste("chmod +x", beamerscape_script))
}
@
<<download_image, cache=TRUE, include=FALSE>>=
svg_image = "./assets/example.svg"
# the svg has to have layers with names <1-> always, <2> only two, <2-3> step 2 to 3
# if the pdfs not filled with the content make sure that in Inkscape
# File -> Document Properties -> Display Units px, Custom Size Units px, Scale 1.00, Viewbox same values as Width and Height in Custom Size
if (!file.exists(svg_image)) {
dir.create(dirname(svg_image))
download.file("https://raw.githubusercontent.com/x49/beamerscape/python/examples/figures/beamerscape_example.svg", svg_image)
}
out_dir = gsub(x = basename(svg_image), pattern = ".svg", replacement = "")
@
\begin{frame}{Test}
<<beamerscape_run, include=FALSE, cache.extra = tools::md5sum(svg_image), cache=TRUE, cache.rebuild=!dir.exists(out_dir)>>=
system(paste(beamerscape_script, svg_image))
@
\setlength{\TPHorizModule}{0.8\linewidth}
\setlength{\TPVertModule}{\paperheight}
\textblockorigin{0mm}{0mm}
<<beamerscape_include, echo=FALSE, results='asis', cache=FALSE>>=
cat("\\subimport{", out_dir,"/}{overlay.tex}", sep = "") #subimport can deal with relative paths in overlay.txt
@
\vspace{30mm}
More Text
\end{frame}
\end{document}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment