Skip to content

feat: add LaTeX/TikZ export for generated diagrams and plots (#137)#145

Closed
itdeveloper1988 wants to merge 1 commit into
llmsresearch:mainfrom
itdeveloper1988:fix/issue-137
Closed

feat: add LaTeX/TikZ export for generated diagrams and plots (#137)#145
itdeveloper1988 wants to merge 1 commit into
llmsresearch:mainfrom
itdeveloper1988:fix/issue-137

Conversation

@itdeveloper1988
Copy link
Copy Markdown

@itdeveloper1988 itdeveloper1988 commented Apr 8, 2026

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

…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
@itdeveloper1988
Copy link
Copy Markdown
Author

itdeveloper1988 commented Apr 9, 2026

@YB0y can you please review my PR and give me feedback?

Thanks.

@dippatel1994
Copy link
Copy Markdown
Member

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 examples/tikz_export.py. Could you two coordinate on a single PR? Also lint is failing here - please run ruff check && ruff format and push.

@dippatel1994
Copy link
Copy Markdown
Member

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 tikz CLI subcommand). I'm going to close this PR in favor of #143 to avoid duplication. Thank you for the contribution! Please feel free to follow up with additional improvements on top of #143 once it merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Export generated diagrams as LaTeX / TikZ source code

2 participants