How to extract every figure from a research paper
A practical look at the figure-extraction problem — why naive approaches fail, what works in practice, and how to build a usable 'all figures at a glance' view.
When you're reading a research paper carefully, you end up flipping back and forth between the prose and the figures constantly. "Wait, what did Figure 3 show?" Scroll up. "Was that in Figure 3 or Figure 4?" Scroll back. By paper number five of the day, your mouse wheel is the part of you that's exhausted.
The fix is obvious in principle: extract every figure and table in the paper into one visual grid, captions and page numbers attached, click any one to jump to it in context. The fix is much harder in practice. This post is about why, and what works.
Why "just extract the figures" is harder than it sounds
A PDF is a presentation format, not a structured document. There's no <figure> element. There's just text positioned at coordinates, lines drawn between points, and images embedded as raster blobs or vector paths.
The figure on page 4 isn't tagged as a figure. It's:
- An embedded JPEG, or
- A set of SVG-like vector commands the publisher's typesetter emitted, or
- A combination — vector axes, raster photos inside them, with text labels positioned separately
To extract "Figure 3" you have to:
- Identify the visual region of the page that constitutes the figure
- Identify the caption text (which is positioned outside the visual region but logically attached)
- Link the two
Each of these is genuinely hard.
The naive approaches and why they fail
Approach 1: Just rasterize the whole page and crop. Easy. Loses the caption-as-text. Loses vector quality. Acceptable for thumbnails; terrible for "click to see at full quality."
Approach 2: Look for embedded images. Misses every vector figure (which is most of them in math, physics, and CS). Also misses tables, which we want too.
Approach 3: Use the publisher's structured tags if present. PDFs can include semantic tags via Tagged PDF markup. In practice almost no academic publishers emit them, and the ones that do emit them inconsistently.
Approach 4: Look at the table-of-figures back-link. If the paper has a list of figures, each entry usually links to a page coordinate. You can follow those links. Works for some papers; many don't have a list of figures.
What actually works
The pragmatic approach we ended up with combines a few signals:
1. Find the caption text
Captions are the most reliable signal in a PDF. They always start with Figure N. or Fig. N or Table N. followed by the caption text. A regex over the extracted text — \b(Figure|Fig\.?|Table)\s+(\d+|[IVX]+)[\.:]\s+(.+?)(?=\n\n|\Z) — finds them with very high precision.
Once you've found the caption text, you know:
- Which page it's on
- The pixel coordinates of the caption text (via the PDF text-extraction layer)
- The text content of the caption
2. Find the visual region
From the caption's position, you look above the caption (figures are above their captions in 99% of cases — Figure N. is the introduction of the figure for the reader's eye). The visual region is everything from the bottom edge of the previous paragraph down to the top edge of the caption.
This is a heuristic, not a guarantee. Multi-column layouts complicate it. Captions that flow onto the next page break it. Tables sometimes have their captions above (unlike figures, which have them below). But for the median case it works well.
3. Crop and render
You take the bounding box from step 2, render that region of the PDF page at high resolution (3x retina for quality), and you have your figure image. Attach the caption text and you're done.
The user-facing payoff
Once you have [{ label, caption, page, image }] for every figure and table, you can do interesting things:
- A grid view of all figures, captions visible, click to jump to source
- Search by caption text ("find me the panel about hippocampus")
- Side-by-side comparison of figures from different papers
- Pull a single figure's data via plot digitization (we covered that in a previous post)
For the reader, the cognitive effect is enormous. Instead of scrolling back to find the panel you half-remember, you press a key and see all panels at once. The figure becomes a first-class object in your reading experience, not a thing buried somewhere in the prose.
Edge cases worth knowing
- Subfigures. Many figures have
(a),(b),(c)sub-panels. Treating them as one figure (with the parent caption) is usually right; treating them as separate figures sometimes gets you closer to what the user actually wants. - Equations. Numbered equations look like figures structurally — a visual region, a number for back-reference. Some readers extract them too. We chose not to; equations are usually read inline.
- Schematics with text inside. A flowchart with labeled boxes contains text that the PDF text layer treats as paragraph text. The extracted "page text" can end up with the box labels mixed in. Filtering by font size and column position helps.
- Rotated landscape figures. Some figures take up a full landscape page with the paper rotated 90°. Handle the rotation transform when rendering or you'll get a sideways thumbnail.
What Voixes does
You can try it on any paper in Voixes — open a PDF, press the Quick Glance button in the toolbar, and you'll see every figure and table extracted into a grid view. Click any one to jump to its location in the text.
What's still hard
Figure extraction works well enough to ship. It still occasionally misses panels in unusual layouts, and the caption-vs-figure association is wrong maybe 2–3% of the time. For most papers in most fields it's reliable; for design-heavy publications (architecture, certain humanities papers) the heuristics break down.
If you're building this yourself, the iteration loop is: run on 50 real papers from your target field, look at the failures, fix the heuristic. Repeat. There's no clever model that gets you out of the long tail.
Voixes is a native Mac app for reading research papers. Quick Glance extracts every figure and table from any PDF into a single visual board — without the paper leaving your Mac.