LyX\includegraphics and "cannot determine the size..."

Information and discussion about LyX, a WYSIWYM editor, available for Linux, Windows and Mac OS X systems.
Post Reply
digl
Posts: 9
Joined: Tue Mar 17, 2015 9:17 pm

\includegraphics and "cannot determine the size..."

Post by digl »

Hello everyone, I hope you can help me out with this please.

I'm working on a document with several figures and tables, and I want to be able to compile it with different sets of these figures and tables. I have different folders with different versions of the files, and I want to simply change a variable in the beginning of the document, to make it look for the files in a particular folder.

So I define a macro as

Code: Select all

\newcommand{\versionInputs}{../versionX}
, and then I use it as the path for the files.
For the tables, I'm importing .tex files and it works just fine with

Code: Select all

\input{\versionInputs/table.tex}
The problem is with the images. If I try to do it through lyx's insert graphics, it won't let me have a \ in the file path, so I can't use the macro (is there any way around that??).

If I try to manually include it using \includegraphics, I just can't make it work. And it's not a problem with the macro, I just can't get any image to work using \includegraphics manually, I always get
! LaTeX Error: Cannot determine size of graphic in .... (no size specifed).
The files are in .eps format, which I think is the format that should cause less trouble. I've also tried emf and png. I have tried with and without \usepackage{graphicx} in the preamble (and with different options), and with lots of different parameter setups to try to determine the size. I've tried using pdflatex and ps2pdf, dvi and others. Nothing seems to work. I'm trying a blank lyx document with nothing but the \includegraphics in different forms. Any suggestions please? thank you!!

It might have to do with estopdf, but I still can't figure it out. And I think that that wouldn't explain that it doesn't work with png's.

Edit: I edited the subject because I realised afterwards that my main problem is not the path thing, that should be sorted out after I fix the problem with \includegraphics
Last edited by digl on Wed Mar 18, 2015 11:19 am, edited 2 times in total.

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

Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

\includegraphics and "cannot determine the size..."

Post by Johannes_B »

Hi and welcome,

package graphicx provides exactly the needed command for that purpose, \graphicspath{{first/path/}{second/path/}}.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
digl
Posts: 9
Joined: Tue Mar 17, 2015 9:17 pm

Re: macro in image path?

Post by digl »

Hi Johannes, thanks for the welcome and the reply. I will check that out. I just edited my post clarifying something however, my problem is not with the image and the path macro, I just can't get any image to work!
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

\includegraphics and "cannot determine the size..."

Post by Johannes_B »

I have to be honest, i am not a LyX user. As an advanced tool with a graphical interface, i am just lost. I want the pure basic stuff, with code to look at, nothing hidden from my view.

LyX does some magic in the background, file conversion and stuff, i am just not sure what exactly.

These days, LaTeX means, in general, two different outputs. Direct output to pdf, which means that images with the format pdf, png and jpg are ok.
And the output to dvi, which you can later convert to pdf, which can only handle eps figures.

On the pure base of things, neither emf, nor bmp, nor tiff, nor .... files are meant to be processed by LaTeX.

There error you are mentioning reveals, that you are simply using the wrong engine, or the right one, i don know. You said you are using eps files, that means a run of pdflatex could return those errors. With basic LaTeX, eps-files are converted to pdf along the compile. The converted file is kept for all new runs. How LyX is handling this, sorry, i don't know.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
digl
Posts: 9
Joined: Tue Mar 17, 2015 9:17 pm

Re: macro in image path?

Post by digl »

Thanks for the explanation. I've tried generating a DVI (with an eps file), but I'm not sure exactly what's the path that lyx is using to get there, (maybe not directly latex but some other route). And pdflatex with png files is giving me the exact same error.
User avatar
Stefan Kottwitz
Site Admin
Posts: 10335
Joined: Mon Mar 10, 2008 9:44 pm

\includegraphics and "cannot determine the size..."

