# Using TikZ along with picture environment

• picture After TikZ

   \documentclass{article}
\usepackage{color}
\usepackage{tikz}
\usepackage[english]{babel}
\begin{document}
\begin{tikzpicture}
\path (0pt,0pt);% for adjusting to origin of entire document
\draw[red]
(0pt, 50pt) -- (120pt, 140pt) -- (240pt, 50pt);
\end{tikzpicture}
\begin{picture}(0,0)
\color{blue}\qbezier(0, 50) (120, 140)(240, 50)
\end{picture}
\end{document}


Result:

• picture Before TikZ

    \documentclass{article}
\usepackage{color}
\usepackage{tikz}
\usepackage[english]{babel}
\begin{document}
\begin{picture}(0,0)
\color{blue}\qbezier(0, 50) (100, 140)(200, 50)
\end{picture}
\begin{tikzpicture}
\path (0pt,0pt);% for adjusting to origin of entire document
\draw[red]
(0pt, 50pt) -- (100pt, 140pt) -- (200pt, 50pt);
\end{tikzpicture}
\end{document}


Result:

• picture Without TikZ

    \documentclass{article}
\usepackage{color}
\usepackage{tikz}
\usepackage[english]{babel}
\begin{document}
\begin{picture}(0,0)
\color{blue}\qbezier(0, 50) (100, 140)(200, 50)
\end{picture}
\end{document}


Result:

As you can see from 3rd example picture environment's coordinates differ from TikZ environment's coordinates. Is that possible to depict TikZ figures in the same coordinate system as picture environment has?

-
I would not rely on the precision on those on top of each other. Is there a particular reason why you need picture AND TikZ? Try and look up TikZ control points feature. That should be able to give you the same bezier curve. –  zeroth Feb 9 '12 at 18:45
No, I write soft that use LaTeX commands. It has already primitives with picture environment. There are a lot of written code in that soft. I need to add TikZ primitives. So I need them both. –  Michael Z Feb 9 '12 at 18:48

No there is no problem with coordinates. The problem is tikz uses a bounding box by default and with \begin{picture}(0,0)you don't have a bounding box with environment picture. In the first part, I use "picture" inside a tikz code and I use a bounding box for picture in other parts. Remark : you have blank spaces misplaced in your code.

\documentclass{article}
\usepackage{color}
\usepackage{tikz}
\usepackage[english]{babel}
\begin{document}
\parindent=0pt
\begin{tikzpicture}
\draw[help lines,step=10pt](0,0) grid (200pt,150pt);
%\path (0pt,0pt);
\draw[red]  (0pt, 50pt) -- (100pt, 140pt) -- (200pt, 50pt);
\node[inner sep=0pt,anchor=south west] at (0,0){%
\begin{picture}(200,140)%
\put(0,0){\line(1,0){200}}
\color{blue}\qbezier(0, 50) (100, 140)(200, 50)%
\end{picture}%
};
\end{tikzpicture}%
\begin{picture}(200,140)%
\put(0,0){\line(1,0){200}}
\color{blue}\qbezier(0, 50) (100, 140)(200, 50)%
\end{picture}
\begin{picture}(0,0)
\color{blue}\qbezier(0, 50) (100, 140)(200, 50)%
\end{picture}%
\begin{tikzpicture}
\path (0pt,0pt);
\draw[red]
(0pt, 50pt) -- (100pt, 140pt) -- (200pt, 50pt);
\end{tikzpicture}
\end{document}


update

version with a bounding box null for the tikzpicture

\documentclass{article}
\usepackage{color}
\usepackage{tikz}
\begin{document}
\parindent=0pt

\null\vspace{2cm}

\begin{picture}(0,0)
\color{blue}\qbezier(0, 50) (100, 140)(200, 50)%
\end{picture}%
\begin{tikzpicture}
\draw[use as bounding box] (0,0) rectangle (0,0);
\path (0pt,0pt);
\draw[red]
(0pt, 50pt) -- (100pt, 140pt) -- (200pt, 50pt);
\end{tikzpicture}%
\begin{picture}(0,0)
\color{green}\qbezier(0, 50) (100, -90)(200, 50)%
\end{picture}%
\end{document}


version with overlay

 \documentclass{article}
\usepackage{color}
\usepackage{tikz}
\begin{document}
\parindent=0pt

\null\vspace{2cm}

\begin{picture}(0,0)
\color{blue}\qbezier(0, 50) (100, 140)(200, 50)%
\end{picture}%
\begin{tikzpicture}[overlay]
\path (0pt,0pt);
\draw[red]  (0pt, 50pt) -- (100pt, 140pt) -- (200pt, 50pt);
\end{tikzpicture}%
\begin{picture}(0,0)
\color{green}\qbezier(0, 50) (100, -90)(200, 50)%
\end{picture}%
\end{document}


The result is the same with the two codes.

-
1) But where exactly is bounding box for "picture" in your example? 2) As I have understand that is NOT possible to draw in both environments with the same document's coordinate system (I mean here two drawings can be overlapped by each other)? P.S. Your trick with using "picture" as node inside TikZ is NOT appropriate for me. –  Michael Z Feb 17 '12 at 13:26
1) I think \begin{picture}(200,140) defines a bounding box here a rectangle from (0,0) to (200,140) and with \begin{picture}(0,0) you don't work in a box and you overwrite everything. Perhaps I don't understand your question. 2) yes you can but you need to work with picture before with tikzpicture (see the end of my example) or you need to remove the bounding box for the tikzpicture and finally you can use the overlay option. I update my answer. –  Alain Matthes Feb 17 '12 at 13:56
Wow! You are genius! The overlay parameter - is a key for me here! –  Michael Z Feb 17 '12 at 16:24
@MichaelZ thanks but not a genius only a passionate fan of tikz –  Alain Matthes Feb 17 '12 at 17:11