%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Contents: Chapter on XeLaTeX
%
% This file is an addendum to lshort-english.
% You will need the lshort-english source version 4.31
% to process this file.
% Add \input{specxetex} to spec.tex just in front of the
% \section{Creating Presentations}.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newpage
\section{Working with \hologo{XeLaTeX}}
\label{sec:xetex}\index{PDF}

\secby{Axel Kielhorn}{A.Kielhorn@web.de}%
Most of the things said about pdf\LaTeX\ are valid for \hologo{XeLaTeX} as well.

There is a Wiki at \url{http://wiki.xelatex.org/doku.php} that collects information relevant to \hologo{XeTeX} and \hologo{XeLaTeX}. 

\subsection{The Fonts}

In addition to the normal \texttt{tfm} based fonts, \hologo{XeLaTeX} is able to use any font known to the operating system. If you have the \texttt{Linux Libertine} fonts installed, you can simply say

\begin{code}
\begin{verbatim}
\usepackage{fontspec}
\setmainfont[Ligatures=TeX]{Linux Libertine}
\end{verbatim}
\end{code}
%
in the preamble. This will normally detect the italic and bold version as well, thus \verb|\textit| and \verb|\textbf| will work as usual. When the font is using OpenType technology you have access to many features which required switching to a separate font or using virtual fonts in the past.
The main feature is the extended character set; a font may contain Latin, Greek and Cyrillic characters and the corresponding ligatures.

Many fonts contain at least two kinds of numerals, the normal lining numerals and so called old style (or lower case) numerals, which partly extend below the baseline. They may contain proportional numerals (the ``1'' takes less space than the ``0'') or monospaced numerals which are suitable for tables.

\begin{code}
\begin{verbatim}
\newfontfamily\LLln[Numbers=Lining]{(font)}
\newfontfamily\LLos[Numbers=OldStyle]{(font)}
\newfontfamily\LLlnm[Numbers=Lining,Numbers=Monospaced]{(font)}
\newfontfamily\LLosm[Numbers=OldStyle,Numbers=Monospaced]{(font)}
\end{verbatim}
\end{code}

Almost all OpenType fonts contain the standard ligatures (fl fi ffi) but there are also some rare or historical ligatures like st, ct and tz. You may not want to use them in a technical report but they are fine for a novel. To enable these ligatures use either of the following lines:

\begin{code}
\begin{verbatim}
\setmainfont[Ligatures=Rare]{(font)}
\setmainfont[Ligatures=Historic]{(font)}
\setmainfont[Ligatures=Historic,Ligature=Rare]{(font)}
\end{verbatim}
\end{code}

Not every font contains both sets of ligature, consult the font documentation or just try it out. Sometimes these ligatures are language dependent, a ligature used in Polish (fk) is not used in English. You have to add

\begin{code}
\begin{verbatim}
\setmainfont[Language=Polish]{(font)}
\end{verbatim}
\end{code}
%
to enable the Polish ligatures.

To learn about fonts in \hologo{XeLaTeX} read the \pai{fontspec} manual.

\subsubsection{Where do I get OpenType fonts?}

If you have \texttt{TeXLive} installed, you already have some at:
\url{.../texmf-dist/fonts/opentype}
just install them in you operating system. This collection does not include \texttt{DejaVu}, which is available at \url{http://dejavu-fonts.org/}.

Make sure that each font is only installed \emph{once}, otherwise interesting results may happen.

\subsubsection{Entering Unicode Characters}

The number of characters in a font has grown but the number of keys on a regular keyboard has not. So, how do I enter non-ASCII characters?

If you write a large amount of text in a foreign language, you can install a keyboard for that language and print out the character positions. (Most operating system have some sort of virtual keyboard, just make a screenshot.) You can even redefine your keyboard layout and make some characters available for direct entry. There is usually some space in the \texttt{option} and \texttt{shift-option} area. 

If you rarely need an exotic character, you can simply pick it in the character palette.

Some editors (those with a Unix background) support digraphs, two letters that are combined into on character.
In \wi{Vim} \texttt{ctrl-k o:} will be transformed into an \"o, \texttt{ctrl-k JA} will created the mirrored R used by a russian toy store chain.

When you know the Unicode position, you can enter the character with \texttt{ctrl-v u<unicodevalue>} in Vim or with \texttt{ctrl-q <unicodevalue>} in emacs.

\subsection{Compatibility Between \hologo{XeLaTeX} and pdf\LaTeX{}}

There are a few things that are different between \hologo{XeLaTeX} and pdf\LaTeX.

\begin{itemize}
\item
A \hologo{XeLaTeX} document has to be written in Unicode (UTF-8) while pdf\LaTeX\ may use different input encodings.
\item
The \pai{microtype} packages does not work with \hologo{XeLaTeX} yet, support for character protrusion is already under development.
\item
Everything font related has to be reviewed. (Unless you want to stick to Latin Modern.)
\end{itemize}

\newpage



