A class and package is provided which allows TeX pictures or other TeX code to be compiled standalone or as part of a main document. Special support for pictures with beamer overlays is also provided. The package is used in the main document and skips extra preambles in sub-files. The class may be used to simplify the preamble in sub-files. By default the preview package is used to display the typeset code without margins. The behaviour in standalone mode may adjusted using a configuration file standalone.cfg to redefine the standalone environment.