# \usepackage{preview} equivalent for ConTeXt?

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?

• Perhaps an odd question, but why use ConTeXt here? If you want to make 'stand alone' TikZ pictures the LaTeX 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.) – Joseph Wright Jun 9 '15 at 7:53
• Further to that, as standalone is probably a more common choice for this task, perhaps you might broaden the question to cover that option as well as directly loading preview? – Joseph Wright Jun 9 '15 at 7:55
• i use KTikZ to work on figures with instant preview. those are going to be embedded in ConTeXt docs, so i’ll use \start... and \stop..., not \begin{...} and \end{...}. – flying sheep Jun 9 '15 at 9:51
• You can use the TeXpage environment to create a standalone page for your image. All you have to do is putting \startTEXpage before \starttikzpicture and \stopTEXpage after \stoptikzpicture. – Wolfgang Schuster Jun 9 '15 at 10:53
• @Metafox beautiful! – flying sheep Jun 9 '15 at 14:56

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.