Skip to content
Compilation Guide November 2026 · 8 min read

How to Fix Common Pandoc LaTeX Errors in Overleaf

When converting Markdown or Word documents to LaTeX with Pandoc and pasting the result into Overleaf, compilation halts frequently on missing macros and undeclared packages. Here is how to diagnose and resolve these errors cleanly.

Interactive Diagnostic Playground Available Paste your snippet into our browser-local checker to instantly highlight missing packages and copy required preamble definitions.
Open Preamble Checker →

1. Why Overleaf Fails on Raw Pandoc Code

Pandoc is an outstanding multi-format document engine, but its output format depends on whether you run it in standalone mode or fragment mode. By default, running pandoc input.docx -o output.tex produces a LaTeX fragment. Fragments contain only document body elements—such as paragraphs, headings, bullet lists, and tables—without a document class or package imports.

When authors paste these fragments into a pre-existing Overleaf template or a standard \documentclass{article} document, pdfLaTeX throws Undefined control sequence errors. The standard TeX distribution provides hundreds of packages, but standard document classes do not load them automatically.

2. Fixing Undefined Control Sequence: \tightlist

The most frequent error reported by researchers pasting Pandoc lists into Overleaf is:

! Undefined control sequence.
<argument> \tightlist
l.14 \tightlist

Pandoc inserts \tightlist inside itemize and enumerate blocks to eliminate vertical paragraph spacing between list items, replicating Markdown's compact bullet style. Standard LaTeX document classes do not define \tightlist.

The Solution: Add the following definition to your Overleaf document preamble before \begin{document}:

\providecommand{\tightlist}{%
  \setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}

Using \providecommand rather than \newcommand is recommended practice: if your template or document class already defines \tightlist, \providecommand quietly stands down rather than throwing a duplicate command error.

3. Fixing Undefined Control Sequence: \pandocbounded

Starting with Pandoc version 3.2.1, figure graphics are wrapped in a special sizing macro:

! Undefined control sequence.
l.28 \pandocbounded{\includegraphics[keepaspectratio]{fig1.png}}

Older versions of Pandoc emitted bare \includegraphics or explicit point dimensions. Pandoc 3.2.1 introduced \pandocbounded to ensure that large figures shrink to fit within \linewidth while smaller diagrams maintain their natural dimensions without upscale blur.

The Minimal Solution: If you only need compilation to succeed without automatic box bounding, add this dummy pass-through macro:

\providecommand{\pandocbounded}[1]{#1}

The Full Bounding Macro: To preserve Pandoc's responsive scaling behavior in Overleaf, insert the complete definition from the official Pandoc template:

\makeatletter
\newsavebox\pandoc@box
\newcommand*\pandocbounded[1]{%
  \sbox\pandoc@box{#1}%
  \ifdim\wd\pandoc@box>\linewidth
    \resizebox{\linewidth}{!}{\copy\pandoc@box}%
  \else
    \usebox\pandoc@box
  \fi
}
\makeatother

4. Missing LaTeX Packages: Tables and Figures

When converting tables or graphical manuscripts, Pandoc relies on several standard packages that are not bundled in basic LaTeX document classes:

For comprehensive formatting patterns, multi-column alignment, and table preamble setup, see our companion Word tables to LaTeX guide.

5. Fragment Output Versus Standalone Documents

Understanding Pandoc's operating modes prevents hours of confusion:

LaTeX Fragment

Produced by default in Pandoc CLI or when choosing LaTeX Fragment in our web converter. Ideal when pasting sections into an existing conference paper or collaborative journal template. Must be pasted inside \begin{document}.

Standalone Document

Produced when passing -s or --standalone in Pandoc CLI or selecting Complete Document in our web converter. Includes \documentclass and package imports. Upload directly as main.tex in Overleaf.

6. Minimal Working Overleaf Preamble

Here is a concise, verified preamble template configured specifically to compile Pandoc-generated LaTeX without undefined sequence errors:

\documentclass[11pt,a4paper]{article}

% Input and font encoding
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}

% Pandoc compatibility definitions
\providecommand{\tightlist}{%
  \setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}

\providecommand{\pandocbounded}[1]{#1}

% Required packages for tables, figures, and math
\usepackage{graphicx}
\usepackage{booktabs}
\usepackage{longtable}
\usepackage{array}
\usepackage{calc}
\usepackage{amsmath,amssymb}
\usepackage{multirow}
\usepackage{hyperref}

\begin{document}

% Paste your Pandoc fragment here

\end{document}

7. What Static Pre-flight Checking Cannot Detect

Our interactive checker provides quick feedback on missing macros and packages. However, static analysis is not a full LaTeX compiler and cannot replace compiling in Overleaf or TeX Live:

Static diagnostics are advisory. We advise you to recompile your document in Overleaf to confirm page breaks, floating figure placement, and bibliography resolution.

8. Primary Documentation References

Need to Convert Word Manuscripts to LaTeX?

Our Word to LaTeX browser extension cleans \tightlist and unwraps \pandocbounded commands directly inside browser memory before you copy to Overleaf.

Explore Word to LaTeX →