17.4.15

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:
\documentclass{article}
\usepackage{fontspec,lipsum}
\defaultfontfeatures{Ligatures=TeX}
\usepackage[small,sf,bf]{titlesec}
 
\setromanfont{Georgia}
\setsansfont{Tahoma}
 
\begin{document}
\section{Introduction}
 
\lipsum[1]
 
\section{Nonsense}
 
\lipsum[2-4]
\end{document}
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.
For a lot more infor­ma­tion, read the fontspec man­ual.

No hay comentarios:

Publicar un comentario