Create a pdf header and numbering sections using R markdown with pandoc

I am using a markdown document created by R and I am trying to create a PDF file from markdowns using pandoc. Everything else works fine, but I want the title of the document to appear and section numbering, as in the default Latex document. It seems that the name given in rmarkdown looks like a section title for pdf.

I managed to create a double spacing, enter line numbers, etc. using the options.sty file. Below is the code I used to create the 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. markup file. In the options.sty file above, it seems that the program does not accept the title and part of the author. I think I'm missing something.

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

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

Automatic pagination will also be included in the pdf latex document. But my pdf is missing. Can anyone suggest how numbering can be included in a pdf document created using pandoc?

Thanks.

+6
source share
1 answer

Pandoc takes the header from the header in the Markdown file. This is a Pandoc-specific extension for 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 partition numbering, you need to run Pandoc with the --number-sections option.

+7
source

All Articles