20

I am using markdown & pandoc for scientific writing, I know I can change margins of the final pdf using

Set margin size when converting from Markdown to PDF with pandoc

but very often the journals require double lines and line numbers in submitted manuscripts, the question is how to change these, I don't know much about LaTex so I am lost in that jungle.

Thanks!

Community
  • 1
  • 1
Leosar
  • 2,010
  • 4
  • 21
  • 32
  • 1
    LaTeX provides the [`setspace` package](http://ctan.org/pkg/setspace), as well as [`lineno`](http://ctan.org/pkg/lineno). I'm unfamiliar with Pandoc's interface or usage, so I'm of no help there. If this turns out to be a purely TeX/LaTeX problem, consider flagging your own post and request migration to [TeX.SE](http://tex.stackexchange.com). Don't repost there; rather flag for migration. – Werner Feb 15 '13 at 00:41

3 Answers3

39

In more recent version of Pandoc, you can use a YAML header and include a bunch of metadata in that, instead of using options on the command line. So, for instance, you can put this at the top of your .md file:

---
title: The Document Title
author:
    - Your Name
    - Co Author
date: \today{}
geometry: margin=2cm
header-includes:
    - \usepackage{setspace}
    - \doublespacing
    - \usepackage{lineno}
    - \linenumbers
---

Document Text

and pandoc will read those options and apply them automatically.

naught101
  • 18,687
  • 19
  • 90
  • 138
24

There is maybe an easy way: generate a file with the packages we need

 \usepackage{setspace}
 \doublespacing
 \usepackage[vmargin=1in,hmargin=1in]{geometry}
 \usepackage{lineno}
 \linenumbers

I named it options.sty. And use the -H FILE option that includes the content of the FILE at the end of the preamble. (as used in https://github.com/karthikram/smb_git)

 pandoc -H options.sty --bibliography mypaper.bib mypaper.md -o mypaper.pdf 

The advantage is that we don't need to edit the template. To add linenumbers, change margins, and set spacing it works.

Leosar
  • 2,010
  • 4
  • 21
  • 32
13

You'll need to use a custom LaTeX template. First, use pandoc to create a copy of the default template:

pandoc -D latex > mytemplate.latex

Now edit this template. Somewhere in the preamble (between \documentclass{...} and \begin{document}), insert the lines

\usepackage{setspace}
\doublespacing

Then, to use your custom template:

pandoc --template mytemplate.latex mypaper.txt -o mypaper.tex
John MacFarlane
  • 8,511
  • 39
  • 33
  • To add line numbers I read the `lineno` package documentation but can't figure out how to add them. – Leosar Feb 17 '13 at 18:51