Wrong image gives you LaTeX error


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.


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

bibliographystyle{plainnat} %because I used natbib pkg

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

    caption{abc is not def or even xyz}

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

About the author

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 behavior, especially its interaction with surface water. I use open source apps like R and Python to do the job. In my spare time, I also have a side project to promote open science in Indonesia's research workflow. One of my current focus is promoting INARxiv, as the first preprint server of Indonesia (osf.io/preprints/inarxiv) and serving as ORCID and OSF (osf.io) ambassador. Research interest: Hydrochemistry, multivariate analysis, and R programming. Blog: dasaptaerwin.net, derwinirawan.wordpress.com. (https://orcid.org/0000-0002-1526-0863)