24 May 2014

#toc in markdown doc

This post is related to:
  1. http://erwinirawansblog.blogspot.com.au/2014/07/bibliography-and-markdown.html
  2. http://erwinirawansblog.blogspot.com.au/2014/05/writing-example-of-marldown-to-docx.html
  3. http://erwinirawansblog.blogspot.com.au/2014/05/sci-writing-drafting-old-fashioned-way.html 

I usually create my Markdown (md) in R. Outlining is one of md's strength. So after composing a long doc with structured heading then our problem is "how can we make a table of contents (toc) out of it".
One solution is using "pandoc" with terminal command. Another way is to use "knitr" in R. you can type:
R> library(knitr)
R> knit2html('foo.Rmd', options=c('toc',markdown::markdownHTMLOptions(TRUE)))
Change the 'foo.md' with your Rmd file.
Then you get an html file with a nice toc as a result.
{@dasaptaerwin}

No comments: