GeneralPng in Latex

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
MatzeTung
Posts: 2
Joined: Wed Oct 22, 2008 3:26 pm

Png in Latex

Post by MatzeTung »

Hello,

I have already read some forum posts about using Png files in latex documents. Mostly, the answer was, that this is not possible if you do not use PdfTex.

But I want to compile my latex code to dvi and use png images. Therefore, I generated a .bb file (with bmeps), which contains information about the bounding box. Interestinly, the following latex source compiles and produces a dvi file which is correctly displayed (including the image) in my dvi viewer.

Code: Select all

\documentclass[12pt]{article}
\usepackage{graphicx}
\begin{document}
\section*{Test}
\begin{figure}[h!t]
\centerline{
	\includegraphics[width=8.1cm]{figures/test.png}
}
\caption{Test image.}
\end{figure}
\end{document}
And here is the problem:
This tex source compiles on exactly 2 computers. On all other computers (I have tried 4), I get the error message:
"Cannot determine size of graphic in figures/test.png (no BoundingBox)."

In principle, it should be possible to use pngs in latex, since it works on 2 machines. All machinges are using the same Miktex version (for windows) and TexnicCenter. I have not changed any packages by hand, I just used the standard Miktex installation.

What is your experience? Is it possible to use Pngs in Latex? Do I have to change any settings?
Is this tex source working on your machinges?


Thanks for answers.

Recommended reading 2024:

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

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

Silver
Posts: 4
Joined: Tue Nov 11, 2008 12:30 pm

Re: Png in Latex

Post by Silver »

Hello,

I have a similar problem, and tried "all" the solutions I have found on the web. I do get the error message just like you about the bounding box.

But for me pdflatex actually generates the dvi (with the error message about bounding box) and yap opens it (but complains). But the image size is blown up all over the page. If I put [width=1cm] i get aabout 6-10 cm on the page but the centering is screwed up.

When I generate a PDF file it all looks very good (and I dont need to shrink the image width).

This workaround works for me to generate decent dvi's. But ofcourse all the pictures appear as black boxes (but with correct size).
\usepackage[demo]{graphicx}

Anyone, any idea?
Andre Smit
Posts: 6
Joined: Fri Apr 04, 2008 10:17 pm

Re: Png in Latex

Post by Andre Smit »

Never tried this but it may help:

http://www.ccn.yamanashi.ac.jp/~kondoh/winbbe.html
MatzeTung
Posts: 2
Joined: Wed Oct 22, 2008 3:26 pm

Re: Png in Latex

Post by MatzeTung »

Unfortunately, the bounding box file is not the problem. You can just generate it with bmeps which comes with latex. The problem is, that I do not get any pngs into a dvi document, even if the bounding box file (.bb) is present.
daleif
Posts: 199
Joined: Wed Nov 19, 2008 12:46 am

Re: Png in Latex

Post by daleif »

the DVI format NEVER contains the included graphics, no matter what format it is. It contains a reference to it, but not the file it self.

Some viewers can then handle this reference and actually find and show the graphics.

Why do you need to be in DVI format? Why can't you just work directly in PDF?
Silver
Posts: 4
Joined: Tue Nov 11, 2008 12:30 pm

Re: Png in Latex

Post by Silver »

There are 2 reasons why I work in DVI:

1. It compiles and update faster than PDF and always point to the row/page I edit in Latex (PDF opens firstpage)
2. If I double click a line in the DVI the latex editor jumps to that line (I have not managed to do this in PDF)
daleif
Posts: 199
Joined: Wed Nov 19, 2008 12:46 am

Png in Latex

Post by daleif »

Silver wrote:There are 2 reasons why I work in DVI:

1. It compiles and update faster than PDF and always point to the row/page I edit in Latex (PDF opens firstpage)
2. If I double click a line in the DVI the latex editor jumps to that line (I have not managed to do this in PDF)
that is what I do on Linux as well, but my documents are created such that they can be compiled by both. Using bad eps versions of relevant PNGs

as to your comments (assuming windows)

(1) use sumatra pdf, Adobe reader is a joke.

(2) use synctex (internal feature in miktex 2.7 and texlive 2008), sumatra pdf can handle this using e.g. winedt as the editor. Otherwise try TeXWorks, new editor with buildin PDF previewer, reconfigure the pdflatex setting in it to
synctex=-1, then you can more or less jump back and forth.
Post Reply