Texmaker and Xetex on OS X

As I am coming from a Linux world I am quite used to some software that is available for Linux. One of the software I used often was Texmaker. After switching to OS X I used TexShop (as it comes bundled with MacTex) for a couple of years. It is a good LaTex editor and it (besides Latex) also supports Xetex (a TeX typesetting engine that uses Unicode and system fonts) out of the box and it nicely updates PDF documents almost on the fly.

But I recently switched back to Texmaker because of some of its strengths that I really like (most UI related):

  • one window
  • tabs
  • auto completition of commands, references …
  • a lot of icons for math symbols
  • document structure on the left side
  • quick access to almost every LaTeX command from menus and most often used ones from drop down menus
  • a better search box (although I would like it to be incremental like in Emacs :))

But it doesn’t work with Xetex right away. There is a simple solution
to this, though. All it is needed is to change two preferences
(assuming you have MacTex installed).

Go to  texmaker -> Preferences

Under Commands change Latex field to:

  /usr/texbin/xelatex  %.tex

Under Quick Build change User field to:

  /usr/texbin/xelatex %.tex|open %.pdf  

The second command can include several commands divided by | sign. So
for example we could compile the .tex file with xetex first, then
compile the auxiliary .aux file and compile the .tex document twice more
(why this is necessary is beyond this post). User field should now look
like (all in one line):

/usr/texbin/xelatex %.tex|/usr/texbin/bibtex %.aux
      |/usr/texbin/xelatex %.tex|/usr/texbin/xelatex %.tex
          |open %.pdf

Edit: there’s one drawback  —  if there are some errors in the .tex
document, Texmaker hangs up and only forcing it to shut down helps.


Authors gravatar

Philip Bliss

Hi there,

I had the same problem–force-restarting Texmaker gets old FAST!

You can solve it by setting the command line to /usr/bin/xetex -interaction=nonstopmode %.tex

Authors gravatar

Matjaž Kljun

Thank you! That worked like a charm 🙂

/usr/texbin/xelatex -interaction=nonstopmode %.tex

Authors gravatar

Flash Sheridan

Another couple of drawbacks: “|open %.pdf” uses your default PDF viewer (Preview in my case) rather than the built-in viewer. And not using the default also seems to break the PDF scrolling information, so “Click to jump to line” silently fails.

Authors gravatar

Matjaž Kljun

It depends on what you set in your preferences. In the menu

texmaker -> Preferences … Select ‘Commnads’ on the left and on the list select:

Pdf viewer – select Built in viewer.

The command ‘open %.tex’ is the same for both: built in viewer and default viewer.

If you need to synchronize PDF and tex file you’d need to use:

/usr/texbin/xelatex -interaction=nonstopmode -synctex=1 %.tex

Authors gravatar

Flash Sheridan

Duh, thanks, that *was* documented somewhere. The command-line argument didn’t actually work for me, but using \synctex=1 in the source (per http://en.foursenses.net/usingsynctex) works fine. I did have some trouble with entering the command in the QuickBuild entry field (Preview was launched instead, even though the preference was set to the built-in viewer), but using the Wizard worked around the problem.

Authors gravatar

Matjaž Kljun

I’m glad it worked in the end. I don’t know if Texmaker needs a restart after selecting a different PDF viewer. Might this be the reason why it didn’t used the one you selected?

But it works now 🙂

Leave a Reply