[NTG-context] Disable reuse of figures
Aditya Mahajan
adityam at umich.edu
Sat Feb 19 07:30:31 CET 2022
Hi,
This is related to a bug report for the filter module:
https://github.com/adityam/filter/issues/60
Normally, when the same figure is included twice, context only includes the figure once and refers to the included figure the second time. The option `object=no` to externalfigure is supposed to prevent that, but it doesn't work. For example, consider the following example the bug-report uses graphviz as the external program, but I have changed that to context to keep things self contained)
\usemodule[filter]
\defineexternalfilter
[graphviz]
[
filter=context --purge,
output=\externalfilterbasefile.pdf,
readcommand=\ReadPDF,
]
\def\ReadPDF#1%
{\externalfigure[#1][object=no]}
\starttext
Circle:
\startgraphviz
\startMPpage
draw fullcircle scaled 1cm;
\stopMPpage
\stopgraphviz
Square:
\startgraphviz
\startMPpage
draw fullsquare scaled 1cm;
\stopMPpage
\stopgraphviz
\stoptext
Behind the scenes, the first \startgraphviz ... \stopgraphviz environment writes the content to an external file (\jobname-temp-graphviz.tmp), runs `context --purge \jobname-temp-graphviz.tmp`, which creates `\jobname-temp-graphviz.pdf`. The `\ReadPDF` macro then includees the file (with object=no).
At the next \startgraphviz .. \stopgraphviz, the same process is repeated. The `\jobname-temp-graphviz.pdf` file is overwritten and the new file should have been included. But it is not. The output contains the first image twice.
I thought that object=no should have prevented the reuse. In fact, if I compile the file with luatex, I get an error message:
! error: (pdf inclusion): file has changed '12-two-outputs-temp-graphviz.pdf'
mtx-context | fatal error: return code: 256
Any idea why object=no is not working?
Thanks,
Aditya
More information about the ntg-context
mailing list