A native PDF view for Emacs on macOS, made for writing LaTeX.
A PDF opens in an ordinary Emacs window, but what you see there is a WebKit
view laid over it. Scrolling and pinch-zoom are the system's own, with
momentum. The keyboard never leaves Emacs, so the PDF buffer has ordinary
Emacs keys and C-M-v scrolls it from the source window.
- SyncTeX both ways.
vellum-forward-searchshows where point's line was set, with a band that fades. A double click or a command-click in the PDF goes to the source, down to the word. - Recompiles without a flicker. When the compiler rewrites the PDF, the new one is prepared out of sight and swapped in at the same place and zoom.
- Links. A click follows a link: a reference, a citation, an entry in the
table of contents. Resting the pointer on one shows where it leads, so a
figure or a reference can be checked without going there.
Flabels the links in view, to follow one from the keyboard.lgoes back to where you were; a web address op 7F0A ens withbrowse-url, even one that is only plain text in the PDF. - Search, outline, copy.
C-s,imenu(the PDF's table of contents), andM-won a mouse selection.M-s olists the lines matching a regexp, asoccurdoes;M-g nandM-g pgo through them in the PDF. - Trimmed margins.
ccuts the margins away so the text fills the window; odd and even pages are each cut to their own text block. - Two pages side by side.
2pairs the pages;C-u 2sets the first alone, as a book opens. - Thumbnails.
topens a column of the pages beside the document, at once however long it is; a click on one goes there. - Dark pages.
iturns the page's white into the theme's background and its black into the theme's foreground, keeping the hue of what is coloured. Under a light theme the pages go dark grey. Setvellum-dark-pagestoautoto have them dark whenever the theme is. - Splits like any buffer. Each window showing a PDF has its own view, with its own place and zoom; keys go to the selected window's.
- A caret, moved as point is. A click puts a caret in the text (or
vdoes, at the top of the view), and Emacs's own motions move it:M-f,M-e,C-n,C-x ], isearch, expand-region.C-SPCstarts a region, and a stroke of the mouse makes one;M-wcopies it with its lines joined, andSsends it tovellum-send-function(an agent's prompt, say) saying the page it is from. Escape takes the caret away. A faint band marks the caret's line, to read by as with a ruler. - Highlights and notes. With a region,
hhighlights it andagives it a note;Alists them all, to go to, take away (d) or note again (e).C-x C-swrites them into the PDF, where any reader shows them. They are for reading: a PDF rebuilt by its compiler loses those saved. - Places to come back to.
C-x r mbookmarks the place,mkeeps it in a register for'(orC-x r j) to go back to, andorg-store-linkmakes avellum:link to the page. - It remembers where you were in each file.
macOS, a graphical Emacs 29 or later built with dynamic modules (no xwidgets
needed), the Xcode Command Line Tools, and synctex from TeX Live.
Clone it, put it on the load-path, and:
(autoload 'vellum-mode "vellum" nil t)
(add-to-list 'auto-mode-alist '("\\.pdf\\'" . vellum-mode))
(with-eval-after-load 'tex (vellum-auctex-setup))
The module is built the first time a PDF is opened; make builds it by hand.
With straight.el (or Doom's package!), the recipe needs nothing beyond the
repository: the module and the viewer are found in the checkout.
(package! vellum :recipe (:host github :repo "dangom/vellum"))
vellum-auctex-setup makes Vellum AUCTeX's PDF viewer, so C-c C-v is a
forward search.
| Key | |
|---|---|
C-n C-p j k |
a line down, up |
SPC DEL C-v M-v |
a screen down, up |
n p |
next, previous page |
M-< M-> |
start, end |
M-g g |
go to a page |
+ - w f 1 |
zoom in, out; fit width; fit page; actual size |
c |
trim the margins, or show them again |
t |
a column of thumbnails beside the document |
i |
dark pages, or pages as printed |
2 |
two pages side by side, or one again; C-u 2 as a book |
C-s C-r |
search, and again; C-g clears the marks |
M-s o |
list the lines matching a regexp |
o |
outline |
F |
follow a link by its label |
l B N |
back after a link or a jump; back; forward again |
v |
a caret in the text, moved with Emacs's motions; Escape ends it |
S |
with a caret: send the region, saying where it is from |
h a |
with a region: highlight it; highlight it with a note |
A |
list the highlights and notes; C-x C-s saves them into the PDF |
m ' |
keep the place in a register; go to a register |
M-w |
copy the selection |
g |
reload |
src/vellum-module.m: the dynamic module. It ownsWKWebViews, places them over rectangles of an Emacs frame, runs JavaScript in them, and passes their messages back through a pipe. It knows nothing about PDFs.web/: the viewer, which is pdf.js (vendored inweb/pdfjs, version inweb/pdfjs/VERSION) andvellum.js.vellum.el: the mode. It keeps each view over the window showing its buffer, talks to the viewer, and runs thesynctexcommand-line tool.
- WebKit does not paint a window that is entirely hidden behind others, so a PDF loaded in a covered frame appears when the frame is next seen.
- Pages are drawn on white whatever the theme; the space around them takes the theme's background.
- Very large documents are pdf.js's weak spot; PDFKit would be faster there.
GPL-3.0-or-later. pdf.js is Apache-2.0; see web/pdfjs/LICENSE.