# Overlaying TikZ nodes on an image using TikzEdt and onimage.sty

Trying to overlay some TikZ onto an image, I have found two very helpful Q&As:

I especially like the onimage solution of the second answer. So I tried using the GUI TikzEdt with this:

\begin{tikzonimage}{bottle.jpg}
\draw [orange, line width=5pt] (0.5,0.92) circle [radius=0.75cm];
\end{tikzonimage}


But I can't get this to work. I added \usepackage{onimage} in the Settings-Settings-Compiler options. The TikzEdt compilation output yields:

! LaTeX Error: Environment tikzonimage undefined.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
...

l.3 \begin{tikzonimage}
{bottle.jpg}
!  ==> Fatal error occurred, no output PDF file produced!


I don't know why it won't work, as it compiles fine when I use MiKTeX. How can I make TikzEdt find the tikzonimage environment?

• I honestly don't know, but out of curiosity, what drives you to not just using TeX without such a GUI, i.e. a good editor? – Turion Feb 23 '15 at 22:38
• @Turion: I am generating a set of raster images of subsurfaces on quadrics using MATLAB, as achieving the same with pgfplots or tikz directly gave me some headaches. Especially opacity and z-fighting/permeating surfaces was problematic. I still want to name some points on my surface for referencing them in the mathematical text, which I would like to do with TeX, as this has a few benefits especially that the results will be nicer to look at. The problem simply is, that manually finding the coordinates and entering them by hand is a bit of a hassle, as there are lots of points. – knedlsepp Feb 23 '15 at 23:04
• @Turion: My workaround is to use a MATLAB script, which displays all my exported png-files, let's me click on the desired points and outputs some tikz-code with the coordinates of the nodes. But as TikzEdt looked promising and already has this WYSIWYG interface, which can be used to create nodes at certain positions I was hoping to automate this a bit. It seems I'm not the only one having this problem as the second highly upvoted answer to the first question gives the tip to overlay a grid onto the image to have some help in extracting the coordinates. (Which is tedious for lots of points) – knedlsepp Feb 23 '15 at 23:09
• @HarishKumar: As described in the answer, I downloaded the onimage.dtx file, ran pdflatex on it and put the resulting .sty in the same folder as the .tex file mentioned above... It's not by any chance you have TikzEdt installed and can reproduce the problem? – knedlsepp Feb 24 '15 at 1:04
• @HarishKumar: Thanks a lot! This would at least help me clarify if the problem is on my end or with TikzEdt. – knedlsepp Feb 24 '15 at 1:06

You can find the details on how to create a local texmf folder for miktex in this answer. Then download the onimage.dtx from here, run pdflatex on it to get the documentation and onimage.sty. Now add these two files (onimage.pdf (documentation) and onimage.sty in to your local texmf folder (for example, for me it is c:\localtexmf\tex\latex\onimage\). Then run a FNDB as explained in Speravir's answer.

Now edit the preamble of tikzedt using the menu Settings-Settings-Compiler options as in this picture:

Then you are good to go.

Put this code in tikzedt

\begin{tikzonimage}{example-image-a}[tsx/show help lines]
\draw [orange, line width=5pt] (0.5,0.92) circle [radius=0.75cm];
\end{tikzonimage}


• @knedlsepp Did you manage to get it work? – user11232 Feb 24 '15 at 7:25
• I just had the chance to try it out. It solved the issue in the sense that the environment is now recognized and it shows the picture on the right, as it does in your screenshot. Sadly what I'm trying to use this program for doesn't work. I want to be able to click on the image to produce nodes and get the \node {x,y} ... TikZ code. With the above codesnippet, clicking doesn't generate any nodes. Only after I wrap the tikzonimage in a tikzpicture-environment I am able to generate nodes. Sadly the image starts jumping around on the first click and only shows the lower left part... – knedlsepp Feb 24 '15 at 9:31
• @knedlsepp :(... – user11232 Feb 24 '15 at 9:36
• Indeed. This may be a bug of TikZEdt, I'm not sure. I suppose it requires a tikzpicture-environment to work, but putting a tikzonimage inside the tikzpicture is probably the wrong usage in terms of TeX. I'm going to ask for clarification here. – knedlsepp Feb 24 '15 at 9:38