11

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.)

1
  • 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. Oct 13, 2013 at 15:17

3 Answers 3

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
2
  • 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. Dec 22, 2013 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. Nov 14, 2015 at 13:11
11

Based off the answer here, you can disable pagenumbering simply by inserting the following LaTeX command at the beginning of your document, or in the YAML front-matter:

\pagenumbering{gobble}
1
  • 1
    This should be the accepted solution.
    – jottr
    Aug 25, 2019 at 10:20
10

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...)

3
  • 2
    For a single page document, I found that using the flag -V pagestyle=empty was sufficient to remove page numbers.
    – daviewales
    Feb 26, 2019 at 4:32
  • @daviewales; I have found -V pagestyle=empty to not work with a single page document. Dec 21, 2019 at 21:47
  • I also found that it doesn't work for the first page. See tex.stackexchange.com/a/44281/38399 for an explanation. IMHO a bug in LaTeX.
    – A. Donda
    Mar 23, 2020 at 20:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.