Skip to content

Add method to load texPackages and tikzLibraries to Plots #1408

Merged
pstaabp merged 1 commit into
openwebwork:PG-2.21from
somiaj:add-amsmath-to-plots
May 22, 2026
Merged

Add method to load texPackages and tikzLibraries to Plots #1408
pstaabp merged 1 commit into
openwebwork:PG-2.21from
somiaj:add-amsmath-to-plots

Conversation

@somiaj
Copy link
Copy Markdown
Contributor

@somiaj somiaj commented May 12, 2026

This adds two options to plots, texPackages and tikzLibraries to Plots, that can be used to add additional packages and libraries fro generating TikZ output. This also adds "amsmath" in the list of default packages that are loaded.

@somiaj somiaj force-pushed the add-amsmath-to-plots branch from e767435 to 03bf653 Compare May 12, 2026 22:06
@Alex-Jordan
Copy link
Copy Markdown
Contributor

Maybe it would be good to also add POD (to plot.pl?) to document which latex packages are available.

I wondered how long until someone hits an issue with some other tex package being unavailable? Not to add mission creep, but have you considered making texPackages configurable by the problem author using plots.pl?

@somiaj
Copy link
Copy Markdown
Contributor Author

somiaj commented May 17, 2026

@Alex-Jordan this did come up in the meeting that plots doesn't have a way to configure the LaTeXImage object directly. But this kinda leads down a rabbit hole of how configurable should plots give the various outputs it supports. What about compatibility with jsxgraph, should this allow creating images that cannot also be created in jsxgraph, or whatever other plot output that could be added in the future?

There is more that can be done here, and maybe we should expose more of the LaTeXImage object to plots. This was just a quick fix to allow common things that many would expect so the tikz/pgfplots label output supports most of the stuff in jsxgraph via MathJax. If someone is really wanting to create a plot object with lots of custom libraries, maybe they should use LaTeXImage directly if they want that much control of the latex/tikiz output, instead of plots which is meant to be more independent of the back end of the plot being created. I think the real issue is someone creates something that shows up nicely in jsxgraph/html output only to find at a later date the hardcopy output is missing something.

It might be a loosing battle to try to deal with each use case, so a future PR could expose more of the LaTeXImage configuration to the plots object. But then authors will have to know what additional libraries to load since MathJax auto loads them.

@Alex-Jordan
Copy link
Copy Markdown
Contributor

Alex-Jordan commented May 17, 2026 via email

@pstaabp
Copy link
Copy Markdown
Member

pstaabp commented May 19, 2026

How about staying with only the addition of the amsmath package, but document and amsmath and pgfplots are included? That might tip others that might want other packages to request them.

@somiaj somiaj force-pushed the add-amsmath-to-plots branch from 03bf653 to 0e8af1d Compare May 19, 2026 20:15
@somiaj somiaj changed the title Add amsmath to the list of TeX packages in Plots. Add method to load texPackages and tikzLibraries to Plots May 19, 2026
@somiaj somiaj requested a review from drgrice1 May 19, 2026 20:16
@somiaj
Copy link
Copy Markdown
Contributor Author

somiaj commented May 19, 2026

I updated this to give an option so a user can load additional texPackages and tikzLibraries, and documented the options. "amsmath" is still loaded by default.

This adds two options to plots, `texPackages` and `tikzLibraries`
to Plots, that can be used to add additional packages and libraries
fro generating TikZ output. This also adds "amsmath" in the list
of default packages that are loaded.
@somiaj somiaj force-pushed the add-amsmath-to-plots branch from 0e8af1d to d292e1d Compare May 19, 2026 20:27
Copy link
Copy Markdown
Member

@drgrice1 drgrice1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks fine.

@pstaabp pstaabp merged commit 1473ef1 into openwebwork:PG-2.21 May 22, 2026
3 checks passed
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.

4 participants