16

I want to convert a document written in Markdown to PDF via TeX, so that it looks like I wrote it in TeX. The problem is that I don't want the page number. What do I write in the terminal in order to avoid it?

(I'm on a Mac if that makes any difference.)

Kurt Pfeifle
  • 3,791
  • You can always convert to LaTeX first, alter it to fit your needs, and then typeset with pdflatex; I'm not positive there is an option for this. – Sean Allred Oct 13 '13 at 15:17

3 Answers3

17

Based off this answer, you can disable pagenumbering by inserting the following LaTeX command at the beginning of your document:

\pagenumbering{gobble}

Or by inserting the following in the YAML metadata block:

header-includes:
- \pagenumbering{gobble}
mdeff
  • 125
daviewales
  • 1,313
13

You can look at the default (builtin) LaTeX template Pandoc is using:

pandoc -D latex | less

You'll discover that this template uses a variable named $pagestyle$. Searchengining for 'latex pagestyle' led me to conclude that a pagestyle named 'empty' may achieve what you want. So I ran this command:

pandoc               \
  -f html            \
  -o fsf.pdf         \
  -V pagestyle=empty \
     https://www.fsf.org

creates a PDF without page numbering... so I thought! When testing however, I found that the first page unfortunately still had a "1" at its bottom! The rest didn't...

So the next stage would be the following:

  1. Save the default LaTeX template of Pandoc into a file:

    pandoc -D latex > latex-pandoc.template
    
  2. Use your editor of choice to hack the template so the first page looses its page numbering too. (I do not currently know how this can be achieved in LaTeX -- would have to google it myself....) The result is latex-hacked.template.

  3. Now apply this template when creating your output:

    pandoc -f html             \
           -o fsf.pdf          \
           -V pagestyle=empty  \
           --template=latex-hacked.template \
             https://www.fsf.org
    

(Maybe there is another choice of pagestyle which avoids the first page numbering? Maybe it is a bug in the definition of the empty pagestyle in LaTeX? I'm sure one of the friendly members of the TeXExchange community will soon chime in and improve my answer if I'm wrong...)

Kurt Pfeifle
  • 3,791
6

Just use your template as described here:

PDF with numbered sections and a custom LaTeX header:

pandoc -N                                         \
  --template=mytemplate.tex                       \
  --variable mainfont=Georgia                     \
  --variable sansfont=Arial                       \
  --variable monofont="Bitstream Vera Sans Mono"  \
  --variable fontsize=12pt                        \
  --variable version=1.10                         \
  README                                          \
  --latex-engine=xelatex                          \
  --toc                                           \
  -o example14.pdf
Sean Allred
  • 27,421
guest
  • 76
  • 1
  • I want to use .txt not .tex

    is it

    --template=/Users/jacob/Desktop/myfile.txt
    
    

    or

    --template=myfile.txt
    
    

    ?

    I tried both, and got "pandoc: myfile.txt: openFile: does not exist (No such file or directory)" although the file does indeed exist.

    – user1603548 Dec 22 '13 at 16:49
  • 3
    I'd like to upvote and downvote your answer at the same time, for the following reasons: Writing a template requires Latex knowledge and it might take a day or two to get a good template together, if you don't have the Latex knowledge. It's good that you mention templates. However, the website you linked does neither explain nor describe how to write such a template, it only tells you how to use one - that's not really helpful. I myself needed multiple attempts on an separate days to create a template. It would be great if there was a tutorial about templates for Pandoc users. – Zelphir Kaltstahl Nov 14 '15 at 13:11