Can I set command line arguments using the YAML metadata

前端 未结 2 1047
有刺的猬
有刺的猬 2020-12-18 08:00

Pandoc supports a YAML metadata block in markdown documents. This can set the title and author, etc. It can also manipulate the appearance of the PDF output by changing the

2条回答
  •  渐次进展
    2020-12-18 08:20

    YAML metadata are not passed to pandoc as arguments, but as variables. When you call pandoc on your MWE, it does not produce this :

    pandoc -o guide.pdf articheck_guide.md --toc --number-sections
    

    as we think it would. rather, it calls :

    pandoc -o guide.pdf articheck_guide.md -V toc:yes -V number-sections:yes
    

    Why, then, does you MWE produces a toc? Because the default latex template makes use of a toc variable :

    ~$ pandoc -D latex | grep toc
    
    $if(toc)$
    \setcounter{tocdepth}{$toc-depth$}
    

    So setting toc to any value should produce a table of contents, at least in latex output. In this template, there is no number-sections variables, so this one doesn't work. However, there is a numbersections variable :

    ~$ pandoc -D latex | grep number
    
    $if(numbersections)$
    

    Setting numbersections to any value will produce numbering in a latex output with the default template

    ---
    title: My Title
    toc: yes
    numbersections: yes
    ---
    

    The trouble with this solution is that it only works with some output format. I thought I had read somewhere on the pandoc mailing-list that we soon would be able to use metadata in YAML blocks as intended (ie. as arguments rather than variables), but I can't find it anymore, so maybe it won't happen very soon.

提交回复
热议问题