I don't care too much about what image format I get out of the process as I can convert it if needed, but I'm looking for the best way to structure my document/files in order to make it easier and faster to generate a set of images that can be used in other documents. I have both a Windows and Ubuntu box (both running TexMaker) so something that works on both platforms is preferred.

I'm using the TikZ package to make some simple figures for my thesis. I have the figures located in the ./figures directory, with each figure in a file with the naming convention <short_description>.tikz. My main document contains all the preamble and styling information as well as all text.

I've used the code from a previous question and created two tex files in the figures directory called export_figures_(win|unix).tex, each of which has a duplicate of the TikZ styling information and then includes a file list_of_figures.tex which is a copy paste of each \input{} in my main document. I then have a batch/shell script for each platform I run to generate images.

I used this approach as I was unable to compile the main document unless the export statement was commented out, which meant I had to constantly uncomment and comment the code section when I created a new figure. The way I have it now is still less than ideal as I have to update two documents manually every time I create or rename a figure. This also means that the TikZ styling information is replicated three times (though I could pull that into it's own file and just include that file).

Is there a better way to implement this to make my life a bit easier? Are there any recommended practices I'm well violating that I should be following?

  • I should clarify the reason I wanted to export these pictures as image files was to use them in a powerpoint presentation (I'm not quite ready to use beamer yet).
    – Ephphatha
    Commented Apr 13, 2011 at 16:47

1 Answer 1


What I do is to create a .tex file for every TikZ picture (a figure is the environment you place it later) I have using the standalone class (written by me just for this task). You can then \input this files (don't use \include for them!) in multiple main files after loading the standalone package there. The standalone files should contain the required preamble like loading tikz and the required libraries. They can also be compiled by themselves, i.e standalone, and included as PDF images. The main files need to load the same libraries of course. There are options to automatically transfer the "sub-preambles" to the main preamble.

If you have global TikZ style settings then place them in a config file and \input this in every files which requires it. Alternatively make a package out of it (simply call it .sty instead of .tex will do it for starters) and load it as package.

The v1.0 of standalone from 2011/12/21 will allow you to compile the standalone picture files to PDF from the main file and include them as PDF in the current and future compilation run. This speeds up compilation a lot but increases the file size slightly. See the package options mode and build in the manual.

In my opinion it doesn't make much sense to place pictures into one main file and then export them, so that they can be used in another main file. If it should be shared between documents put them into an extra file. This also makes version control easier because the picture is separated from the text.

  • I don't suppose you're able to give an example of the standalone class?
    – Ephphatha
    Commented Apr 13, 2011 at 16:48
  • @Ephphatha: There are example in the package manual. A principal, but minimal example is also in this answer. Commented Apr 13, 2011 at 17:14

You must log in to answer this question.

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