noib3 via ntg-context schrieb am 02.10.2021 um 17:50:
Coming from LaTeX, when I had some TikZ pictures I wanted to add in my document I would usually keep them on a separate file, I would compile them with the standalone class so that the resulting PDF's size would be limited to exactly the dimensions of the figure. I would then import the compiled PDF in my main document. All this to not slow down compilation times.
What's the ConTeXt equivalent of this workflow? How can I keep the PDF dimensions limited to the figure?
In addition to Wolfgang’s suggestion, you might consider using buffers. These are only typeset if something in the figure changes, which ConTeXt checks with each run. It automates the process of making separate files and including them, without slowing down compilation. Put the TikZ code in buffers and typeset the buffers to make the figures: \startbuffer[MyTikZFigure] % TikZ code here \stopbuffer \startplacefigure[reference=MyFig, title={This is the figure’s caption}] \typesetbuffer[starttikz, MyTikZFigure,stoptikz] \stopplacefigure Following a suggestion from Hans, I made two buffers that have the starting and ending stuff needed for my figures: \startbuffer[starttikz] % This buffer will start every TikZ picture. \environment env_physics % My physics macros \environment env_TikZ % My TikZ macros \setupbodyfont [libertinus,11pt] % Other setups for figures \startTEXpage \starttikzpicture \stopbuffer \startbuffer[stoptikz] % This buffer will stop every TikZ picture. \stoptikzpicture \stopTEXpage \stopbuffer