## LaTeX forum ⇒ LyX ⇒ Lyx preview: image inside TikZ picture

Information and discussion about LyX, a WYSIWYM editor, available for Linux, Windows and Mac OS X systems.
pireddag
Posts: 28
Joined: Tue Nov 21, 2017 3:06 am

### Lyx preview: image inside TikZ picture

Dear forum users,

the LyX preview does not work if I include a picture using \includegraphics inside a tikzpicture environment.
It works if I include the same picture on its own.

Here are two code snippets to insert inside a TeX code box in LyX

\begin{tikzpicture}\node[anchor=south west,inner sep=0] (image) at (0,0) {\includegraphics[width=0.4\textwidth]{example-image-a.jpg}};  \end{tikzpicture}

(does not appear in preview)

\includegraphics[width=0.4\textwidth]{example-image-a.jpg}

(appears in preview).

I have verified that the tikz picture appears in preview if I substitute the image with text.

As far as I know the image example-image-a.jpg is part of the mwe package so the two snippets should compile inside a LyX document if one puts the command \usepackage{tikz} in the preamble.

I have tried both with the standard article class and with the Koma article (I do not expect the class to be important for this).

Any ideas? Thanks in advance!

thomasb
Posts: 132
Joined: Thu Aug 03, 2017 10:54 am

pireddag
Posts: 28
Joined: Tue Nov 21, 2017 3:06 am
Hi, thanks a lot for the answer.

I think I did not explain myself well. I am able to insert the image inside a TikZ picture (in the way that you said: I took the code from another StackExchange answer, this one: https://tex.stackexchange.com/questions/186389/how-can-i-annotate-an-image-with-arrow-and-text) . I can obtain the pdf from the LyX file then.

What I cannot do is to see the image in the LyX preview. The preview works for TikZ pictures, and for images, but not for images which are inside TikZ pictures: so I would like to know if it is possible to obtain it.

thomasb
Posts: 132
Joined: Thu Aug 03, 2017 10:54 am
pireddag wrote:The preview works for TikZ pictures, and for images, but not for images which are inside TikZ pictures: so I would like to know if it is possible to obtain it.

Well, I don't even know what a preview is... If you're on Windows, try this viewer.

pireddag
Posts: 28
Joined: Tue Nov 21, 2017 3:06 am
thomasb wrote:Well, I don't even know what a preview is...

it is LyX's instant preview. It is explained here for equations: https://wiki.lyx.org/LyX/InstantPreview, but it works for many of the TeX code snippets that one inserts in LyX (the so called "Evil Red Text").

It works nicely for example for the packages siunitx and tcolorbox, and usually works for TikZ pictures (and graphs made with pgfplots).
I have figure out that it does not work if one inserts an image inside a TikZ picture. Maybe the LyX mailing list is the right place where to ask, I will do it. If I get an answer there, I will post it here.

But thanks for trying to answer the question!

thomasb
Posts: 132
Joined: Thu Aug 03, 2017 10:54 am
pireddag wrote:But thanks for trying to answer the question!

(give Sumatra a try, though : https://tex.stackexchange.com/questions ... -using-lyx ...)

pireddag
Posts: 28
Joined: Tue Nov 21, 2017 3:06 am
thomasb wrote:
pireddag wrote:But thanks for trying to answer the question!

(give Sumatra a try, though : https://tex.stackexchange.com/questions ... -using-lyx ...)

I already use it

thomasb
Posts: 132
Joined: Thu Aug 03, 2017 10:54 am
pireddag wrote:I already use it

that was my last cartridge...

pireddag
Posts: 28
Joined: Tue Nov 21, 2017 3:06 am
thomasb wrote:
pireddag wrote:I already use it

that was my last cartridge...

I find the LyX instant preview helpful

thomasb
Posts: 132
Joined: Thu Aug 03, 2017 10:54 am
pireddag wrote:I find the LyX instant preview helpful

With Emacs, you can make a keyboard short-cut to compile. It's not as direct as preview though...