I want to use complex monocolor vector graphics but I would like to be able to specify the color inside my latex source. Solutions :

  1. Use a pdf, but I can't specify the color afterwards. Perhaps a solution with svg ?
  2. Use tikz, but it makes my compilation so slow as it needs to parse the complex paths again each time I use one of those graphics !
  3. Use tikz+\savebox, as my graphics have a lots of complexity, but there are only a few different of them that I use a lots of time.

Here is my question : can I use \savebox to save some tikz operations with a custom color that will be specified only when I use \usebox ?

My wish would be to have a command \mygraphics that takes one argument the color such that \mygraphics{blue} and \mygraphics{red} typeset my graphic in blue or in red without parsing my graphic each time.

  • Instead of savebox you can define a command with an (optional) argument Commented May 12, 2013 at 11:23
  • Defining a command with an optional argument is like solution 2 : tikz must parse 100 times the same complex path if I use 100 time the same graphic with different colors...
    – Xoff
    Commented May 12, 2013 at 11:48
  • How about using the external library of TikZ? You can update pictures later by putting remake next before them. See section 32 of the TikZ manual for details. Commented May 12, 2013 at 13:10
  • well if you can show the example of what your complicated graphics is then we can offer more options. If it is only the color you are interested in then you can use masking which is a big advantage of PGF. But I don't see what you mean by complexity. Is it a lot of paths or else? I'm plotting ridiculous amount of bode plots with 2500 points each with pgfplots in my thesis and it takes 3 minutes to compile.
    – percusse
    Commented May 12, 2013 at 15:54

2 Answers 2


It seems to me there is a fourth solution using both an external pdf and tikz. You could compile the tikz using the "standalone" class, an example of such code is given here, then include the obtained pdf in your main document. The compilation would then be fast while keeping full control over the graph.


Ok, I finally found what I need in programming-in-tikz. Soft paths allow to compute a path and save it for later, using it with different fill, stroke, ...

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .