active library

texwatch

Live-reloading TeX editor with PDF viewer in the browser

Started 2026 Python

Resources & Distribution

Source Code

Package Registries

texwatch

Live-reloading TeX editor with PDF viewer in the browser. Edit LaTeX, see the PDF update instantly, click between source and output.

Why

Writing LaTeX means compiling, switching windows, scrolling to find your place, checking for errors, switching back, fixing, recompiling. Every cycle costs seconds that add up to hours.

texwatch collapses that loop into one command. Run texwatch in your project directory and it watches every .tex and .bib file, recompiles on save, and serves a split-pane editor+viewer at localhost:8765. SyncTeX links source lines to PDF positions bidirectionally — double-click a line to jump the PDF there, click the PDF to jump the editor back. Errors appear inline with surrounding source context, not buried in a log file.

What sets it apart:

  • Bidirectional SyncTeX in the browser — no IDE plugin required
  • Semantic paper analysis — bibliography health, environment inventory, document metadata, all available from the CLI or API
  • AI-native — an MCP server gives Claude Code full read/write access to your paper state, so it can navigate, inspect, and edit your document directly
  • Multi-project — serve an entire directory of papers from one process, each on its own route

Install

Requires Python 3.10+

pip install texwatch

Optional extras:

pip install texwatch[capture]   # PDF screenshot support (pymupdf)
pip install texwatch[mcp]       # Claude Code integration (MCP server)

Requires latexmk (or pdflatex/xelatex/lualatex) on your PATH.

Quick start

cd my-paper/
texwatch init          # creates .texwatch.yaml
texwatch               # starts server, opens at http://localhost:8765

The browser UI has three panes: file tree, CodeMirror editor, and PDF viewer. Save a file anywhere in the project and the PDF reloads automatically.

Common use cases

Navigate from source to PDF:

Double-click a line in the editor, or press Ctrl+Enter to jump the PDF to that position.

Navigate from PDF to source:

Click anywhere in the PDF to scroll the editor to the corresponding source line.

Jump to a section:

texwatch goto "Related Work"    # fuzzy matches section titles
texwatch goto 42                # jump to line 42
texwatch goto p3                # jump to page 3

Check compilation errors (from another terminal):

texwatch status
texwatch compile --json

Get a paper overview:

texwatch dashboard              # unified view: health, sections, issues, bibliography
texwatch dashboard --section bibliography
texwatch bibliography           # shortcut for bibliography analysis
texwatch environments           # list all LaTeX environments
texwatch digest                 # document metadata (title, author, class)

Screenshot a PDF page:

texwatch capture output.png --page 1 --dpi 300

Serve multiple projects:

texwatch serve --recursive --dir ~/papers/
# Dashboard at http://localhost:8765, each project at /p/{name}/
texwatch current                # show which project is active
texwatch current other-paper    # switch to a different project

Configuration

.texwatch.yaml in your project root:

main: paper.tex
watch:
  - "*.tex"
  - "*.bib"
ignore:
  - "old_*.tex"
compiler: latexmk     # auto | latexmk | pdflatex | xelatex | lualatex
port: 8765
page_limit: 8         # optional: flag when PDF exceeds N pages

Multi-paper projects: Use the papers: key to define multiple compilable documents in one directory:

papers:
  - name: main-paper
    main: paper.tex
  - name: supplementary
    main: supplement.tex
    compiler: pdflatex
watch:
  - "*.tex"
  - "*.bib"

Each paper appears as a separate project at /p/{dirname}/{name}/.

Web UI features

  • Editor: CodeMirror 6 with LaTeX syntax highlighting, word wrap toggle, conflict detection when files change on disk
  • Viewer: PDF.js with continuous or paged scroll, SyncTeX highlight overlay
  • Error panel: Compile errors/warnings with clickable source locations and surrounding context lines
  • TODO panel: Collects % TODO, % FIXME, \todo{} annotations from all .tex files
  • Log viewer: Full LaTeX compilation log, toggled from the error panel
  • File tree: Navigate and open project files (.tex, .bib, .cls, .sty, etc.)
  • Structure: Parses \section, \input/\include tree, word count (via texcount)

Claude Code integration

texwatch includes an MCP server that gives Claude Code full access to your paper’s state and source files. When you run texwatch serve, it auto-registers itself in your project’s .mcp.json — no manual configuration needed.

If you prefer manual setup:

// .claude/.mcp.json
{
  "mcpServers": {
    "texwatch": {
      "command": "texwatch",
      "args": ["mcp"]
    }
  }
}

MCP tools

ToolDescription
texwatchGet complete paper state (health, sections, issues, bibliography, changes, environments, editor/viewer context, file tree, recent activity)
texwatch_sourceRead source file content
texwatch_historyGet previous versions of a source file (saved before each write)
texwatch_gotoNavigate PDF viewer to a line, page, or section
texwatch_compileTrigger recompilation
texwatch_write_sourceWrite content to a source file with conflict detection
texwatch_captureScreenshot current PDF page as PNG (base64)
texwatch_projectShow or switch the current project

This lets Claude see your full paper state — sections, compile errors, bibliography, word count — and navigate, recompile, or edit source files directly.

CLI reference

CommandDescription
texwatch initCreate .texwatch.yaml in current directory
texwatch / texwatch serveStart the watcher and web server
texwatch statusShow compile status, errors, viewer state
texwatch viewShow editor and viewer pane state
texwatch goto <target>Navigate to line, page (p3), or section name
texwatch compileTrigger recompilation
texwatch capture <file>Screenshot PDF page to PNG
texwatch configView or modify .texwatch.yaml
texwatch filesList project file tree
texwatch dashboardUnified paper dashboard (health, sections, issues, bibliography, changes, environments)
texwatch bibliographyShow bibliography analysis
texwatch environmentsList LaTeX environments
texwatch digestShow document metadata (title, author, class)
texwatch activityShow recent activity events
texwatch currentShow or switch the current project
texwatch scan <dir>Find projects with .texwatch.yaml
texwatch mcpRun MCP stdio server for Claude Code

Most commands accept --port, --json, and --project flags.

Exit codes

CodeMeaning
0Success
1General failure (compile error, file not found, etc.)
2Argument parsing error
3Server not running (for commands that require a running server)

HTTP API

When texwatch serve is running, the following endpoints are available. For multi-project mode, prefix with /p/{project_name}.

EndpointMethodDescription
/statusGETCompile status, errors, viewer/editor state
/compilePOSTTrigger recompilation
/gotoPOSTNavigate to {"line": N}, {"page": N}, or {"section": "..."}
/pdfGETServe the compiled PDF
/sourceGETGet source file content (?file=...)
/sourcePOSTUpdate source file ({"file": "...", "content": "..."})
/filesGETProject file tree
/errorsGETCurrent errors and warnings
/contextGETEditor/viewer state + current section + word count
/structureGETDocument structure (sections, TODOs, inputs)
/captureGETScreenshot PDF page as PNG (?page=N&dpi=N)
/dashboardGETUnified paper state (all sections combined)
/bibliographyGETBibliography entries and citation analysis
/environmentsGETLaTeX environment inventory
/digestGETDocument metadata (title, author, document class)
/activityGETRecent activity events
/history/{file}GETPrevious versions of a source file
/configGETProject configuration
/currentGETCurrent project name
/currentPOSTSwitch current project
/wsWebSocketReal-time updates (compile events, navigation)
/projectsGETList all projects (multi-project mode)

License

MIT

Discussion