Post by Stefan Kottwitz »

Hello,

and welcome to the forum!
digl wrote:The problem is with the images. If I try to do it through lyx's insert graphics, it won't let me have a \ in the file path, so I can't use the macro (is there any way around that??).
Instead of a backslash \, which starts a command (control sequence), use a slash /.

"cannot determine the size..." should come from LaTeX in DVI mode, because it checks the size of the EPS image (bounding box).

With png or jpg you don't have a bounding box, which would raise that error. But only in DVI mode. With such files, use pdfLaTeX instead. Johannes already gave good explanation.

Ensure that you use pdfLaTeX with png and jpg, and (dvi)LaTeX with eps. LyX should let you select the way, choose PDF or DVI or PDF via DVI&PS. Normally you don't need to specify a file name extension for \includegraphics, but you may. The image should have the format, renaming the extension won't help, just to mention, though I'm sure you know that.

If there's still trouble, you could provide all information: the .lyx test file, the (pdfLaTeX) export file, the image and the .log file, all as attachments. With all such information fixing problems is easy most of the times.

Stefan
LaTeX.org admin
digl
Posts: 9
Joined: Tue Mar 17, 2015 9:17 pm

\includegraphics and "cannot determine the size..."

Post by digl »

Thanks Stefan.

I'm making some progress. I realized that the png works with pdflatex. The problem was making the type explicit through the [type=png] option. I took that out and it worked.

Still can't make it with the eps however (and I don't want those ugly looking pngs!). I generate a dvi file, but when I open it I have zillions of errors, and the images are not there. Im trying both LuaTeX and the DVI option in lyx, which I assume is plain LaTeX.

I have

Code: Select all

\includegraphics{d:/media}
with a media.eps file located in d:/ (also tried a .ps version). It clearly has to do with the beamer file I'm working on, because a minimal file with that code displays the image in the DVI. I think that I need to figure out how does lyx in the background take the eps file and manages to display it in a pdf built through pdflatex.

Alternatively, I could define the path with the command using lyx's graphics dialogue. I'm curious about what you said about this. If I insert a normal slash, should LyX figure out I'm trying to run a command and turn it around when it goes to latex? Anyway, if I try it, it doesn't let me, the same that happens if I add a backslash, it's gone when I look back at the graphics dialogue. Remember that I AM trying to run a command, to define the path.

Again, thanks a lot for your help!
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

\includegraphics and "cannot determine the size..."

Post by Johannes_B »

Storing a path in a macro is, in my opinion, never a good idea.

Specifying paths in LaTeX is done with forward slashes. Forward slashes work in Windows systems as well. The constant usage of backslashes in Windows seems to be like a style decision.


Another possibility is the use of XeLaTeX, which can handle all formats by using very special internals. In the following example, i used file endings to force the use of each format.

Code: Select all

% arara: xelatex 
\documentclass{article}
\usepackage{mwe}
\begin{document}
\includegraphics[width=.6\textwidth]{example-image-a.png}\par
\includegraphics[width=.6\textwidth]{example-image-b.pdf}\par
\includegraphics[width=.6\textwidth]{example-image-c.eps}\par
\end{document}


To know what really goes on in the backround of LyX, we need to have a real LyXpert around.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
digl
Posts: 9
Joined: Tue Mar 17, 2015 9:17 pm

\includegraphics and "cannot determine the size..."

Post by digl »

Thanks again Johannes. XeTex (together with deleting the type option I was mistakenly including) did the trick for the eps! It messed up some of the text, but it seems like that shouldn't be hard to fix.

Now for the paths, I'd rather have a macro in the path anyway (it allows for more flexibility that fixing it in the preamble, and editing the preamble in lyx takes a couple of steps that I'd avoid with a macro). Latex seemed to have a problem with some spaces in the path, fixed with \usepackage[space]{grffile}.

So problem solved, thank you very much Johannes and Stefan!
Post Reply