How to change the font size when exporting a markdown file as pdf on VS Code? (Markdown PDF - yzane)

Viewed 110

I have been using the Markdown PDF extension for almost 2 months now and been a big fan of it but I feel like the default font size is a bit big and I would like to edit that. I haven't played around with the default settings of any extension before so have no idea what to do.

1 Answers

You can add css files to change the style for the generator.

First, create a css file

You need to create the css file. For example, at the root of the project: markdown.css.

The content I use:

p, li, ul, code {
    font-size: 12px;
    line-height:150%;
}

Then, update the vscode project's settings

In the file .vscode/settings.json, add the lines:

"markdown-pdf.styles": [
    "markdown.css"
]

If the settings.json's file is missing, you need to create it and do not forget the curly brackets :

{
    "markdown-pdf.styles": [
       "markdown.css"
    ] 
}

To go further

markdown-pdf.styles is an option interpreted by the plugin (the list of the existing options). You can remove the default style with the option markdown-pdf.includeDefaultStyles set to false.

And if you want to adapt the css file to your needs, generate the markdown as an html file with the command: "Markdown PDF: Export (html)". And then, you can check the HTML tags.

Related