### Contact

R, Statistics and Visualization

# R Reporting Part 8: Using LaTeX to Create Posters

This is the eigth of a series of articles on how to use R, RStudio and TexMaker to prepare presentations and batch jobs for automated reporting on a web server or Microsoft SharePoint server. The series is based upon the presentation that I did at the February 27, 2016 Dallas R User Group Meetup. Because the presentation was primarily a demonstration, there really isn’t a presentation to distribute; this series covers the topics from the presentation/demonstration. The series will eventually include the following articles as I complete them over the next couple of weeks:

The series of articles describes the process for daily batch jobs that generate the Daily Econometric Graphs web page which includes links to the same econometric charts in several formats, all generated through the same R code:

All of the examples are based upon the knitr R package; you should reference the knitr documentation, as this article is not a replacement for the knitr documentation.

Example source is available in images/documents/econometric_source.zip.

## LaTeX Poster Styles

Because LaTeX was written by and for academics and professionals in math and science who need to create posters for conferences and other displays, several authors have created LaTeX packages to make it easy to create posters. Here are a few of the major packages:

• Baposter from Brian Amberg is easy to use but has a relatively fixed display style.
• Beamerposter uses Beamer style operations.
• A0poster is perhaps the most flexible of the various poster packages, but with flexibility comes some complexity.

The example that follows will use BAposter, as it is probably the easiest to get working. The example poster is a PDF file Useful Econometrics Poster.

## BAPoster Example

The code for the example poster uses the knitr chunk syntax discussed earlier in this series of articles in R Reporting Part 3: Using Rhtml for Batch Web Reporting and set up using the read_chunk("econometric_charts_chunks.R") call in the prologue of the LaTeX/knitr file:


### Set Up Defaults

The first step is to set the various global parameters for the poster, for complete information on the various options, see the BAPoster documentation.

 \background{} \begin{poster}{ background=none, colspacing=0.7em, textborder=roundedleft, headerborder=none, headershape=roundedright, headerheight=0.134\textheight,% this defines height of box reserved for title, name, etc. %another declarations } {} {Useful Econometrics} {Bruce Moore \\ Moore Software Services LLC \\ Coppell, TX USA \\ This email address is being protected from spambots. You need JavaScript enabled to view it.document.getElementById('cloakd1c53cf16d53781f89c73b619c1bc224').innerHTML='';var prefix='&#109;a'+'i&#108;'+'&#116;o';var path='hr'+'ef'+'=';var addyd1c53cf16d53781f89c73b619c1bc224='m&#111;&#111;r&#101;bw'+'&#64;';addyd1c53cf16d53781f89c73b619c1bc224=addyd1c53cf16d53781f89c73b619c1bc224+'m&#111;&#111;r&#101;s&#111;ftw&#97;r&#101;s&#101;rv&#105;c&#101;s'+'&#46;'+'c&#111;m';var addy_textd1c53cf16d53781f89c73b619c1bc224='m&#111;&#111;r&#101;bw'+'&#64;'+'m&#111;&#111;r&#101;s&#111;ftw&#97;r&#101;s&#101;rv&#105;c&#101;s'+'&#46;'+'c&#111;m';document.getElementById('cloakd1c53cf16d53781f89c73b619c1bc224').innerHTML+='<a '+path+'\''+prefix+':'+addyd1c53cf16d53781f89c73b619c1bc224+'\'>'+addy_textd1c53cf16d53781f89c73b619c1bc224+'<\/a>';} { \includegraphics[width=7cm,angle=0]{"/home/bwmoore/svn_work/Consulting_Business/VG_Visuals/Dropbox/LOGOS/Logo - Tagline Below/MOORE LOGO Tagline"}} \setlength\parindent{24pt}

The bracket pairs contain the following:

• The first bracket pair contains the key value options that set up the block shapes and other parameters
• The second bracket pair contains the eyecatcher text; this is not used on this poster
• The third bracket pair contains the poster title
• The fourth bracket pair contains the poster authors
• The final bracket pair contains the logo or header graphic for the poster

### Creating a Text Box for a Single Column

BAPoster uses the headerbox tag to generate each box on the poster:

 \headerbox{Purpose}{name=purpose,column=0,borderColor=mssDeepBlue,headerColorOne=mssDeepBlue,headerColorTwo=mssDeepBlue,boxshade=none,headerFontColor=white}{ \paragraph{}This poster provides example econometrics to demonstrate using RStudio to generate a poster. }

The bracket pairs on the tag are as follows:

• The first bracket pair contains the text for the heading
• The second bracket pair contains the keywords for the tag, including these important tags:
• name is required and is needed to establish the relative position of boxes within a column.
• column is required to determine in which column the box should be placed
• borderColor and the other keywords are optional but will be used in almost all cases.
• The third bracket pair contains the text for the box. This can include any LaTeX tags for tables, lists, math, as long as the output will fit on the poster.

### Creating the Second Text Box in a Column

The second and subsequent text boxes in a column are identical to the first but must have a below keyword to reference the text box that is immediately above:

 \headerbox{Data Source}{name=dataSource,column=0,below=purpose,borderColor=mssDeepBlue,headerColorOne=mssDeepBlue,headerColorTwo=mssDeepBlue,boxshade=none,headerFontColor=white}{ \paragraph{}The data for this poster was pulled from the St. Louis Federal Reserve FRED2 system using the fImport R package. \paragraph{}The poster uses the \LaTeX\ \href{http://www.brian-amberg.de/uni/poster/}{BAposter} package and was composed in RStudio and generated using the knitr R package. It was formatted for A0 printing (33.11 by 46.81 inches), although BAposter supports other page sizes. \paragraph{}Lists use the normal \LaTeX\ list itemize environment. For example, the data series used in this poster are \begin{itemize} \item Swap rates \item Used Car and Rruck Consumer Price Index \item Median Household Income \item Unemployment Rate \item Mortgage Delinquency \end{itemize} }

### Creating a Text Box that Spans Columns

To emphasize a point, it will frequently be useful to create a text box that spans columns, as is done in the “Cost of Funds” block on this poster using the span keyword:

 \headerbox{Cost of Funds}{name=costOfFunds,column=1,span=2,borderColor=mssDeepBlue,headerColorOne=mssDeepBlue,headerColorTwo=mssDeepBlue,boxshade=none,headerFontColor=white}{ << costOfFunds,echo=FALSE,message=FALSE,warning=FALSE,error=FALSE,pdf.compress=TRUE,eval=TRUE,fig.path="images/figures/",dev=c("png","pdf","svg"),fig.width=6,fig.height=3,dpi=200>>= @ }

This text box incorporates R code that will be evaluated by the knitr package. knitr does not know the size of the LaTeX text box, so you will probably want to use the fig.width and fig.height keywords for the chunk to set the relative dimensions that you want for any graphics so that the proportions match what you need in the text box.

This web site uses cookies to provide user authentication and improve your user experience through the use of Google Analytics and Matomo Analytics. It also uses contact information for email and phone communcation. For details, see the Privacy Policy.