From Markdown to PDF: how to change the font-size with Pandoc?

35,929

Solution 1

Add this to your incantation:

-V fontsize=12pt

Solution 2

If you want to go bigger than 12pt you can use the extsizes package. Was already pre installed for me, so this worked out of the box with pandoc:

---
documentclass: extarticle
fontsize: 14pt
---

…

Possible sizes are 8pt, 9pt, 10pt, 11pt, 12pt, 14pt, 17pt, 20pt.

Solution 3

For new users of pandoc (like myself), as an alternative to specifying variables with the -V flag, you can add them to the YAML metadata block of the markdown file. To change the fontsize, prepend following to your markdown document.

---
fontsize: 12pt
---

Works with fontsize 10,11, and 12. In addition to the comments on John MacFarlane's answer, there is some good info on specifying additional fontsizes with latex in this article (inline latex can be used in pandoc markdown documents being converted to pdf).

Share:
35,929
pimpampoum
Author by

pimpampoum

Updated on April 28, 2021

Comments

  • pimpampoum
    pimpampoum about 3 years

    I'm converting some Markdown files into PDF using Pandoc like this:

    pandoc input.md -V geometry:margin=1in -o output.pdf 
    

    By default, the font-size is quite small in the pdf. I'd like to make all the fonts bigger (title, sub title, text, etc.). How can I do that?

  • pimpampoum
    pimpampoum almost 10 years
    I just tried "pandoc input.md -V fontsize=20pt -o output.pdf", and I don't see any difference in the fontsize of the pdf
  • John MacFarlane
    John MacFarlane almost 10 years
    The standard latex article document class doesn't support 20pt. Try 12pt.
  • pimpampoum
    pimpampoum almost 10 years
    And if I want to increase the size to 14pt, how can I do that?
  • xmojmr
    xmojmr almost 10 years
    @pimpampoum as John wrote the "standard.." does not support it. But it should be possible to fully customize the output through the pandoc templates. Take a look at the GitHub template repository where you should be able to tweak anything you need at github.com/jgm/pandoc-templates
  • John MacFarlane
    John MacFarlane almost 10 years
    Yes, this might be useful: ctan.org/tex-archive/macros/latex/contrib/extsizes. If you have this package installed, you can change your default latex template to use extarticle instead of article. Then some larger font sizes will be available. See the pandoc README on customizing your latex template.
  • brian
    brian over 3 years
    and how do i do that?