I use plain LaTeX for research papers (which don't run without error in XeLaTeX) and XeLaTeX for presentations (which use fontspec). I am working with Kile and have a shortcut (Alt+2) for QuickBuild with PDFLaTeX which I am very accustomed to. Now I could easily choose a different Shortcut for a QuickBuild with XeLaTeX. However, I always accidentally push Alt+2 creating errors, which is a bit annoying.

Is there any way to have Kile recognize automatically which command should be used to build the current file? I'm fine with putting some document type declaration like "% use xelatex" at the beginning of the document if that helps.


If you use Linux or Mac, you can use the following script as "compiler" for Kile:

read -r line < "$filename"
if [ "$directive" == "% use" ]; then
    eval "$latex" "$filename"
    eval pdflatex "$filename"

It checks if the first line of the input file contains the % use [compiler] directive and executes it if found, if not it defaults to pdflatex.

Note: this does not copy other command-line arguments (such as --shell-escape), and probably has other problems I didn't think of.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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