Tan Shuai

Quickly Convert Markdown to Academic-Style Paper PDF on macOS

Software Development

In this guide, I'll walk you through how I convert Markdown documents to academic-style paper PDFs on macOS using Pandoc and BasicTeX. This method is quick and straightforward, perfect for when you need to create professional-looking PDF files for your academic papers.

Step 1: Install Pandoc and BasicTeX

First, you'll need to install Pandoc and BasicTeX on your macOS system. Here's how I did it:

  1. Install Pandoc: Open Terminal and enter the following command to install Pandoc:

    brew install pandoc
  2. Install BasicTeX: Since MacTeX is quite large, I opted for the smaller BasicTeX package to save space. Run this command:

    brew install --cask basictex
  3. Install Common LaTeX Packages: To ensure you have the necessary packages for generating PDFs, run these commands:

    sudo tlmgr update --self
    sudo tlmgr install collection-basic collection-latex collection-latexrecommended collection-fontsrecommended

Step 2: Prepare Your Markdown File

Next, create your Markdown file (e.g., paper.md). Here’s how I set up my file, including the title, author, date, and contact information:

---
title: "Your Paper Title"
subtitle: "Optional Subtitle"
date: \today

author: |
  | Your Name
  | your-email@tanshuai.com
  | www.tanshuai.com
---

# Abstract

Your abstract here.

# Introduction

Your introduction here.

# Methodology

Your methodology here.

# Results

Your results here.

# Conclusion

Your conclusion here.

Step 3: Convert Markdown to PDF with Pandoc

Now, you can convert your Markdown file to a PDF. I used the following command in Terminal:

pandoc paper.md -o paper.pdf --pdf-engine=xelatex

This command uses Pandoc's default LaTeX template to convert the Markdown file into an academic-style paper PDF, including the author's contact information below their name.

Additional Tips

  • Custom LaTeX Template: If you need more advanced formatting or specific styles, you can create or download a custom LaTeX template and use it with Pandoc:

    pandoc paper.md -o paper.pdf --pdf-engine=xelatex --template=your-template.tex
  • More Metadata: You can add extra information in the YAML metadata header, such as an abstract or keywords, and use these in custom templates.

Conclusion

By following these steps, you can easily convert Markdown documents to academic-style paper PDFs on macOS. Using Pandoc and BasicTeX makes this process quick and efficient, perfect for when you need to generate professional PDF documents. Whether you're preparing academic papers, technical reports, or other formal documents, this method works great. Including contact information in the metadata header adds a professional touch to your documents.

I hope you find this guide helpful! If you have any questions or run into issues, feel free to reach out. Happy writing!