XeTeXXeTeX wont compile with a png image in cls

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

XeTeX wont compile with a png image in cls

Post by efroselli »

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:

Code: Select all

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

and in the Descriptions pane it says:

Code: Select all

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

Code: Select all

% Define the header/footer page style for the title page.
\fancypagestyle{titlestyle}
{
   \fancyhf{}

   \renewcommand{\headrulewidth}{0pt} % remove lines as well
   \renewcommand{\footrulewidth}{0pt}

   \fancyhead[R]
   {
       \includegraphics[width=1\textwidth]{./template_gfx/head-bar.png}
   }

   \fancyfoot[R]
   {
      \raisebox{-2cm}{\includegraphics[height=2cm]{./template_gfx/Logo.png}}
   }

   \fancyfoot[C]{}
}
The line

Code: Select all

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

Recommended reading 2024:

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

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

User avatar
Stefan Kottwitz
Site Admin
Posts: 10320
Joined: Mon Mar 10, 2008 9:44 pm

XeTeX wont compile with a png image in cls

Post by Stefan Kottwitz »

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
LaTeX.org admin
efroselli
Posts: 24
Joined: Wed Feb 20, 2013 1:24 pm

Re: XeTeX wont compile with a png image in cls

Post by efroselli »

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.
****
\includegraphics[width=1\textwidth]{./templateGfx/headBar.png}
****

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
User avatar
Stefan Kottwitz
Site Admin
Posts: 10320
Joined: Mon Mar 10, 2008 9:44 pm

XeTeX wont compile with a png image in cls

Post by Stefan Kottwitz »

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
LaTeX.org admin
efroselli
Posts: 24
Joined: Wed Feb 20, 2013 1:24 pm

Re: XeTeX wont compile with a png image in cls

Post by efroselli »

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. 8-)

EFR
Post Reply