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 have installed "ProTeX" with "TeXstudio 2.3" & "Miktex 2.9". I get an error

! The fontspec package requires either XeTeX or LuaTeX to function

when I attempt to run

\documentclass{article}
\usepackage{fontspec}

\begin{document}
Hello world! 
\end{document}

MikTeX is said to come with some of this installed.

share|improve this question

4 Answers 4

You should compile the document with xelatex or lualatex command. For me, your document compiles with both with no errors.

share|improve this answer
    
I am an old pre-CP/M nerd. I don't use command line stuff if I can help it. Thanks for your answering my cry for help. –  Optionparty Sep 18 '12 at 6:42

You have to reconfig TeXstudio to use lualatex or xelatex instead of pdflatex which is preconfigured in TeXstudio. You can change it under options, then commands.

You can also use the command line to test whether for example lualatex is running. lualatex test will compile test.tex with lualatex.

share|improve this answer
    
'comands' reads "latex -src -interaction=nonstopmode %.tex". How should it then read? –  Optionparty Sep 14 '12 at 8:42
    
If you are pressing F6 in running your pdflatex, replace pdflatex in pdflatex -synctex=1 -interaction=nonstopmode %.tex with either lualatex or xelatex. –  hpesoj626 Sep 14 '12 at 9:24
    
@hpesoj626: Thanks for answering; I wasn't online till now. –  Kurt Sep 14 '12 at 12:15
    
Oh, I hope you don't mind. I think the comment was harmless enough. :) –  hpesoj626 Sep 14 '12 at 12:50
    
Thank you for answering. I'm going to learn fast, with everyones help in this forum. –  Optionparty Sep 18 '12 at 6:45

Also in the MiKTeX Settings (Options window) under the “Formats” tab one must activate the creation of format files (needed for fonts!) for lualatex, luatex, xelatex and xetex:

window screenshot

Select every single of them, click on ‘Change…’ and in the dialogue window “Format Definition” deactivate ‘Exclude this format when updating all format files’.

Then, very important, go to the “General” tab and update all format files, what creates also the new ones, followed by a refresh of the filename data base (FNDB).

share|improve this answer
    
I have done the above plus exclude Latex, Pdflatex, "Update Formats", and have the same error. –  Optionparty Sep 14 '12 at 8:23
    
@Optionparty: My answer is an addition to the others. You didn’t say anything to them. But also important: I’ve forgotten a second step, see my edit. –  Speravir Sep 14 '12 at 15:26

If you insist on TeXStudio you may now download TeXStudio 2.4. You can now set up your xelatex and lualatex commands with this version.

I am using Ubuntu 12.04 but TeXStudio 2.4 must have the same features as the Windows version.

See in the picture below that there is already a separate box your xelatex and lualatex commands.

enter image description here

Now, in the build option, choose your default compiler. You may now choose either xelatex or lualatex. See picture below.

enter image description here

If you don't want to update just yet, you may look at my comment in Kurt's answer.

But it is a hassle to keep on changing your default compiler. Some times it is better to just open cmd and run xelatex myfile.tex or lualatex myfile.tex. Just CD to your source folder before doing the compile.

share|improve this answer
    
I downloaded 2.4. I works great. I love the software improvements. –  Optionparty Sep 18 '12 at 6:36
    
I'm glad it helped. –  hpesoj626 Sep 18 '12 at 6:52

Your Answer

 
discard

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.