Skip to content
sachsmc edited this page Oct 31, 2014 · 7 revisions

Using the templates

Getting set up

Dependencies

Optional

For evaluating R code

Getting started

Clone or download this repository to your working computer. Then, locate the folder corresponding to the journal you wish to submit to. Use the following table to find your journal. Can't find your journal? Request it here.

Folder name Journal(s) Link to style guide
amstat JASA, TAS, JBES, JCGS, SBP, Technometrics amstat
biometrical-journal Biometrical Journal biometrical-journal
biometrics Biometrics biometrics
biometrika Biometrika biometrika
biostatistics Biostatistics biostatistics
ims AOAS, AOP, AAP, AOS, SSY ims
jss Journal of Statistical Software jss
stats-in-med Statistics in Medicine statmed

Using the template

Copy the entire contents of the appropriate folder to your paper's working directory. If you are working on a paper called mypaper and it is located in ~/Papers/October/ and you want to submit to Biostatistics, then copy the contents of the biostatistics folder to ~/Papers/October/. The folders contain everything necessary to compile a markdown document into the correct Latex format.

Each folder comes with an example Rmarkdown file called example.Rmd and its associated bib file example.bib. The important metadata must be supplied in the yaml front-matter of the markdown document, which are key: value pairs enclosed between --- and ... at the top of the document. For example, the author, title, bibliography, and abstract are defined there:

---
title: Pandoc templates for common statistics journals
author:
- first: Michael 
  last: Sachs
  affilnum: a,b
  email: [email protected]
  ekey: e1
- first: Homer
  last: Simpson
  affilnum: b
  email: [email protected]
  ekey: e2
affiliation:
- name: National Cancer Institute
  key: a
- name: Moe's Tavern
  key: b
date: October 2014
year: 2014
abstract: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.'
keywords: In hac; habitasse; platea; dictumst
bibliography: example
...

Each journal has their own requirements for front-matter. For details, see the Wikis at the sidebar, or look at the example headers.

When you are ready to compile, it is simple from the command line:

make example.pdf

If you have an Rmd file with R code embedded in it, it will automatically be processed by knitr. If you have just an .md file, no problem, it will be processed directly. To save the intermediate tex file

make example.pdf example.tex

You may need to edit the tex by hand, but these templates will get you 99% of the way to submission.

Citations

The templates all use natbib to create the citations and reference list, except for AMSTAT, which requires the reference list be contained in the .tex file. In either case, references should be contained in a single bibtex file.

To create in-text citations, use the following guide. Pandoc automatically converts to the natbib style. The following is quoted from the Pandoc README

"Citations go inside square brackets and are separated by semicolons. Each citation must have a key, composed of '@' + the citation identifier from the database, and may optionally have a prefix, a locator, and a suffix. The citation key must begin with a letter or _, and may contain alphanumerics, _, and internal punctuation characters (:.#$%&-+?<>~/). Here are some examples:

Blah blah [see @doe99, pp. 33-35; also @smith04, ch. 1].

Blah blah [@doe99, pp. 33-35, 38-39 and *passim*].

Blah blah [@smith04; @doe99].

A minus sign (-) before the @ will suppress mention of the author in the citation. This can be useful when the author is already mentioned in the text:

Smith says blah [-@smith04].

You can also write an in-text citation, as follows:

@smith04 says blah.

@smith04 [p. 33] says blah.

If the style calls for a list of works cited, it will be placed at the end of the document. Normally, you will want to end your document with an appropriate header:

last paragraph...

# References

The bibliography will be inserted after this header. Note that the unnumbered class will be added to this header, so that the section will not be numbered."

YAML header

The md document needs to have a YAML header which contains metadata that will be rendered into the final document. This includes the title, abstract, author names, addresses, and so on. Each journal uses these items in unique ways in their Latex templates. Therefore, the headers differ slightly. The common entries are listed in the table below.

field description
title Every journal uses the title field. If your title contains a colon (:), enclose it in double-quotes (")
abstract Every journal uses the abstract field. If your title contains a colon (:), enclose it in double-quotes ("). Be sure to check the word limits.
bibliography Path to the .bib file. With the exception of AMSTAT, omit the .bib extension from the filename.

Details on the possible fields and options for each journal are listed in their own Wikis (see the sidebar). Some entries are allowed to be lists, which follow the following syntax. The list name is at the top. Each element of the list starts with - followed by the first named entry. Every element must contain the same named entries in the key: value syntax.

authors:
- name: Michael C. Sachs
  affiliation: National Cancer Institute, Bethesda, MD 20892
  email: [email protected]
- name: Homer J. Simpson
  affiliation: Moe's Tavern, Springfield, USA
  email: [email protected]

Other details

Raw tex

Raw tex can be inserted directly into the markdown document for things like, equation arrays, sidewaystables, subfloats, and so on. The Journal of Statistical Software encourages the use of the \proglang{} to indicate programming languages, \pkg{} to indicate packages, and \code{}. You can use these in the markdown document just as you would in Latex.

Figures

For figures generated in R, I recommend either using the pdf device, or better yet the tikzDevice. For the pdf device, use the chunk option dev='pdf'. For the tikzDevice, insert this chunk at the start of your document.

library(knitr)
knit_hooks$set(plot = function(x, options) {
  if ('tikz' %in% options$dev) {
    hook_plot_tex(x, options)
  } else hook_plot_md(x, options)
})

Then use the chunk option dev='tikz'. The main advantage of tikz is that the fonts in the figures will match the document fonts. See the knitr Graphics Manual for more details and examples.