TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to define a run configuration for using XeLaTeX with BiBTeX from within TeXWorks, but I'm coming up empty.

I tried following this guide and adapt it to what I wanted to do, and ended up with this:

program: xelatex
argument: "%1.tex" && bibtex "%1" && xelatex "%1.tex" && xelatex "%1.tex"

but when I run it by hitting Ctrl+T I get the following message:

This is XeTeX, Version 3.1415926-2.3-0.9997.5 (TeX Live 2011)
restricted \write18 enabled.
entering extended mode


and then nothing happens.

How do I configure TeXWorks to run XeLaTeX+BiBTeX+XeLaTeX+XeLaTeX when I hit "compile"?

For extra credit, the run configuration should not run more times than necessary, i.e. not all four runs if no references have changed.

share|improve this question
up vote 7 down vote accepted

The simplest way is to create a new xelatexmk "engine" in the "Typeset" menu; instructions are at


It's sufficient to change pdflatex with xelatex. If you also put at the beginning of the file the "magic line"

% !TEX program = xelatexmk

this new engine will be automatically selected. The script latexmk will run the necessary programs the right number of times to resolve cross references and build the bibliography.

In the end, the window for defining the tool should look like the following

Name: xelatexmk
Program: latexmk

Arguments: -pdf
           $pdflatex=q/xelatex $synctexoption %O %S/
share|improve this answer
Brilliant, thanks! =) – Tomas Lycken Nov 12 '11 at 21:50
Is it possible to add make index within that code? So it becomes exlatex+bibtex+makeindex+exlatex+exlatex – user24460 Jan 16 '13 at 2:38
@user24460 That's a job for latexmk; I don't know if it supports exlatex – egreg Jan 16 '13 at 10:50

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.