Skip to main content
When a hook has an output field set (a path to the artifact it produces, e.g. main.pdf, essay.html, diagram.svg), DocWriter shows a floating Preview button in the top-right of the editor. Clicking it opens a popup window that displays the artifact and reloads automatically every time the hook produces a new version.

How matching works

The preview button appears when the active tab matches a hook’s output path. The matching is conservative. It triggers when:
  • The active tab is the source file the hook consumes (e.g. you have main.tex open and the hook’s output is main.pdf), or
  • The active tab’s stem matches the output’s stem (you have essay.md open and the hook’s output is {{stem}}.html).
If the button does not appear, the most likely cause is the hook’s output field is empty or the active tab does not match any hook’s scope. See Hooks.

Opening the preview

Click the Preview button. A popup window opens, sized 900×1200, showing the rendered artifact. DocWriter supports four kinds of output:

Live reload

The preview window subscribes to a server-sent-events bus. Every time your hook finishes, the preview reloads the file:
  • PDF. Scroll position, page number, and zoom level are preserved across reloads.
  • HTML. scrollX and scrollY are preserved.
  • Image. Wrapper scroll position is preserved.
You do not need to refresh manually. The header shows the timestamp of the last reload and a connection-status indicator (connected / disconnected).

SyncTeX (LaTeX projects)

For PDFs produced by pdflatex -synctex=1 (the LaTeX template hook provides this flag), the preview supports two-way navigation between the PDF and the source:
  • Backward sync. Double-click any text in the PDF. DocWriter resolves the click to the source .tex file and line, switches to that file in the editor, and scrolls to the line.
  • Forward sync. In the editor, the menu has a Show in PDF command. The preview window scrolls to the corresponding page and position.
Both directions shell out to the synctex binary (part of TeX Live and MacTeX). If synctex is not on your PATH, both directions silently no-op.

Themes

The preview window picks up the editor’s current theme (light, dark, solarized, etc.) and applies it to the PDF.js viewer chrome. The document itself is unchanged. Themes only restyle the viewer, not the rendered PDF or HTML.

When the preview button is not enough

For workflows that produce non-file outputs (server logs, REPL output, test results), use the history pane to follow hook output instead. Every hook run’s stdout and stderr is captured there.

Where to go next