1

After spending 54 million years waiting for "TeX Live" (required by pandoc) to install, I was finally able to run the command to turn my .txt file into a PDF:

pandoc -i "1.txt" -o "1.pdf"

The result is a PDF with completely messed up text because it uses some other font than Courier[ New]. Some varying-width default font.

After reading and reading, I found this: https://pandoc.org/MANUAL.html#creating-a-pdf

The option "fontfamily" is mentioned, so I tried to do:

pandoc -i "1.txt" -o "1.pdf" --fontfamily=Courier

This results in:

Unknown option --fontfamily.
Try pandoc --help for more information.

I have looked through the entire "pandoc --help" output without finding any mention of fonts.

How do I set the font to be used?

1
  • 1
    -V 'fontfamily:dejavu' The -V stands for --variable. Checkout tex.stackexchange.com/questions/234786/… and you might want to spend a few million years more to install xelatex as latex-engine, then use --variable mainfont="DejaVu Sans"
    – ponsfrilus
    Commented Feb 4, 2020 at 17:02

2 Answers 2

2

You might try inserting some configuration at the top of your file. For example:

---
geometry: "left=25mm,right=25mm,top=10mm,bottom=25mm"
output: pdf_document
fontfamily: roboto
fontsize: 14pt
monofont: "Courier New"
toc: true
---

This sets both the default body text to be from the roboto family, the size, and the specific monospace font to use.

Just put this at the very top of your document.

2
  • roboto leads to a LaTeX Error: File roboto.sty' not found.` error with pandoc in.md -o out.pdf? panbdoc 2.9.2.1 Commented Oct 13, 2022 at 18:15
  • 1
    @starbeamrainbowlabs Pandoc uses an existing LaTeX installation. The installed LaTeX installation must provide all the classes you are referring to. In this case, the class 'roboto' is used. ctan.org/pkg/roboto In other cases it can become more difficult to determine the needed package. Commented Nov 22, 2022 at 16:26
-3

This is a solution relevant to the task at hand i.e. converting .txt to .pdf. Open the "yourfile".txt in Libreoffice correct the formatting if needed and export it as pdf. Task accomplished.

2
  • 2
    This way is not a pandoc solution as tagged from the OP. Commented Dec 8, 2020 at 18:29
  • Welcome to Super User! Please take the tour and read through the help center center. Here is a guide on How to Answer. Commented Dec 8, 2020 at 18:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .