I am generating a lot of plots and tables (in Julia) for a research project, to be shared with coauthors. It used to be that I would dump the tables in a directory and tried to be good with file naming, but it got beyond manageable. The purpose is now to generate a single PDF file for discussion of results, and then select what goes into the paper.
Now, when I dump the plots and tables, I would prefer to simultaneously generate a LaTeX document, with section headings, table/figure captions, and inclusion of the relevant figure. Eg the API I would imagine is something like this:
ltx = start_LaTeX_document("some_path.tex"; packages = ["booktabs"])
# ^ adds preamble, already includes graphicx
add_section(ltx, "Baseline plots")
add_figure(ltx, "What a nice figure", "some_figure_path.pdf")
add_subsection(ltx, "The robustness checks that will make the editor complain"
* "that the paper is now too long even though he asked for them")
add_table(ltx, "Some table", "some_table_dump.tex")
end_LaTeX_document(ltx)
I can just mock this up quickly but wanted to ask if there is a package that does this already.
If you only need very basic structure and formatting, it might be easier to generate a simpler format like Markdown, and then use Pandoc to convert it to LaTeX.
Quarto + Julia works great! Every time you change your Julia code in the project, it reruns it, updates the results and plots, generates LaTeX source, and compiles an updated PDF.
I used Quarto for exactly this scenario. Generate all of your plots, then generate a quarto document that references them, along with whatever other text, tables, etc., that you need. Instead of going to latex, I used Quarto’s option (embed_resources) to generate a single, all-inclusive HTML file that users could then open and navigate in their browser.
Last I looked into Quarto it outsourced those things to Pandoc, so if you want completeness you should probably look in their documentation. Or skip Quarto and directly use Pandoc.
In situations similar to yours (but not exactly the same, either), I’ve found Literate.jl (and its markdown output) + pandoc to be both useful and very easy to learn/use.
I like the “API-free” approach where you write Julia code and surround it with Markdown-formatted comments which will appear in the document. Which is not exactly what you had in mind, but might still fit your use case.
I have done this in the past! My suggestion is to have a .tex template with a place holder like:
<-- TABLE 1 -->
Then, you generate the table in Julia (you can use PrettyTables.jl for LaTeX) and put the result in a string. Afterward, you copy the template and replace the placeholders with the string. I have done this several times for reports of equipment tests, and it works pretty well.
EDIT: I mean, you can generate the table, the result, etc., and replace those placeholders.
Since you are using Emacs, maybe org mode would be an option? If your workflow can be divided into some chunks that fit well into babel blocks, it might be worth a try.
If you are not too deeply wed to LaTeX, you should consider the Typst app and the related Typstry.jl package.. I recently did a 200-page book heavy in figures and found it worked well. The markup is Commonmark-like.
= Chapter or section
== second level header
#note(side: "inner")[margin note.]
#wideblock(side: "inner", figure(image("figures/fig35.svg", width:120%), caption: [Plot with Optional Elements]))
The colors are set using a combination of techniques called a ternary operator and a comprehension. The way to read this line:#index[ternary operators]