http://statacumen.com/teaching/ada1/ UNM Stat 427/527: Advanced Data Analysis I (ADA1) Prof Erik Erhardt Converting from Markdown to LaTeX for poster. This video illustrates the process below: https://www.youtube.com/watch?v=9ttx1FNcOwk&list=PLpN_zjlfJSrATZin6LCWpq9ihsoXpHaqS&index=57 ---------- Step 0: - Install LaTeX - On Windows, open MikTeX options, install Packages Always on-the-fly. - Place ADA1_PosterTemplate_Portrait.Rnw file in the same folder as your ALL Rmd file. - Open in RStudio and Compile PDF and verify you see a pdf poster. - Make sure your ALL Rmd file knits completely. Step 1: Export the source code from your Rmd (Markdown) file so it can be read into your Rnw (LaTeX) file. R Console: Output R code from your homework (see top of my HW.Rmd file) setwd("C:/Dropbox/UNM/teach/ADA_Redesign_2015/ADA1_Content/homework") knitr::purl("ADA1_HW_ALL_NESARC_Project.Rmd") # write .R file LaTeX %% Add your HW file's *.R file (from perl()) here <>= setwd("C:/Dropbox/UNM/teach/ADA_Redesign_2015/ADA1_Content/homework") source("ADA1_HW_ALL_NESARC_Project.R") # run code into environment, cache results @ Step 2: Copy blocks of text/code from your Rmd file to Rnw, fix up into LaTeX, and compile. Do one small part at a time and make sure each change you make continues to work. If it stops working, it was the last thing you did. Read any compile error message and try to fix it. Step 3: Figure sizes. Adjust fig.width and fig.height for the size the figure is created, then adjust out.width for the size the figure is displayed on the page. For example, if fig.* were both really big (around 20, inches is the unit), but out.width='1\\textwidth', then the text would look very small (since a big image was squeezed into a small area). This is one strategy for controlling the text size of the figure. Bibliography: For the bibliography to show, it needs to be compiled from auxilary files that are created when the poster is first compiled. Then, the poster needs to be compiled again to incorporate the bibliography information. Whenever citations are added or removed, the bibliography should be recompiled. To compile (bibtex) the bibliography: - Set WD: Session / Set Working Directory / Choose Directory ... - Get terminal in WD: Tools / Terminal / New Terminal - Verify you're in the folder/directory with your poster files: - dir [Enter] (if Windows) - ls [Enter] (if Mac or Linux) Example output: C:\Users\erik\Desktop>ls ADA1_PosterTemplate_Portrait.nav ADA1_PosterTemplate_Portrait.toc UNM_logo.pdf ADA1_PosterTemplate_Portrait.Rnw ADA1_PosterTemplate_Portrait.out ADA1_PosterTemplate_Portrait.vrb ADA1_PosterTemplate_Portrait.aux ADA1_PosterTemplate_Portrait.pdf beamerthemeUNM.sty ADA1_PosterTemplate_Portrait.bbl ADA1_PosterTemplate_Portrait.snm bib_example.bib ADA1_PosterTemplate_Portrait.log ADA1_PosterTemplate_Portrait.tex figure NESARC.RData AddHealth.RData addhealth_public4.RData - bibtex [poster file name, no period or extention] - bibtex ADA1_PosterTemplate_Portrait Example output: C:\Users\erik\Desktop>bibtex ADA1_PosterTemplate_Portrait This is BibTeX, Version 0.99d (MiKTeX 2.9.7140 64-bit) The top-level auxiliary file: ADA1_PosterTemplate_Portrait.aux The style file: plain.bst Database file #1: bib_example.bib ---------- A Helpful reference for translations between Markdown and LaTeX Code chunks Markdown ```{R, options} code ``` LaTeX <>= code @ Citations Markdown [@ref1;@ref2] LaTeX \cite{ref1,ref2} List Markdown * a1 * a2 LaTeX \begin{itemize} \item a1 \item a2 \end{itemize} Bibliography Markdown bibliography: bibfile.bib LaTeX \bibliography{bibfile} Values in text Markdown `r nrow(NESARC)` LaTeX \Sexpr{nrow(NESARC)} Variable names in text Markdown `VarName` LaTeX \verb|VarName| Quotes Markdown "begin and end" LaTeX ``begin and end'' END OF LINE