Creating S Olarly Multilingual Documents Using Unicode, Opentype, and Xǝtex
Creating S Olarly Multilingual Documents Using Unicode, Opentype, and Xǝtex
Creating S Olarly Multilingual Documents Using Unicode, Opentype, and Xǝtex
Version 1.4
is is a work in progress. Please send comments or corrections to:
hospes02@solarsfonts.net.
Abstract
is document is intended for people who are new to TEX and/or to XƎTEX
and who have a particular need to prepare multilingual, Unicode-based doc-
uments that take advantage of OpenType features.
• Sections 1–3 provide the information that new users need to understand
what TEX is all about and that will help them decide whether they wish
to learn TEX.
• Sections 4 and 5 provide guidance on geing started with TEX, using the
TeXworks development environment.
• Sections 6 and 7 plus the Appendices show how to take advantage of the
advanced Unicode and OpenType features available in XƎTEX.
ere is mu information available online about TEX. Some of it is overly
complex for beginners; at the same time, it is hard to find guidance about using
Unicode and OpenType with XƎTEX. is article is by no means a complete
guide to TEX, but aer reading it users should be able to get a basic document
working using the TeXworks environment and know how to access OpenType
features. ey can then use other resources to learn more about TEX in general;
some suggestions for this are provided.
ose experienced with TEX but new to XƎTEX, Unicode, and OpenType
can consult Sections 6 and 7 plus the Appendix on fontspec, while skipping
the other sections. Sections 1–3 will be useful to anyone new to TEX even if
Unicode and OpenType support are not important.
1
is article was prepared using TEXworks and is set in Linux Libertine.
2
Contents
1 Why TEX? 5
3
12 Appendix E: Some Traditional TEX Keystrokes 40
List of Figures
1 e TEXworks environment. . . . . . . . . . . . . . . . . . . . 7
2 A larger view of the editor window. . . . . . . . . . . . . . . 8
3 TEXworks’s File / New from Template . . . dialog. . . . . . . . 13
4 A basic TEXworks document. . . . . . . . . . . . . . . . . . . 14
5 Choosing the appropriate processor before typeseing. . . . . 15
6 Loading hyphenation files. . . . . . . . . . . . . . . . . . . . . 20
4
1 Why TEX?
Building on the foundation of Unicode, OpenType fonts provide an abun-
dance of features that make it possible to create high-quality typography in
many languages. In addition, some of these features are important to sol-
ars in fields in as classics, medieval studies, biblical studies, and linguistics.
If you need basic information about Unicode and OpenType, particularly re-
garding the role that OpenType can play in solarship, see my book about
document preparation for solars. It provides pointers to many other sources
in addition to the information provided in the book itself. e current edi-
tion is out of date, and a new edition will be available in July 2009 from
http://scholarsfonts.net.
As of April 2009, Windows users who want to take advantage of these ad-
vanced OpenType features have limited options. (e situation with Mac OS
X is mu beer.¹) ese options include the commercial desktop publishing
programs ark Express and Adobe InDesign and the open source typeset-
ting language TEX and its extension XƎTEX. Scribus, the open source desktop
publishing app, does not yet support OT features for advanced typography.
Microso Word 2007 supports a limited number of OpenType features, not
enough to make it useful for many solarly needs. For more information
about whi programs support Unicode and OpenType, see REFERENCE .
ark and InDesign provide very good support for OpenType features, but
they are expensive even if one qualifies for academic pricing. Some people also
prefer, for philosophical reasons, to use and support open source soware. TEX
is an open-source typeseing language designed specifically to produce high-
quality documents; it is widely used in mathematics but is less well known in
other academic fields. XƎTEX is a version of TEX that can take advantage of
Unicode and OpenType features, providing an alternative to the commercial
products, but installing and learning this soware can be intimidating. is
document reflects my own experiences as a relative newcomer to TEX and is
designed to help others who wish to try it. Note that this is not a complete
tutorial on TEX; there are already many su resources available, as discussed
below. is document focuses on what beginners who require Unicode and
OpenType support need to know. Because Unicode and OpenType are relative
newcomers to the TEX world, this information is not so easy to come by.
5
run through a processor that produces the formaed output; nowadays, this
will probably be a PDF file. Su systems were used on standalone typeset-
ters prior to the personal computer era and were created for early PCs before
Windows and Mac OS made development of WYSIWIG ² programs su as
InDesign possible.
ere are some advantages to the TEX approa. It is designed to help users
write well-structured documents by using tags su as \section and \subsec-
tion. It also separates, to a large extent, the content from the final design. TEX
utilizes document classes, whi are predefined layouts that specify su fea-
tures as margins, headers and footers, font sizes, and so on. ere are many
of these available for different types of documents su as articles, books, etc.
One can customize a document class or write a new one, but many users find
that a document class prepared by a knowledgeable designer produces very
good results, perhaps beer than they could produce on their own using a
word processor. Finally, it should be noted that while word processors have
goen more and more bloated, TEX is still small and efficient, even though it
can do everything the word processors can. A MiKTEX download is about 83
megabytes, whi includes many extra paages and their documentation; the
actual files needed to compile a document are very mu smaller. Compare
this with the 500+ megabytes needed for a typical word processor. Because
TEX source code is composed exclusively of plain text, these files are also very
small, compared to those produced by most of today’s word processors. A TEX
installation and some source files can easily fit onto a flash drive.
e screen shot in Figure 1 below shows a typical editing session using the
TEXworks development environment, with the source code on the le and the
output in format displayed on the right.
Figure 2 (page 8) shows a larger view of a TEXworks editing window. e
TEX typeseing commands are colored, and at the boom of the window ap-
pears a panel (with green text) displaying the messages that the compiler gen-
erates when it processes the source code. ese messages can very useful in
traing down errors in your source code. Some people are put off by the
presence of the many tags that one must enter in TEX source code. is is very
different from a program and does take some geing used to. If the
tags bother you and take the focus off your writing, I suggest using a familiar
word processor to write and edit; don’t waste time with fancy formaing since
that will be done later in TEX. Once the text is finished, copy it and paste it
into TEXworks (or whatever editor you use). is will remove any formaing
you applied in the word processor. Or save the file as plain text and open it
directly in TEXworks. You can then add the TEX tags and typeset the docu-
ment. As you get more experienced, you’ll probably find it’s faster to add the
tags as you go along, and perhaps you will find them less distracting. Despite
the need to shi to a new paradigm, people who need sophisticated typog-
raphy—particularly via OpenType features—should at least consider XƎTEX,
6
Figure 1: e TEXworks environment.
7
Figure 2: A larger view of the editor window.
8
paages available that aid in the creation of critical editions of text; compli-
cated numbering semes and apparatus criticus are mu easier to handle
with these paages.³
9
• You may have trouble doing certain things or think they can’t be done
in TEX. Before giving up, see if someone has wrien a paage that will
do what you need. For example, TEX provides a tabular environment
that allows you to create simple tables. But this environment can’t break
tables across pages, print a header row at the top of ea page of a multi-
page table, use color in tables, and do many other things you might want.
e paages longtable and colortbl enable you to do them. e need to
look for additional paages makes using TEX a bit messier than using
a standalone application; it’s just part of the learning curve. e best
place to look for paages not included with your distribution of TEX is
in the CTAN repository (see page 17).
• Unicode support in TEX is relatively new; it began in 2004 when Jonathan
Kew released the XƎTEX paage, about whi more will be said below.
From the beginning, TEX users could enter the aracters needed for Eu-
ropean languages, and later on paages were created to handle other
scripts su as Arabic. But these older systems are not Unicode-based
should not be used now for serious multilingual work. Mu of the in-
formation that you can find on the internet about TEX may be outdated,
particularly in regard to support for languages other than English.
• XƎTEX includes support for OpenType features and AAT features on Mac
OS.
• Prior to XƎTEX, users could not directly use fonts installed in their operat-
ing system. TEX comes with a few fonts, the Computer Modern family
designed by Donald Knuth as part of the original TEX system. ese
fonts, used by default in TEX, have a rather light look to them and it is
oen possible to recognize a document produced with TEX just by the
look of these fonts. It is possible to add other fonts to a TEX installation,
but this requires mu additional work. Until XƎTEX, la of support
for Unicode and system fonts made TEX an inappropriate oice for the
growing number of people who require Unicode-based soware.
• At a minimum, you will need three things:
– a version of TEX, referred to as a distribution; in particular, you
need XƎTEX if you want to use Unicode and your installed system
fonts. A distribution includes many popular paages in addition
to the basic TEX typeseing engine.
– an editor to create the source code; there are editors specifically
designed for this task, although any plain text editor can be used
as long as it is Unicode-based
– a way to view and print the output files; there are various ways
to do this, some of whi require Ghostscript and GSview (open-
source equivalents to Adobe’s PostScript language and Reader so-
ware)
• ere are programs designed to help the beginner get running with TEX
as easily as possible. In particular, beginners should take advantage of
10
one of the integrated development environments that aid users in in-
stalling TEX, entering and correcting the source code, and producing
the final output within one application. At the moment, the only su
environment that can handle Unicode and OpenType on Windows is
TEXworks, so I will assume that is the environment that you are using.
⁴
In short, if you are ready to try TEX, you need to do four things:
• download and install the soware
• learn your way around the TEXworks environment
• start learning LATEX, whi will enable you to create basic documents
• use XƎTEX-specific features to control font selection and apply OpenType
features
11
e following assumes that your computer system is Unicode-based and
that you already have things set up to enter text in whatever languages you
require.
12
Figure 3: TEXworks’s File / New from Template . . . dialog.
the advanced font selection features of XƎTEX. To create a basic document for
XƎTEX, oose File/New from Template… and you will see the window shown
in Figure 3.
Choose the article-fontspec.tex template and a new document will be cre-
ated that looks like Figure 4. Note the use of the % aracter to separate the
actual commands from comments. Note also the curly braets { } that enclose
options for the various commands. ese are very important; to avoid error
messages, don’t accidentally delete one or add one two many. e baslash
aracter \ before ea command is also essential. If the text in the editor is
too small, enlarge it or ange to a more legible font using the Format/Font
command (this affects what you see in the editor, not what appears in the final
output). To make your oice the default whenever you start TEXworks, set it
using the Edit/Preferences dialog.
e preamble begins with the \documentclass command. Every TEX doc-
ument must include this. For this example we will use the article class, whi
is designed (as its name implies) for writing articles of the sort that appear in
academic journals. Following the \documentclass command you find several
examples of the \usepackage command. is command tells TEX to include
the paages that you need to use when it compiles the document. If you use
a command that depends on having a particular paage loaded and the pa-
age is not given in the preamble, you will get error messages. For XƎTEX docu-
ments, always use the fontspec, xunicode, and xlxtra paages. e graphicx
paage is needed if you want to include any graphics; you can remove it
otherwise.
Unless you have the font Charis SIL on your system, ange the \setmain-
font to something more appropriate. If you are in the US, just delete (or com-
ment out using %) the \geometry paage, since TEX defaults to US leer size
paper.
13
Figure 4: A basic TEXworks document.
14
Figure 5: Choosing the appropriate processor before typeseing.
15
at the lower right, and you can use the command to jump to a given
line in order to fix an error when one is identified during compilation. One
useful thing to keep in mind about errors: start by fixing the first one, since an
error near the beginning of a document may generate others that will vanish
aer the offending first one is fixed.
You cannot yet print the file from TEXworks’s output panel; instead,
you must open the in Adobe Reader or another viewer, then print.
is will be fixed in a future version.
You can now use the “Short Manual” to learn more about using the TEX-
works’s editor, su as how to use the auto-completion feature to save time
when typing TEX commands, and mu more.
• LATEX for Word Processor Users by Guido Gonzato is helpful for new-
comers because it shows the LATEX equivalents for common word pro-
cessor commands. It is distributed with MiKTEX or can be downloaded
separately from here: ftp://tug.ctan.org/pub/tex-archive/info/
latex4wp/latex4wp.pdf
• ere are several printed books that tea LATEX; a good one is A Guide to
LaTeX by Helmut Kopka and Patri W. Daly (Addison-Wesley; fourth
edition 2003).
16
• A useful two-page summary of LATEX commands is available at http:
//www.stdout.org/~winston/latex/latexsheet.pdf
e best place to go for further help is CTAN, the Comprehensive TeX Arive
Network, at http://tug.ctan.org/. ere is lots of helpful stuff here, includ-
ing the very important TeX catalog online, http://www.ctan.org/tex-archive/
help/Catalogue/bytopic.html, where you can find many additional pa-
ages and their documentation along with additional tutorials.
17
• enter ‘e’ followed by a combining acute. To get this aracter:
– use a special keyboard that supports combining marks
– copy and paste it from a utility su as Character Map or BabelMap
– use the XƎTEX command \char”0301
In all cases except the last, your output file will contain the aracter
U+00E9, ; xunicode has taken care of ang-
ing the given text into the appropriate precomposed Unicode aracter. Com-
bining marks entered using \char” plus hexadecimal digits, however, are not
anged into precomposed forms.⁷
Most people will prefer the first option (typing the aracter directly) if it is
available, since it lets you see the actual aracter in your source file. However,
all three work equally well. e traditional TEX commands for accent marks
are particularly convenient for those who have been working with them for a
long time. In addition, they are useful for marks that are usually not supported
by keyboards, su as the macron (\=) and the breve (\u), or for aracters
that you enter only infrequently. Anyone who regularly types in Spanish,
for instance, would certainly want to install a keyboard that provides easy
access to the necessary aracters. Someone who on rare occasions types a
Spanish word with accents or inverted question marks might be satisfied with
the older TEX conventions. A list of the traditional TEX keystrokes for accents,
aracters, and common symbols is given in Appendix E.
⁷If you are creating a PDF to be printed and it looks good, you don’t need to worry about exactly
what aracters are in the output file. However, if the text may be reused for other purposes later, this
information may be important.
18
y̆. e \kern command, when followed by a negative value, moves the
following aracter closer to the previous one.⁸ If you need to use su
a combination many times in your document, you can define a custom
command for it, su as the following:
\newcommand{ybr}{y\kern-4pt\char”0306}
whi will produce a y-breve every time you enter \ybr.
⁸Don’t put a space between the base leer and the following combining mark, or you will have to
kern by a very large amount to ba up over the blank space.
19
Figure 6: Loading hyphenation files.
Note that you do not have to use polyglossia for le-to-right scripts if
you don’t need the special features it provides. e opening of the Odyssey,
printed below, appears just fine, since the lines of poetry avoid any need for
hyphenation and the default font used for this document contains Unicode
Greek aracters as well as Latin:
Ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν:
πολλῶν δ᾽ ἀνθρώπων ἴδεν ἄστεα καὶ νόον ἔγνω,
πολλὰ δ᾽ ὅ γ᾽ ἐν πόντῳ πάθεν ἄλγεα ὃν κατὰ θυμόν,
ἀρνύμενος ἥν τε ψυχὴν καὶ νόστον ἑταίρων.
(e source code for this document does load polyglossia, but I did not put
\begin{greek} and \end{greek} tags around these lines, so they get no spe-
cial treatment.) You must use polyglossia if the main font on your document
does not contain Greek (or Hebrew or Cyrillic or whatever other script you
need) and if want hyphenation and other niceties.
20
6.3 Creating Right to Le Text
You should not have trouble entering right-to-le text if you already have your
computer set up to use Hebrew, Arabic, or another of the right to le scripts
that are supported in Unicode. (If you have not yet set up that capability, you
need to do so before using RTL text in XƎTEX.) e following examples will
use Hebrew, but the same principles will apply to Arabic, Syriac, etc.
21
ble (and omit polyglossia). In this case, put small amounts of text inside the
command \RL{ }; for larger amounts, use the \setRL command, whi is
terminated with \setLR.
⁹ose with some experience in using Unicode RTL text may realize that this procedure does not
follow the Unicode bidirectional algorithm. is algorithm requires only a RLO at the beginning and
a PDF at the end for short amounts of text (full paragraphs do require an additional, higher-level
command in a word processor or editor to get paragraphs right-aligned.) e need for the additional
RLO is due to the way XƎTEX interacts with the ICU text renderer that it uses.
22
7 Using Fonts and OpenType Features
7.1 LATEX Font Basics
ere are a few things you should know as you begin working with fonts.
fontspec, following in the footsteps of LATEX, thinks in terms of font families.
We saw on page 13 above how to use the \setmainfont command to set the
default font for the document. If the font you specify here has bold, italic,
and bold italic versions (and the font maker has named them in the custom-
ary ways internally) then the right font will automatically be applied when
you ask for bold or italic text. e main font is usually a serifed face. TEX
traditionally defines two other families, a sans-serif and a monospaced font;
use the \setsansfont and \setmonofont commands. You can ignore these if you
don’t plan to use the other font families in your document. Notice also that
the default font size is usually set as part of the \documentclass command in
the preamble.
Aside from the default, font sizes are usually set in relative, not absolute,
terms with the LATEX commands (from smallest to largest) \tiny, \scriptsize,
\footnotesize, \small, \normalsize, \large, \Large, \LARGE, \huge and \HUGE.
e advantage of this procedure is that if you ange the default, LATEX can
adjust all the other font size anges relative to the new default; you don’t
have to go around manually anging ea one. (You can, of course, specify
exact sizes if you wish.) e same is true for seing the font families, where
one seing at the beginning can control the entire document.
In LATEX, the appearance of text may be anged in two main ways, by
using a declaration or a command. A declaration is a command that affects the
entire document forward from the point where it is given (unless specifically
anged by a subsequent command).
Font anging commands have both command and declaration forms. To
swit from the default roman font to the sans-serif family, you can issue either
the declaration \sffamily or the command \textsf{sometext}, where sometext
is the text that you wish to be printed in the sans-serif font. You can see that
if the sans-serif text is long, it would be easy to get lost and forget the closing
curly braet. Furthermore, your italic text might have other font anging
commands nested inside it, su as commands for boldface or underlining,
potentially leading to further confusion. So, in general, use the declaration
form for anything longer than a few words or a short sentence.¹⁰ e table
below lists the common font commands.
¹⁰It is possible to put the declaration form inside a grouping, like this: {\rmfamily text text}. In
very complicated situations you may need to do so, but it is unusual.
23
\textrm{text} \rmfamily applies the roman family
\textsf{text} \sffamily applies the sans-serif family
\texttt{text} \ttfamily applies the monospaced family
\textnormal{text} \normalfamily applies the default family
\textbf{text} \bfseries produces boldface text
\textit{text} \itshape produces italic text
\textsc{text} \scshape produces
\emph{text} \em produces emphasized text
\underline{text} produces underlined text
24
features—and the need to sort out the names for those accustomed to OT is a
small price to pay.
\fontspec[Ligatures=Discretionary,Numbers=OldStyle]{Linux Libertine}
it would set the font to Linux Libertine with the OT Discretionary Ligatures
and Oldstyle figures turned on. Note the following:
• the OT (or AAT) features go inside square braets
• the name of the feature is followed by an equal sign, then the option;
multiple features may be selected at once if separated by a comma; no
spaces allowed inside the square braets
• names are case sensitive
• see the art in Appendix A for a list of OT features and options plus
some additional information
• names of fonts inside the curly braets must be the display name, i.e.,
the name shown when you pull down an application’s font menu (it
may contain spaces)
You will want to set any OT features you want to apply throughout the doc-
ument as part of the preamble.
To add a new OT feature to the font and features already in effect, you
can use the \addfontfeatures command. Note that there is a slight difference
in syntax between \addfontfeatures and other commands:
\fontspec[Numbers=OldStyle]{Cardo}
\addfontfeatures{Numbers=OldStyle}
e first example applies both a font ange and an optional feature, while
the second applies only a different feature. e differing use of square and
curly braets may seem odd, but actually is logical. e main point of the first
example is to ange the font, and an option is applied along with that. With
\addfontfeatures, the whole point of the command is to ange the option; the
option is not subservient to any other command.
Do note that any anges made with \addfontfeatures will apply to the
rest of the document or until they are cancelled by a new command. If you
want to apply a feature to only a small amount of text, put the entire command
and the associated text inside curly braces like this:
{\addfontfeatures{Numbers=OldStyle}
In 1894 and again in 1902 we went West.}
25
Here the oldstyle numerals will be applied only to this one short sentence,
and the default lining numerals will resume aer the end of the group. If
the text is long or you get lost in too many curly braclets, you can create an
environment using \begin and \end commands; see the standard LATEX tutorials
for more about this.
If you wish to have a particular font associated with a specific script or
language, see section 9.3 on page 32. You may need to do this if, for instance,
the main font you are using in a document does not support Greek or Hebrew
and you need to use those languages in your document.
Appendix B provides a summary of the most common fontspec commands.
For more examples, see the short code sample in Appendix C. is sample is
designed to help you learn to control fonts and OT features, not to demon-
strate many general features of LATEX (there are other places to look for that!).
Remember that the % aracter sets off commented from the actual com-
mands, and I have included comments to help you undestand what ea line
does. You can copy this code, paste it into TeXworks, and typeset it on your
own system (ange the Linux Libertine font if you don’t have it, or get it
from http://linuxlibertine.sourceforge.net/. It’s freely available and
despite its name works on Windows or Mac as well as Linux. Appendix D
lists some other freely available fonts that contain OT features for you to ex-
periment with (not all the fonts contain exactly the same features, so e the
documentation that comes with ea). Also be aware that a TrueType font can
contain OT features; e the information provided by the font maker if you
are unsure.¹¹ You can also run the XƎTEX macro opentype-info.tex on a font
and get a file listing the OT features present in the font.¹²
¹¹Fonts that have the .otl extension may contain outlines in the Compact Font Format (CFF), an
update of the older Postscript Type 1 format, or they may contain TrueType outlines. Windows recog-
nizes TrueType fonts that have a digital signature as OpenType, whether or not they contain advanced
typographical features. TrueType fonts without the digital signature but with advanced features still
get the extension .ttf.
¹²Use aat-info.tex for AAT fonts on Mac OS X.
26
ea bit of text in Arial to be a couple of points smaller. fontspec can handle
that for you. Some typefaces come in a number of different weights in addi-
tion to the regular and boldface: light, book, demi, heavy, bla and so forth.
You can tell fontspec to use the demi version as the “boldface” when the light
version is the main font; in other words, you can define your own font fam-
ilies. You may not need to do this oen, but when you need it, this ability is
very helpful.
Have fun!
27
8 Appendix A: Fontspec and OpenType Features
• the lehand column is the fontspec feature name (given in the same
order as in the fontspec documentation)
• the second column, FS Feature Options, shows the tags used to turn
various options on and off. e names are case-sensitive, i.e., OldStyle
works but Oldstyle does not.
• these tags work with either the \fontspec or the \addfontfeatures com-
mand, e.g.:
\fontspec[Letters=SmallCaps]{MinionPro} or
\addfontfeatures{Ligatures=Discretionary,Historical}
• the OpenType Name and the four-leer OpenType tag are provided for
those who have some familiarity with OT features outside of fontspec
and want to mat the names they know with those used by fontspec.
For example, if you have used Adobe InDesign or read the official OT
specification, you are familiar with Tabular Figures, not Monospaced.
• the righthand column indicates features that should be turned on by de-
fault with a double asterisk. Not all applications (including Microso’s
own Office suite) follow this part of the OT spec, at least not completely.
• this table omits OT features that are applicable only to Arabic, East
Asian languages, etc.
• note that “Alternate” is an option within the Contextuals, Fractions, and
Style features and is also the name of a separate feature. See the notes
below for clarification.
(e table begins on the next page and continues onto page 30.)
28
4 ?
¹³If you have an OT font that comes with different optical size versions, XƎTEXwill automatically
select the appropriate one based on the font size specified in the document, so this command is nor-
mally not used. You can adjust optical size if desired with the OpticalSize command or turn it off with
OpticalSize=0.
¹⁴All the above are turned off by prefixing the FS option with No, e.g., NoWordFinal.
29
4 ?
VerticalPosition Inferior Subscript subs
Superior Superscript sups
Ordinal Ordinals ordn
ScientificInferior Scientific Inferiors sinf
Numerator Numerators numr
Denominator Denominators dnom
¹⁵Both the Variant and Alternate options are selected numerically; Variant=1, Alternate=2, etc.; the
first alternate is numbered 0. See your font’s documentation for information about the stylistic sets
and stylistic alternates it supports.
¹⁶Simply turning on Style=Alternate will select the first variant, if more than one is defined in salt.
To access other stylistic alternates, use Alternate= (see above).
30
9 Appendix B: fontspec Command Summary
is is meant as a “eat sheet” that you can keep handy while working. You
may need to study the examples in fontspec.pdf to see how these options re-
ally work. A few of the rarer fontspec commands are not listed here. Re-
member that all fontspec commands are case-sensitive. So BoldItalic works but
Bolditalic will generate all sorts of error messages.
Note that there is a difference between the way most font commands are
invoked versus \defaultfontfeatures and \addfontfeatures. In most cases the
features come first inside square braets, followed by a font name in curly
braets. With these two commands there are never any square braets, and
the features are in curly braets.
\addfontfeatures overrides features called by \fontspec, whi itself re-
places features called by \defaultfontfeatures.
31
\newfontfamily\name[ ]{ }
is command sets a font family that can be reused later in the document.
\newfontface\name[ ]{ }
is command is similar to the above, but is used for fonts that do not
belong to a family, as with some decorative and symbol fonts; automatic se-
lection of bold and italic is not available and presumably not required.
Don’t use \newfontfamily and \newfontface unless you need to reuse the
commands multiple times; for an occasional font ange, just use \fontspec.
Note that you must supply your own name for these two commands, shown
above as \name between the command and the square braets for options. So
this command:
\newfontface\cal[Contextuals=Swash]{Flourishy Font}
would allow you to swit to your favorite calligraphic font (hence the short-
hand name \cal) with contextual swashes turned on simply by typing \cal.
BoldFont
ItalicFont
SmallCapsFont
ese three features allow you to create your own font families. is is
particularly useful if you are using a family that has more than the standard
four weights. For example, if you set text in Art Deco Light, you could au-
tomatically use the Demi version as the ”boldface” by giving the following
command:
\fontspec\[BoldFont={Art Deco Demi}]{Art Deco Light}
32
If you have an older set of fonts whi provides small caps in a separate font
file, you can get the small caps to be applied automatically with this command:
\fontspec[SmallCapsFont={Art Deco Small Caps}]{Art Deco}
ExternalLocation
You can use a font located anywhere on your system, not just in Win-
dows’s \Fonts folder. However, automatic selection of bold and italic does not
work with external fonts, but you can associate them manually by using the
commands given above. Here is an example:
\fontspec[ExternalLocation=\Type Outlines\TrueType]{gara.ttf}
Scale
If you have ever mixed, e.g., Times New Roman and Arial in a document,
you noticed that the portions in Arial seemed too big even though the same
point size was used for both. e Scale command can handle this for you. It
scales the font being called relative to the default roman font. You can specify
an exact percentage for scaling, but usually it’s easier to let fontspec adjust it
for you as follows:
\newfontfamily[Scale=MatchLowercase]{Arial}
is scales Arial to mat the lowercase aracters in Times. If your text is all
uppercase, you can use MatchUppercase instead. is feature is particularly
useful if you put it in your preamble when defining the default sans-serif and
monspaced fonts, whi will then work well with the default roman.
LetterSpace
Use this command if you want more spacing between leers than is built
into the font, as is commonly done when headings are set in all capitals. (Note
that some OpenType fonts can use the Kerning feature with the Uppercase
option to handle this also.) e value of 0.0 is the font’s default spacing, while
a value of 1.0 adds one-tenth of the font’s point size to the traing. So this
command:
\addfontfeature{LetterSpace=1.0}
will add 0.12 points between words if a 12 point font is in effect.
33
9.5 Font-Dependent Features
ese features are tabulated in Appendix A, so they are not repeated here.
ey will not work unless the font contains the appropriate feature tables.
34
10 Appendix C: Some Sample Code
10.1 A Basic Document
TO BE WRITEN
35
10.2 A Multilingual Sample
Download the zip file containing the sample code. Study the file short mul-
tilingual sample.tex, whi includes some explanatory comments to help you
see what is happening. If you typeset this file, you should see the following as
your output if you have the Linux Libertine, DejaVu Sans, and DejaVu Sans
Mono fonts on your system. If you don’t have them and don’t wish to install
them, you will need to edit the font definitions in the preamble.
Polytonic Greek
e default language of this document is American English. To get some text
in ancient Greek with hyphenation and numerals enabled, we put it inside an
environment. So this code:
\begin{greek}
Ἡροδότου Ἁλικαρνησσέος ἱστορίης ἀπόδεξις ἥδε, ὡς μήτε τὰ γενόμενα
ἐξ ἀνθρώπων τῷ χρόνῳ ἐξίτηλα γένηται, μήτε ἔργα μεγάλα τε καὶ
θωμαστά, τὰ μὲν Ἕλλησι τὰ δὲ βαρβάροισι ἀποδεχθέντα, ἀκλεᾶ γένηται,
τά τε ἄλλα καὶ δι᾽ ἣν αἰτίην ἐπολέμησαν ἀλλήλοισι.
\medskip
24 = \greeknumber{24}, 1836 = \Greeknumber{1836}
1 5 10 50 100
\atticnumeral{5 10 50 100}
\end{greek}
Latin
o usque tandem abutere, Catilina, patientia nostra? quam diu etiam furor
iste tuus nos eludet? quem ad finem sese effrenata iactabit audacia? nihilne te
nocturnum praesidium Palati, nihil urbis vigiliae, nihil timor populi, nihil con-
cursus bonorum omnium, nihil hic munitissimus habendi senatus locus, nihil
horum ora voltusque moverunt? patere tua consilia non sentis, constrictam
iam horum omnium scientia teneri coniurationem tuam non vides? quid pro-
xima, quid superiore nocte egeris, ubi fueris, quos convocaveris, quid consili
ceperis quem nostrum ignorare arbitraris? O tempora, o mores! senatus haec
36
intellegit, consul videt; hic tamen vivit. vivit? immo vero etiam in senatum
venit, fit publici consili particeps, notat et designat oculis ad caedem unum
quemque nostrum. nos autem fortes viri satis facere rei publicae videmur, si
istius furorem ac tela vitamus. ad mortem te, Catilina, duci iussu consulis iam
pridem oportebat, in te conferri pestem quam tu in nos omnis iam diu mai-
naris.
Hebrew
א בְּרֵאשִׁית בָּרָא אֱלֹהִים אֵת הַשָּׁמַיִם וְאֵת הָאָרֶץ׃ ב וְהָאָרֶץ הָיְתָה תֹהוּ וָבֹהוּ וְחֹשֶׁךְ עַל־פְּנֵי
תְהֹום וְרוּחַ אֱלֹהִים מְרַחֶפֶת עַל־פְּנֵי הַמָּיִם׃ ג וַיֹּאמֶר אֱלֹהִים יְהִי אֹור וַיְהִי־אֹור׃ ד וַיַּרְא אֱלֹהִים
אֶת־הָאֹור כִּי־טֹוב וַיַּבְדֵּל אֱלֹהִים בֵּין הָאֹור וּבֵין הַחֹשֶׁךְ׃ ה וַיִּקְרָא אֱלֹהִים לָאֹור יֹום וְלַחֹשֶׁךְ קָרָא
לָיְלָה וַיְהִי־עֶרֶב וַיְהִי־בֹקֶר יֹום אֶחָד׃ פ ו וַיֹּאמֶר אֱלֹהִים יְהִי רָקִיעַ בְּתֹוךְ הַמָּיִם וִיהִי מַבְדִּיל בֵּין
מַיִם לָמָיִם׃ ז וַיַּעַשׂ אֱלֹהִים אֶת־הָרָקִיעַ וַיַּבְדֵּל בֵּין הַמַּיִם אֲשֶׁר מִתַּחַת לָרָקִיעַ וּבֵין הַמַּיִם אֲשֶׁר
מֵעַל לָרָקִיעַ וַיְהִי־כֵן׃ ח
Old Italic
SAMPLE AND DISCUSSION GO HERE
37
11 Appendix D: Fonts with OpenType Features
Now that you know how to use OpenType features, you will want to experi-
ment. is table includes information about freely available fonts to try. ere
are of course commercial fonts, particularly those from Adobe.
38
Junicode Designed for medievalists, Junicode contains a large ar-
acter repertoire and can be used for many languages. It also
handles combining marks well and contains many OT fea-
tures. e bold and italic contain fewer aracters than the
roman.
http://junicode.sourceforge.net/
Linux Libertine Despite its name, this font runs on Windows and Mac OS
just fine. It is a Renaissance-style face in four weights with
many OT features. Linux Biolinum, a sans-serif face, is
under development. See
http://linuxlibertine.sourceforge.net/
TeX Gyre TeX Gyre is a project to update and extend the fonts dis-
tributed with the open-source Ghostscript page description
language. It includes a number of fonts, ea in OpenType
and Type 1 formats. e OT versions contain many fea-
tures for advanced typography, all of whi are identified
in the documentation. Except as noted, all families include
four fonts. e families released so far are:
Adventor: a sans-serif face similar to Avant Garde Gothic
Bonum: a serif face similar to Bookman Old Style
Chorus: an italic-only face similar to Zaph Chancery
Cursor: a monospaced font similar to Courier
Heros: a sans-serif face similar to Helvetica; both standard
and condensed versions of ea font included (8 fonts)
Pagella: a serif face similar to Palatino
Sola: a serif face similar to Century Soolbook
Termes: a serif font similar to Times
http://www.gust.org.pl/projects/e-foundry/
tex-gyre/
39
12 Appendix E: Some Traditional TEX Keystrokes
See page 18 for baground on these keystrokes.
40
Change Log
version 1.4 June 20, 2009 section on RTL text rewrien and ex-
panded, based on recent testing and
emails (now complete); section on cre-
ating multilingual text expanded and
improved, with examples and info on
xunicode; Appendix E (traditional TEX
keystrokes) added
version 1.3 May 24, 2009 discussion of the different forms of font
controls (end of §7.1) added; discussion
of \newfontfamily and \newfontface clar-
ified; miscellaneous typos fixed and some
formaing improvements
version 1.2 May 18, 2009 sections on fontspec and polyglossia sig-
nificantly enlarged and improved; infor-
mation on hyphenation added; note to
Mac and Linux users added; sample code
added; miscellaneous improvements
version 1.0 May 10, 2009 initial release
41