How to use LaTeX directives

Many programming languages (including LaTeX) have directives or pragma–formatted comments that tells the compiler to do something specific.

LaTeX pragma: de facto directives are compatible with popular LaTeX editors including TeXstudio.

Specify LaTeX compiler and bibliography toolat the top of the main/root LaTeX document like:

% !TeX program = xelatex
% !BIB program = biber

LaTeX projects often use Biber for bibliography management. The above directives tell TeXstudio to use XeLaTeX compiler and Biber bibliography tool when compiling the document.

Trouleshooting missing XeTeX compiler

If XeTeX directive:

% !TeX program used: xelatex

yields:

Error: One command expansion invalid.
  Parent Command: compile
  Primary Command: compile

Fix by installing XeLaTeX compiler

  • Linux: apt install texlive-xetex
  • macOS: brew install mactex
  • Windows: get XeLaTeX via MikTeX

Restart TeXstudio to use XeLaTeX.