LaTeX forum ⇒ XeTeXXeTeX 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

Postby efroselli » Mon Feb 25, 2013 1:57 pm

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:

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



and in the Descriptions pane it says:

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



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

  1. % Define the header/footer page style for the title page.
  2. \fancypagestyle{titlestyle}
  3. {
  4. \fancyhf{}
  5.  
  6. \renewcommand{\headrulewidth}{0pt} % remove lines as well
  7. \renewcommand{\footrulewidth}{0pt}
  8.  
  9. \fancyhead[R]
  10. {
  11. \includegraphics[width=1\textwidth]{./template_gfx/head-bar.png}
  12. }
  13.  
  14. \fancyfoot[R]
  15. {
  16. \raisebox{-2cm}{\includegraphics[height=2cm]{./template_gfx/Logo.png}}
  17. }
  18.  
  19. \fancyfoot[C]{}
  20. }


The line
  1. \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:

User avatar
Stefan Kottwitz
Site Admin
Posts: 8451
Joined: Mon Mar 10, 2008 9:44 pm
Location: Hamburg, Germany
Contact:

Postby Stefan Kottwitz » Mon Feb 25, 2013 2:31 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
Site admin

efroselli
Posts: 24
Joined: Wed Feb 20, 2013 1:24 pm

Postby efroselli » Mon Feb 25, 2013 4:16 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.
****
\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: 8451
Joined: Mon Mar 10, 2008 9:44 pm
Location: Hamburg, Germany
Contact:

Postby Stefan Kottwitz » Mon Feb 25, 2013 5:33 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
Site admin

efroselli
Posts: 24
Joined: Wed Feb 20, 2013 1:24 pm

Postby efroselli » Mon Mar 04, 2013 1:54 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. 8-)

EFR


Return to “XeTeX”

Who is online

Users browsing this forum: No registered users and 1 guest