LyXLyx 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

Post by pireddag »

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

Code: Select all

\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)

Code: Select all

\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!

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

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

Lyx preview: image inside TikZ picture

Post by thomasb »

pireddag
Posts: 28
Joined: Tue Nov 21, 2017 3:06 am

Lyx preview: image inside TikZ picture

Post by pireddag »

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 ... w-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: 134
Joined: Thu Aug 03, 2017 10:54 am

Lyx preview: image inside TikZ picture

Post by thomasb »

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

Lyx preview: image inside TikZ picture

Post by pireddag »

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: 134
Joined: Thu Aug 03, 2017 10:54 am

Lyx preview: image inside TikZ picture

Post by thomasb »

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

Lyx preview: image inside TikZ picture

Post by pireddag »

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: 134
Joined: Thu Aug 03, 2017 10:54 am

Lyx preview: image inside TikZ picture

Post by thomasb »

pireddag wrote:I already use it :-)
that was my last cartridge...
pireddag
Posts: 28
Joined: Tue Nov 21, 2017 3:06 am

Lyx preview: image inside TikZ picture

Post by pireddag »

thomasb wrote:
pireddag wrote:I already use it :-)
that was my last cartridge...
:-)

I find the LyX instant preview helpful :-)
thomasb
Posts: 134
Joined: Thu Aug 03, 2017 10:54 am

Lyx preview: image inside TikZ picture

Post by thomasb »

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...
Post Reply