feat: add LaTeX/TikZ export for generated diagrams and plots (#137)#145
feat: add LaTeX/TikZ export for generated diagrams and plots (#137)#145itdeveloper1988 wants to merge 1 commit into
Conversation
…earch#137) Add TikZExporterAgent that converts generated images to compilable LaTeX source using the VLM, with --export-tikz on generate, --export-pgfplots on plot, and a standalone `paperbanana tikz` command for post-hoc conversion. - New TikZExporterAgent following BaseAgent pattern with prompt recorder - Pipeline integration with progress events, cost tracking, error handling - export_tikz / export_pgfplots settings with YAML key_map support - Separate prompt templates for methodology diagrams (TikZ) and plots (PGFPlots) - 19 tests covering agent, config, types, and CLI validation Closes llmsresearch#137
|
@YB0y can you please review my PR and give me feedback? Thanks. |
|
Hey @itdeveloper1988, heads up that PR #143 by @YB0y implements the same TikZ/LaTeX export for the same issue #137. This PR has better test coverage (19 tests) while #143 ships |
|
Hey @itdeveloper1988, after the recent updates PR #143 by @YB0y has become the more complete implementation (14 tests, PGFPlots support, venue/header metadata, post-hoc |
feat: add LaTeX/TikZ export for generated diagrams and plots (#137)
Problem
Academic publishers (IEEE, ACL, NeurIPS) require editable .tex source
files for figures. The current raster-only output (PNG/JPEG/WebP)
forced researchers to manually redraw generated diagrams in TikZ after
using PaperBanana for the conceptual work.
Changes
paperbanana/agents/tikz_exporter.py (new)
TikZExporterAgent extending BaseAgent; VLM call at temperature=0.2
with image + context; strips markdown code fences via regex;
prepends metadata header with version, model, venue, diagram type
prompts/diagram/tikz_exporter.txt (new)
prompts/plot/tikz_exporter.txt (new)
Prompt templates for TikZ and PGFPlots output with escaped braces
paperbanana/core/config.py
export_tikz and export_pgfplots boolean settings with YAML key_map
paperbanana/core/types.py
TIKZ_EXPORTER_START/END progress stages; tikz_path field on
GenerationOutput
paperbanana/core/pipeline.py
Instantiates TikZExporterAgent in init with prompt_recorder;
runs export after final image save with progress events, cost
tracking, and graceful error handling; _get_version() helper
paperbanana/cli.py
--export-tikz on generate; --export-pgfplots on plot; standalone
tikz subcommand for post-hoc conversion of existing images
tests/test_tikz_exporter.py (new, 19 tests)
_extract_code fence stripping (8 cases including case-insensitive)
Agent run with mocked VLM (header content, diagram type routing)
Config/types field defaults and overrides
CLI input validation (missing file, invalid type, invalid venue)
Behavior after this change
$ paperbanana generate --input method.txt --caption "..." --export-tikz
Saves final_output.png and final_output.tex side by side.
$ paperbanana tikz --input outputs/run_abc/final_output.png
Converts an existing image to a .tex file in the same directory.
Closes #137