Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'm writing an automatic compiling pipeline that should be able to compile any given tex file into a pdf. The diversity of the input tex files mainly shows up in what format of figures they use and how they include them. The figures are mostly eps, ps, and pdf, and they may use psfig, graphix etc to include them.

I'm not particular clear on what criteria I should set up in the pipeline about what figure handling packages used in those tex file should trigger which latex compiling scheme among pdflatex, latex, and xelatex. Any easy rule of thumbs or any tables that I can look for the rules? thanks.


I am aware the question is not well posed in the first place. I think what I want is 1) is there a tool that could compile all sorts of tex files with different figure formats and figure handling packages. 2) if not, is there a specific keyword I should search for in the file that tells me what compiling method I should use?

My current design is to try various compiling schemes one by one (latex->pdflatex->xelatex) until it succeeds.

share|improve this question
psfig is obsolete; nothing that can be done with it can't with graphicx. Moreover the more recent TeX distributions allow for conversion on the fly of EPS files into PDF, so the question is not well posed. It's different if you're talking about pstricks. –  egreg May 29 '12 at 21:48
@egreg Thanks for pointing out the obscurity in the way I present this question. It's just that I am not quite sure if there is a rule for me to treat each files differently or there is, as you said, an one tool for all. The question arises from my frustration after applying pdflatex to all the files. –  nye17 May 29 '12 at 21:51
This is a pretty interesting question, and I'd like to see the answer to it. It seems you have a relatively large "training set"? If no one has the answer readily available and you have to do your own research based on your files (I would have thought most documents should compile with pdflatex unless they're using PSTricks graphics or some special input character set, which might require the use of xelatex), it would be great if you could write a self-answer. –  Jake May 29 '12 at 22:06
@Jake The "training set" is potentially large. The motivation for this small fun project is that , I want to reformat the .tex files of academic papers from Arxiv so that I could produce pdfs that are friendly to my kindle eReader. Although the Arxiv articles are generally well-typed, there are still scientists who are terrible TeX practitioners, therefore the need to encompass all their crazy adventures in figure handling. –  nye17 May 30 '12 at 4:45
Since your use-case is arxiv articles, you can find out from the PDF what was used to produce it. Running pdfinfo on a PDF from the arxiv I get dvips + GPL Ghostscript GIT PRERELEASE 9.05 which strongly suggests latex. On one of my articles, I get LuaTeX-0.70.1 so it was lualatex. On another, I get xdvipdfmx (0.7.8) whence xelatex. So if you download the source and the PDF then it's an easier task than just going from the source alone. –  Loop Space May 30 '12 at 11:01

2 Answers 2

"to compile any given tex file" will not work as they are files which are incorrect and can't be compile.

If one assumes that the given tex file can be compiled but that you don't know how: Looking only at the content of the file is not enough. As an example if your file looks like this:


Then you should not use xelatex (because of inputenc) but if latex or pdflatex can be used (or both) depends on the format(s) of the external image.

Also while things like fontspec, polyglossia, pstricks or driver options like \usepackage[dvips]{....} all are indications of the expected engine they don't exclude other engines (as they can be hidden in conditionals) and you can't completly rely on them if you don't have complete trust in the code of the tex files – and imho you shouldn't trust code which uses obsolete packages like psfig or which tries to include .ps (non-encapsulated postscript) as graphic.

At last: Finding the correct engine is perhaps not enough. Some documents only compile with additional command line switches (--shell-escape) or need a special format.

share|improve this answer

If the question is not limited to graphics and could offer one criterion.

If you find a \usepackage{fontspec}, it has to be xelatex or lualatex that was used in the first place.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.