I would like to create a ConTeXt document cropped around a single \starttikzpicture \stoptikzpicture
. How to achieve this by letting TeX infer the page size from the box dimensions?
1 Answer
Building on @Metafox's command, you can use \startTEXpage ... \stopTEXpage
to create a page with only tikz pictures. For example,
\usemodule[tikz]
\starttext
% 1st picture
\startTEXpage[offset=3mm]
\starttikzpicture
....
\stoptikzpicture
\stopTEXpage
% 2nd picture
\startTEXpage[offset=3mm]
\starttikzpicture
....
\stoptikzpicture
\stopTEXpage
\stoptext
will create a pdf with two pages that are the size of the tikzpicture plus 3mm of offset of each side.
standalone
class is the usual go-to, and as TikZ has its own syntax there's not an obvious (to me) ConTeXt benefit. (BTW, the question in general seems like a good one: I'm wondering as an aside.)standalone
is probably a more common choice for this task, perhaps you might broaden the question to cover that option as well as directly loadingpreview
?\start...
and\stop...
, not\begin{...}
and\end{...}
.TeXpage
environment to create a standalone page for your image. All you have to do is putting\startTEXpage
before\starttikzpicture
and\stopTEXpage
after\stoptikzpicture
.