Germán Rodríguez
Stata Markdown Princeton University

Two-Column Slides

markstat 2.0 lets you take advantage of Pandoc's new syntax for columns, as illustrated in the following example using slides that show code and graphs side-by-side. Let us start with the script, which defines two slides. In both cases there is a left column with Stata code using the strict syntax, and a right column with a figure. I also change the delimiter to ; to allow the code to stretch over several lines without continuation comments.

% Two-Column Slides
% Germán Rodríguez
% November 10, 2017

# An Economist Graph {.fragile}

The [Stata Tutorial]( has a plot of U.S. Life
Expectancy over time using the Economist scheme. Here's the code and graph 

:::::: {.columns}
::: {.column}

#delimit ;
quietly sysuse uslifeexp, clear;
graph twoway line
  le_wmale le_bmale year, 
     clcolor(blue red)
	 title("U.S. Life Expectancy") 
	   order(1 "white" 2 "black") 
	   range(25 80)
quietly graph export economist.png, 
  width(500) replace;

::: {.column}

# Visualizing Regression Models {.fragile}

Dawn Koffman gave a [workshop](
on visualizing regression models using Ben Jann's `coefplot`. 
After reading the data, running a regression model, and storing the
estimates, she plots the coefficients:

webuse nhanes2, clear;
quietly tab region, gen(reg);
quietly logit diabetes female age bmi reg1-reg4;
estimates store fem_age_bmi_reg;

:::::: {.columns}
::: {.column}

#delimit ;
coefplot fem_age_bmi_reg, eform  
 drop (_cons) xscale(log)      
 xline(1, lwidth(vthin)) omitted
 cismooth grid(none) 
  female="female" age="age (years)"
  bmi="bmi" reg1="Northest" 
  reg2="Midwest" reg3="South"
  reg4="(reference cat) West",
  notick labsize(medlarge))
  title(Diabetes Risk Factors, 
quietly graph export coefplot.png,
 width(500) replace;
::: {.column}

The new syntax here is the use of colon fences, which are similar to code fences. The outer fences define columnar output, and the inner fences define the columns, which here default to equal width. For clarity I used six colons for the outer fences and three colons for the inner ones, but all that's required is three or more colons. Pandoc can distinguish opening and closing fences because openers always have attributes, here {.columns} for the outer one and {.column} for each of the inner ones. Inside these divisions we can use Markdown and Stata code as usual.

Save the script as twocols.stmd in the current working directory. Or download the script from this website using the Stata command:

copy twocols.stmd

Issuing the command markstat using twocols, strict slides(santiago) will produce the HTML presentation using the S5 engine with the Santiago theme shown here and embedded below:

If you have a LaTeX installation you can use the command markstat using twocols, strict beamer(madrid) to generate a PDF presentation via LaTeX using Beamer with the Madrid theme, as shown here. You can see screen captures of these slides in the carousel below.

Of course you can use any of the many Beamer themes available.

New in markstat 2.0