Am 16.09.24 um 12:59 schrieb Bruce Horrocks:
On 15 Sep 2024, at 22:11, Florent Michel
wrote: Thanks Bruce for your very helpful reply!
The reason for my question was indeed consistency, e.g. ensuring figure captions stay up to date with what the figures show when changing parameters. Thinking more about it, the second solution you mention seems to be a better option, though - I can simply define the parameters in an external file and read it from both the PDF solver and ConTeXt to ensure consistency. Thanks for mentioning it!
Thank you also for mentioning \executesystemcommand, which I was not aware of!
Another option might be to use a marker such as
% DE_figure_here param1 param2 param3
in your ConTeXt source and then use 'awk' or another Unix text pre-processor to scan through for these, run the appropriate DE calculation, plot the graph and generate the appropriate \placefigure command to go in its place.
Bonus marks if it can automatically generate the caption based on the parameters! But if not, the marker can always follow the \placefigure macro e.g.
\placefigure {This is a DE showing something and something else} % DE_figure_here param1 param2 param3
so the awk code only needs to insert the image file name.
Note I’ve deliberately omitted the braces from the bit to be substituted so that you need to generate them in the awk. That way, if you forget to process, you’ll get an error not a missing image.
That sounds needlessly convoluted to me. I’d use Aditya’s filter module to call external programs, it also does caching, i.e. if the parameters don’t change, it won’t waste processing time. https://github.com/adityam/filter Hraban