Forgive me for my perhaps naive questions, I am beginning to discover Tikz potentials. To ease certain operations as moving objects or transforming them, I want to know if there is a mechanism in Tikz that I can group certain operations and give a name to this grouping and use that name in doing operations on the whole collection of objects that are grouped. My first guess was perhaps scope will do this. But could not see how I can refer collectively to the scoped operations and/or objects. The best analogy, for give me to mention it, is the grouping operation in Power Point. Thanks for your help. Artimess


You can apply transformations to a scope, like for example:

        \draw (-1,-1) rectangle (1,1);
        \draw (0,0) circle (1);

Whatever parameters and operations you specify in the [...] at the beginning of the scope environment is applied to every command inside the scope.

  • 1
    I do not think that it answers OP's question. The scope is not named - no possibility to reuse it later. – hpekristiansen Jun 2 '14 at 7:49

TikZ 3.0 introduced a new concept called pic. It's possible to include complex drawing commands inside a pic and later use it as a whole. A little example with Caramdir's code:

    mycomplexfigure/.pic = {
        \draw (-1,-1) rectangle (1,1);
        \draw (0,0) circle (1);
\path  (1,3) pic{mycomplexfigure};
\path[red,rotate=45,transform shape]  (2,1) pic{mycomplexfigure};

enter image description here

Some more examples with .pic:


tikzpicture envionments can be nested. They behave like scope environments and support optional arguments for parameters. For instance, \begin{tikzpicture}[scale=0.5, transform shape] ... \end{tikzpicture} could be used inside a parent tikzpicture environment.

  • I know that this works, but is it meant to work? I ask because in another question (which escapes me now), an answer was to nest tikz pictures but when I experimented then I found that the inner and outer pictures didn't properly know about each other (in particular, node names and co-ordinates couldn't be guaranteed to work). – Loop Space Aug 16 '10 at 19:30
  • I used it but don't remember problems. But I wished also tikz matrices could be nested. – Stefan Kottwitz Aug 16 '10 at 20:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.