What is it?
===========

Introduction
------------

Making figures for presentations, websites or publications usually take
a lot of time. However, the process is usually the same (compile,
convert and export). Thus, automation must be used to focus on the
content and not on managing files. Based on this observation, I
conceived a workflow and I wrote a software that automate this task.

The source code is available here: https://github.com/sciunto-org/scifig

Choices
-------

Languages and softwares for figures
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

We need to choose a technology to make figures. I like to write code,
I'm efficient that way, so I choose LaTeX because I already use it for
my documents and my presentations. To draw figures, pstricks or Tikz can
be used. I tried both and Tikz looked to me more efficient (for loops
for instance). To make plots, I'm familiar with
`gnuplot <http://www.gnuplot.info/>`__ for almost a decade now. Gnuplot
has a tikz terminal and this is lucky. It will be very easy to combine
drawings and plots. For rare other needs (chemical formulae), LaTeX
usually have what we need.

`Ktikz <http://kde-apps.org/content/show.php/ktikz?content=63188>`__ and
`gummi <https://github.com/alexandervdm/gummi>`__ are really helpful to
prepare drawings. They refresh the output while you edit the code. It's
almost a live mode.

Output formats
~~~~~~~~~~~~~~

-  tex (standalone file)
-  eps
-  pdf
-  svg

Workflow
~~~~~~~~

Now, we need to find a strategy to make our figures.

Drawings

-  tikz file: the code you write with Ktiz for instance, between \\begin
   and \\end{tikzpicture}
-  tex file: we decorate the tikz file with some packages and a document
   class (standalone) to have a croped image
-  pdf file: the tex file compiled with pdflatex
-  eps file: pdf to eps
-  svg file: pdf to svg

Plots with gnuplot

-  plt file: this is the standard gnuplot script to make a figure, with
   tikz terminal
-  tikz file: code generated by gnuplot
-  plttikz files: optional, inject tikz code before or after the code
   generated by gnuplot. It allows to draw in plots!
-  tex file: we decorate the plttikz file with some packages and a
   document class (standalone) to have a cropped image
-  pdf file: the tex file compiled with pdflatex
-  eps file: pdf to eps
-  svg file: pdf to svg

 Others

Any other chain for another tool can be implemented, such as matplotlib
in python, which has a tikz terminal too.

Implementation
--------------

My first implementation (around 2007) was based on shell scripts and
makefile. Quickly coded, but not easy to maintain and the code tend to
become hard to read very rapidly.

The second implementation (around 2011) used
`waf <https://github.com/waf-project/waf>`__, a build to in python. The
idea was to reuse something existing rather than writing from scratch a
workflow. However, in practice, waf is not full adapted for the workflow
I need. I made a working version I used for almost 4-5 years, I found
interesting features (colored output, src and build separated, export
function) but the addition of new workflow would require a lot of
energy.

Then, I arrived to write a third version, from scratch since I know
perfectly what I need:

-  a database to record what must be recompiled based on modifications
-  a detector to guess the right rule to apply (based on file formats)
-  a set of rules to build the figure
-  a nice output
