Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to specify numbered sections in Pandoc's front matter?

Tags:

yaml

pandoc

I would like to specify numbered sections via Pandoc's support for YAML front matter. I know that the flag for the command-line usage is --number-sections, but something like

--- title: Test number-sections: true --- 

doesn't produce the desired result. I know that I am close because you can do this with the geometry package (e.g. geometry: margin=2cm). I wish there was a definitive guide on how Pandoc YAML front matter handling. For example, the following is very useful (avoids templates), but its discoverability is low:

 header-includes:   - \usepackage{some latex package} 
like image 683
tlnagy Avatar asked Jun 13 '14 15:06

tlnagy


People also ask

How do you use extensions in Pandoc?

An extension can be enabled by adding +EXTENSION to the format name and disabled by adding -EXTENSION . For example, --from markdown_strict+footnotes is strict Markdown with footnotes enabled, while --from markdown-footnotes-pipe_tables is pandoc's Markdown without footnotes or pipe tables.

Is Pandoc secure?

The python package pandoc was scanned for known vulnerabilities and missing license, and no issues were found. Thus the package was deemed as safe to use.

Where are Pandoc templates?

Some Pandoc templates for an article in PDF (vita LaTeX), HTML, or Microsoft Word. These go in ~/. pandoc/templates . These can be be pointed to directly with the --template= switch as appropriate.


2 Answers

In order to turn on numbered-sections in latex output you need to use numbersections in your YAML block. If you ever want to "discover" things like this with pandoc just poke around the templates:

 $ grep -i number default.latex  $if(numbersections)$  $ grep -i number default.html*  $ 

As you can see this option does not work with html.

Markdown and YAML I tested with:

 ---  title: Test  numbersections: true  ---    # blah   Text is here.   ## Double Blah   Twice the text is here 

If you need it to work with more than beamer,latex,context,opendoc you will need to file a bug at github.

like image 84
dfc Avatar answered Sep 28 '22 06:09

dfc


In order to show section number in the produced output pdf, there are two choices.

In YAML front matter

Add the following setting to begin of markdown file

--- numbersections: true --- 

In command line

We can also use the command option to generate pdf with numbered section. According to Pandoc documentation, the correct options is --number-sections or simply -N,

pandoc test.md -o test.pdf --number-sections # pandoc test.md -o test.pdf -N 
like image 36
jdhao Avatar answered Sep 28 '22 07:09

jdhao