Wrong image gives you LaTeX error

texstudio

False image format can cause premature end{document} in LaTeX

Dear friends,

I posted my problems on Microsoft Powerpoint (ppt) yesterday, at my wp blog. Binaries just give you more than just a bunch of 0 and 1. Versioning problem was just one of them. Newer version creates file that older version can’t open. Or perhaps older version has more features but then got removed in the newer version.

That’s why I try to move slowly to text file or ASCII (http://www.computerhope.com/jargon/t/textfile.htm). Being formerly a binary guy, syntax error warnings give me cramps.

And this was another LaTeX adventure. This morning I managed to solve a weird problem with my LaTeX codes. It kept showing the following warnings (I used TeX Studio by the way):

  • no bibdata ... and
  • no bibstyle ...

The main TeX file seemingly couldn’t fine the bib file. Both text (or ASCII) files are two of main files in Latex typesetting. The Tex file stores the body text and commands, while the bib file stores the reference information in Bibtex format.

So as I took myself in pages of Stack Exchange discussions, most of the answers direct me to:

  1. check the bibtex format for missing , or missing {}.
  2. missing file in the latex distribution due to installation or upgrade failure.
  3. premature end{document} command. They argue the mis-placement of such command could also make Latex ignore the bibliography{} and bibliographystyle{} commands that usually placed at the end of the main text.

All of them was checked, and double checked, and yet, both warnings still popped.

Then I went sleep mode on it.

The next morning I tried the other way around. I checked the main tex file line by line from preamble section down to the bibliography section. So I made a new Tex file and then copy-paste each section and subsection from the existing tex file.

The preamble part was safe. It looked like this.


documentclass[english]{article}
usepackage[T1]{fontenc}
usepackage[latin9]{inputenc}
usepackage{setspace}
usepackage{graphicx}
usepackage{natbib}
usepackage{booktabs}
usepackage{url}
onehalfspacing
usepackage{babel}

And at the end of my file, I placed the following commands.

bibliographystyle{plainnat} %because I used natbib pkg
bibliography{foo}
end{document}

Then I checked the sections and subsections. All were ok, until I stumbled upon this lines.

begin{figure}
    includegraphics{abc.jpg}
    caption{abc is not def or even xyz}
    label{fig:abc}
end{figure}

They were basic commands to insert figure in Latex. If I deleted the lines, the compiling went smooth. But it was the other way around when I ran the lines.

Then I changed the jpg file with another file. Strangely it went OK. So I checked the image to see what was wrong with it.

It turned out that my jpg image was actually a gif image. Although both formats are classified as raster formats, but they are not completely twin brothers (or sisters). Hence I rename it.

And what do you know. The one line that all Latex users are looking for out of the compilation process.

process exited normally
Advertisements

Published by

Erwin

Research interest: Hydrochemistry, multivariate analysis, and R programming My current focus is how to provide the hydrostratigraphy of volcanic aquifers in Bandung area. The research is based on environmental isotope measurement in groundwater and morphometry. My work consists of hydrochemical measurements. I am using multivariate statistical methods to provides more quantitative foundation for the analysis and more insight into the groundwater behaviour.

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s