[Tex/LaTex] Why is TeXWorks generating corrupted pdfs


I have installed MikTeX and TeXWorks on my Windows 7 PC.

When I edit a .tex file in TexWorks and then save the file as a pdf, the pdf created cannot be opened by Adobe Reader; Reader complains that the file is damaged.

Nonetheless, executing pdflatex myFile.tex on the windows command line creates a pdf that Adobe Reader can reliably open.

Why can't I create such pdfs through the TexWorks IDE?

Best Answer

The .pdf output of a TeX file is obtained after being compiled with one of the many compiling methods such as PDFTeX, PDFLatex, XeTeX etc. This is analogous to any other programming language, the source code cannot be saved as an .exe file to make it an executable.

In TeXworks one can use the play button to compile the .tex document with a compiler that can be set next to it.

However, as Peter Grill mentions, there are some peculiarities concerning the output and auxillary files during the source code compilation especially in Windows environment. The most common is experienced with Adobe Acrobat viewers. They do not let you to compile the same document if its output is already open in it since they lock the file for further modifications and TeX compilers complain and stop compiling. If this is a problem that should be addressed you can safely switch to another .pdf viewer such as SumatraPDF.

Another example is the removal of .aux files, as in some systems they are also locked and cannot be deleted even though they are not essential and can be reproduced.

These type of peculiar behavior tend to cause less and less annoyance when you get more experience with the machinary.

Happy TeX'ing.