# Automatic conversion from picture commands to tikz-pgf

I'm trying to modify an old document with a bunch of images created using the picture/pict2e environment.
The problem is that I need to improve these images, but adding some new features in those old environments sometimes require a lot of work, while in TikZ would be just a couple of parameters.

So, the question: is there a way to automatically convert picture images into TikZ/pgf images ?

-
The simple answer here, 'No', seems a bit short! –  Joseph Wright Jan 10 '12 at 19:02
@JosephWright: It's still good to know. Thanks for the information :) –  digEmAll Jan 11 '12 at 8:02

Just to summarize Joseph's NO and add a but. If you are willing to spend a lot longer than simply translating the code you had the misfortune to inherit, here is a methodology.

First you need to write gobbling macros for all the pict2e macros, including also a whole lot of macros from the original picture environment as well. How you do that? For example to gobble the \picture macro you can use:

\def\picture(#1,#2)(#3,#4){%
\def\storepiconevar{#1}
\def\storepictwovar{#2}
\def\storepictthreevar{#3}
\def\storepicfourvar{#4}
% starts the tikZ environment
\tikzpicture
}
% ends the tikZ environment
\def\endpicture{\endtikzpicture}

For some you maybe able to develop translation macros between the two such as the simplistic example below (not showing any actual calculations for simplicity).

\def\line(#1,#2)#3{\draw(#2,#1)--(#1,#1);}

Trying it out in a MWE:

\documentclass{article}
\usepackage{tikz}
\def\picture(#1,#2)(#3,#4){%
\def\storepiconevar{#1}
\def\storepictwovar{#2}
\def\storepictthreevar{#3}
\def\storepicfourvar{#4}
% starts the tikZ environment
\tikzpicture
}
\def\endpicture{\endtikzpicture}
\def\line(#1,#2)#3{\draw(#2,#1)--(#1,#1);}
\begin{document}
\unitlength=0.5cm
\begin{picture}(0,0)(2,0)
\line(1,0){2}
\end{picture}
\end{document}

Worth a try if you want to learn both pict2e and tikZ very well. Let us know if you come up with a package.

-
I'm not so skilled in LaTeX to start writing something that can be turn into a package, but this is definitely applicable in my case, because the picture I need to improve are really simple (just a bunch of lines, vectors, rectangles) and my need is just to add some dashing, colors, arrow styles and so on. Hence, I will give it a try, thanks a lot ! :) –  digEmAll Feb 16 '12 at 8:09
@digEmAll I think it is also a very good way to learn both TikZ and pic2e. I am not using TikZ very often and keep looking the commands up:) –  Yiannis Lazarides Feb 16 '12 at 8:25