7
votes

I am using the markdown document created by R and I am trying to create the pdf file from the markdown using pandoc. Everything else works fine but I want the title of the document to appear and the numbering on the sections as in default Latex document. It seems the title defined on rmarkdown appears as a section title for the pdf.

I was able to create double spacing, enter line numbers etc by using a options.sty file. Below is the code that I used to create a pdf.

For options.sty I used:

 \usepackage{setspace}
\doublespacing

\usepackage[vmargin=0.75in,hmargin=1in]{geometry}
\usepackage{lineno}
\usepackage{titlesec}

\titleformat{\section}
{\color{red}\normalfont\Large\bfseries}
{\color{red}\thesection}{1em}{}

\titleformat{\subsection}
{\color{blue}\normalfont\Large\bfseries}
{\color{blue}\thesection}{0.8em}{}


\title{Monitoring Stations}
\author{Jdbaba}

I used knitr to create the R markdown file. In the above options.sty file, it seems the program is not taking title and author part. It seems I am missing something.

The code I used to convert markdown to pdf is as follows:

pandoc -H options.sty mydata.md -o mydata.pdf

In latex document, the pdf would have the automatic numbering as well. But my pdf is missing that. Can anyone suggest how numbering can be enabled on the pdf document created using pandoc ?

Thanks.

1
I was going to ask a question on RMarkdown/Pandoc too, and I agonised over whether it should appear here or on the Tex-LateX site. I think you will be better off migrating it to that site.Simon O'Hanlon
Read the pandoc documentation. Look for the options --number-sections and --table-of-contentsRamnath

1 Answers

8
votes

Pandoc takes the title from a title block in the Markdown file. This is a Pandoc-specific extension to Markdown. The block should have the following format:

% title
% author(s) (separated by semicolons)
% date

So, in your case:

% Monitoring Stations
% Jdbaba
% March 6, 2013

To have the sections numbered, you'll need to run Pandoc with the --number-sections option.