feat: add LaTeX/TikZ export for generated diagrams and plots#143
Conversation
|
Hi @dippatel1994 I've opened PR for new feature. Could you please review this and share any feedback? |
|
Hey @YB0y, heads up that PR #145 by @itdeveloper1988 implements the same TikZ/LaTeX export feature for the same issue #137. PR #145 includes 19 tests while this one ships |
|
Hi @dippatel1994 Thank you for your feedback. I added test code and fixed lint error. Could you take another look at this? |
dippatel1994
left a comment
There was a problem hiding this comment.
Tests added (14 functions covering extract_code, agent run, and CLI subcommand) and lint clean. Nice PGFPlots support and venue/header metadata. Thanks @YB0y!
|
Hey @YB0y, CI is failing with |
|
@dippatel1994 Thank you for taking the time to review my PR. I’ve resolved the conflicts and lint errors. Could you please take another look? |
|
Hey @YB0y, lint passes now but all 9 test jobs are still failing. Please check the test failures locally with |
|
Hey @YB0y, tests are still red. Two failures:
|
…re/tikz-export # Conflicts: # paperbanana/cli.py # paperbanana/core/pipeline.py # paperbanana/core/types.py
674dafd to
66c39b2
Compare
|
@dippatel1994 please review this. |
|
@dippatel1994 , I’d appreciate it if you could review this when you have time. |
Summary
TikZExporterAgent— a new VLM-powered agent that converts any generated image to compilable LaTeX source by reasoning about its visual structure--export-tikz(diagrams) and--export-pgfplots(plots); the.texfile is saved alongside the raster output in the same run directorypaperbanana tikz --input <image>subcommand for post-hoc conversion of any previously generated imageexamples/tikz_export.pydemonstrating all three usage patternsMotivation
Academic venues (IEEE, ACL, NeurIPS camera-ready) require editable figure source files. Until now, the only output was raster images (PNG/JPEG/WebP), forcing researchers to manually redraw figures in TikZ after using PaperBanana for the conceptual work. This PR closes that gap without changing any existing behaviour — export is opt-in via flags.
Changes
agents/tikz_exporter.pyTikZExporterAgentextendingBaseAgent; VLM call attemperature=0.2with image + context; strips code fences; prepends metadata headerprompts/diagram/tikz_exporter.txt\begin{tikzpicture}snippet using only standard packagesprompts/plot/tikz_exporter.txt\begin{axis}structurecore/config.pyexport_tikz: boolandexport_pgfplots: boolsettings; YAML key map entriescore/types.pyTIKZ_EXPORTER_START/ENDprogress stages;tikz_path: Optional[str]onGenerationOutputcore/pipeline.pyTikZExporterAgent; runs it after the final image is saved; writes.tex; populatesresult.tikz_path; budget/cost tracking includedcli.py--export-tikzongenerate;--export-pgfplotsonplot;tikz_pathprinted in result output; newtikzsubcommandexamples/tikz_export.pyUsage
Test plan
paperbanana generate --input ... --caption ... --export-tikzproduces a.texfile alongside the PNG with correct metadata headerpaperbanana tikz --input <existing_image>writes a.texfile to the same directorypaperbanana plot --data ... --intent ... --export-pgfplotsproduces PGFPlots output--export-tikzabsent → no.texfile written,result.tikz_pathisNone(no behaviour change).texcompiles underpdflatexwithout errors on a sample diagrampaperbanana tikz --helpshows all flags correctlyCloses #174