Getting started with XeLaTeX

By now, most LaTeX users have prob­a­bly heard of XeLa­TeX, if only because it is an option in the lat­est ver­sions of the stan­dard LaTeX edi­tors such as TeXnic­Cen­ter, WinEdt and TeX­Works. But most LaTeX­ers have prob­a­bly not yet become XeLa­TeX­ers. Why should you?

XeLa­TeX is essen­tially a replace­ment for pdfLa­TeX. It was pri­mar­ily devel­oped to enable bet­ter font han­dling, espe­cially non-​​Roman scripts. If you want to write in Tel­ugu, then XeLa­TeX is going to make your life much eas­ier. For Eng­lish writ­ers, the main ben­e­fit of XeLa­TeX is the abil­ity to use the fonts on your com­puter, just as you can with other soft­ware. If you’ve grown to love using Geor­gia in MS-​​Word and always wanted to write a LaTeX doc­u­ment in Geor­gia, now you can.

Here is a very sim­ple example:


Note the fol­low­ing features:

  • The fontspec pack­age is almost always nec­es­sary with XeLa­TeX and con­tains com­mands to load the required fonts.
  • You usu­ally need the com­mand \defaultfontfeatures{Ligatures=TeX}. This is so the new fonts behave in the way we’ve come to expect with LaTeX, such as allow­ing an em-​​dash to be writ­ten as ---.
  • The two fonts that are loaded (Geor­gia and Tahoma in this exam­ple) are fonts avail­able in my Win­dows fonts directory.
  • The titlesec pack­age is loaded only so head­ings are in sans-​​serif bold in order to show the effect of the font changes.
  • The lip­sum pack­age pro­vides some non­sense text for test­ing purposes.

A dis­ad­van­tage of using XeLa­TeX is that most of the fonts on your com­puter will not come with enough fancy char­ac­ters (known as glyphs) for math­e­mat­ics. So maths has to be set using a stan­dard LaTeX font. Con­se­quently, I am not using XeLa­TeX for my math­e­mat­i­cal doc­u­ments, but I have started try­ing it out on non-​​mathematical documents.

My first seri­ous XeLa­TeX doc­u­ment is my lat­est CV where I’ve used the fol­low­ing font commands:

\setromanfont{Minion Pro}
\setsansfont[Colour=AA0000]{Myriad Pro}

For a lot more infor­ma­tion, read the fontspec man­ual.

Related Posts:

  • Vladimir Vitanov

    Hi! Great blog! I just found it today and read quite a bit, mostly about LaTeX. I’m try­ing to write my own blog on Word­Press, so I would like to ask you this: How do you get this nice LaTeX syn­tax high­light­ing? Do you use Word­Press online ser­vice, or maybe you have your own Word­Press installation?

    Thanks in advance. Great work, again.

    • Rob J Hyndman

      I have my own Word­Press instal­la­tion. The syn­tax high­light­ing comes from the WP-​​CodeBox plu­gin.

  • hith­ere

    Hi! may i know which edi­tor are you using for the xela­tex com­pile?
    Well, i have been a long –time wined­i­tor user for latex com­pile. When i am search­ing how to write pro­fes­sional resume using latex, i found your web­site. Your resume looks really impres­sive.
    Thank you in advance.

    Could you

  • Aline Menezes

    How do I get XeLa­tex work­ing with TexStudio?

  • Pingback: Research tips - XeLaTeX with TeXstudio()

  • Kumar

    I just wanted to say thanks! Helpmed me type tel­ugu and devanagari !

    • Rama

      Hi Kumar, can you please send me a sam­ple file where you could do both tel­ugu and eng­lish in the same Latex doc­u­ment. I am using Mik­Tek and TeX­works as edi­tor, which shows me the XeLa­teX option.

  • Valentina

    Can I use XeLa­Tex with LyX? I’m start­ing at LaTeX and a friend rec­om­mended LyX to me as I wouldn’t have to learn ad do all that cod­ing. I find it very use­full, but I would love to get to use all the fonts I have on my PC (I am a visual designer with an edi­to­r­ial design interest).

    I also work mostly in span­ish, as I live in Lati­namer­ica. Itell you this ‘cos you men­tion that “for eng­lish writ­ers, the main ben­e­fit of XeLa­Tex is the abil­ity to use the fonts on your com­puter” so maybe it wasn’t avail­able for span­ish con­fig­u­ra­tion… Could you clear this things up to me? Thanks a lot!

  • QS

    Your CV nau­se­ates me. How the fuck do you have so much moti­va­tion? I can barely gather the strength to work on my PhD.

  • Venkat

    Thankyou. Tel­ugu, that is pre­cisely when I landed on this page. Coin­ci­dence or con­spir­acy !! Why Telugu ?