My apologies if this is noob-ish, but I was wondering if it might be possible to include line numbers for the text when converting from markdown to PDF? In case it helps, my use case is that I'm writing academic papers in markdown, but need to submit a PDF version (that includes line numbers in the output) when submitting it online.
Either in separately included LaTeX file or using YAML metadata on top of your Markdown document, add \usepackage[left]{lineno}. If you decided to use YAML metadata then it would something like this:
---
header-includes:
- \usepackage[left]{lineno}
...
My text.
I think you have to give the \linenumbers command as well.
header-includes:
My text.
```
@ericmjl -- Note that pandoc produces PDFs by going through LaTeX (by default). So if you want to know how to add a feature, it's usually a question of finding the right LaTeX package.
@wilx @jkr: wow you guys are amazing!!!!! :smile: :smile: :smile:
I think I get the logic now - if I want to use a LaTeX package, basically include it in the header-includes section of the YAML header. Is that correct?
I think I get the logic now - if I want to use a LaTeX package,
basically include it in theheader-includessection of the YAML
header. Is that correct?
Yes. Or, if you want more control, you can change the template that
pandoc uses to create latex output.
pandoc -D latex > mytemplate.latex to get the defaultmytemplate.latex in $DATADIR/templates (~/.pandoc/templatespandoc --template=mytemplate foo.md -o foo.pdfThis works the same for other output formats (html, etc) as well.
See http://pandoc.org/MANUAL.html#templates for more info.
One more possible way to do this is to put the \usepackage and setup lines into separate, say, header.tex file and then include it in preamble by invoking pandoc with --include-in-header=header.tex.
Most helpful comment
I think you have to give the
\linenumberscommand as well.``` .markdown
header-includes:
...
My text.
```
@ericmjl -- Note that pandoc produces PDFs by going through LaTeX (by default). So if you want to know how to add a feature, it's usually a question of finding the right LaTeX package.