## LaTeX forum ⇒ XeTeX ⇒ XeTeX wont compile with a png image in cls Topic is solved

Information and discussion about XeTeX, an alternative for pdfTeX based on e-Tex
efroselli
Posts: 24
Joined: Wed Feb 20, 2013 1:24 pm

### XeTeX wont compile with a png image in cls

Last Friday I tried to learn how to use XeTeX to compile some documentation for my company. Up to now I have used pdflatex with no problems, but the marketing people were requesting the use of certain Opentype fonts which could not be accessed with the standard setup.

I got the font problem cracked and felt triumphant, but ran into a separate problem. We are using a customized class to create the front matter for our documentation. This class calls two png images which are a colored bar and a company logo. The pdflatex compilation never had any problem with them, but the XeTeX will not work unless I comment them out in the cls file.

Here is the error that I get:

`Unable to load picture or PDF file 'C:/Users/me/Documents/filedirectory'.Missing \$ insertedExtra }, or forgotten \$.Extra }, or forgotten \$.Package graphics Error: Division by 0.`

and in the Descriptions pane it says:

`\selectlanguage      {english}%The requested image couldn't be read because it was not a recognized image format.`

Here is the section of code in the class file that calls the images:


The line
`\RequirePackage{graphicx}`

is also present in the class, so it's not as if a graphic package is missing.

Can anyone decipher what the problem here is? I'm a LaTeX newbie and the whole argument for using Lyx was that I wasn't supposed to trouble my pretty head with formatting issues, so I need to crack this quickly before my employers complain...

Cheers,
EFR
Last edited by Stefan Kottwitz on Mon Feb 25, 2013 2:28 pm, edited 1 time in total.
Reason: code marked

Tags:

Stefan Kottwitz
Posts: 9567
Joined: Mon Mar 10, 2008 9:44 pm
`Missing \$ inserted` means, math mode was entered but you didn't specify it. It can be caused, for example, by an underscore which is for subscripts in math mode. So perhaps remove the underscore _ in the path name of your included images.

Stefan

efroselli
Posts: 24
Joined: Wed Feb 20, 2013 1:24 pm
Thanks!
That solved the problem, in part. I was still getting an error that it could not find the images. Finally I figured out that it would not tolerate white space as well as subscripts in any of the path names. After changing all the path names, I can finally compile my document with all the requested fonts.

But now this implies a major overhaul of path-naming rules throughout the company, and this could generate friction. Is there anyway to keep the path names as they are? Putting the path in quotes, or something like that? I notice in the code snippet I provided, the call of the path is relative, e.g.
****
****

This is so that we can manage the files in several mirror directories with a Subversion versioning system. So there too, it would be better if perturbation to the firm and its working habits could be kept to a minimum. Anyway to code this so that I don't have to write in a literal, white-space-free path at every turning?

Thanks again for your coding help.

EFR

Stefan Kottwitz
Posts: 9567
Joined: Mon Mar 10, 2008 9:44 pm
You could simply load the grffile package in your document preamble for support of white spaces in paths or file names.

Btw. please don't mark code by ****. Just use the Code button when editing, so we get syntax highlighting for better readability. Have a look at your first post in this topic, which I edited for you, marking code.

Stefan

efroselli
Posts: 24
Joined: Wed Feb 20, 2013 1:24 pm
Thanks! I'll have a go with the package.
I was wondering how my code samples came out so attractively presented in the web interface. I didn't know about using the Code button but will use it from now on with enthusiasm.

EFR