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.texopen and the hook’s output ismain.pdf), or - The active tab’s stem matches the output’s stem (you have
essay.mdopen and the hook’s output is{{stem}}.html).
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.
scrollXandscrollYare preserved. - Image. Wrapper scroll position is preserved.
SyncTeX (LaTeX projects)
For PDFs produced bypdflatex -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
.texfile 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.
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
- Hooks. Set up the hook that produces the output.
- Editing an Overleaf LaTeX project. A complete LaTeX preview workflow.