\chapter{Changing the appearance}\label{sec:appearance}

This chapter is not part of the introduction, but people who are
particular about the looks of their documents can find here some
tips to modify the appearance of a document globally. These tips use
only preamble commands, staying within the spirit of \LaTeX.

\section{Empty lines instead of paragraph indentation}
\label{sec:parskip}

Use the \texttt{parskip} package. Add the following line to the preamble:
\begin{verbatim}
\usepackage{parskip}
\end{verbatim}
The left sample below is typeset without, the right one with this package:
\exa
\includegraphics[width=\linewidth]{../samples/par_indent}
\exb
\includegraphics[width=\linewidth]{../samples/par_parskip}
\exc
\nextblock
This also takes care of vertical spacing of \texttt{itemize}- and
\texttt{enumerate} environments. This is still just a quick hack;
for a professional result all measurements should be harmonized.

\section{Double-spacing}

This looks ugly, but is often demanded for draft printouts. A line
\begin{verbatim}
\usepackage[doublespacing]{setspace}
\end{verbatim}
or, less radically
\begin{verbatim}
\usepackage[onehalfspacing]{setspace}
\end{verbatim}
in the preamble will do the trick.

\section{Display math alignment}

A documentclass option \texttt{fleqn}:
\begin{verbatim}
\documentclass[fleqn]{article}
\end{verbatim}
ensures that displayed equations are not centered but left-aligned,
with a fixed indentation from the left. The left sample below has
the default centered alignment of equations. The right one has the
option applied and has left-aligned equations:
\exa
\includegraphics[width=\linewidth]{../samples/math_deflt}
\exb
\includegraphics[width=\linewidth]{../samples/math_fleqn}
\exc

\section{Page dimensions}

\begin{verbatim}
\usepackage[textwidth=10cm,textheight=17cm]{geometry}
\end{verbatim}
There are a lot of options, also for page headers and -footers, and
for an asymmetric layout. Again, search the documentation list (see
\ref{sec:doclist}).

\section{Font size}
\label{sec:fontsize}

For a slightly larger font, use the \texttt{11pt}- or \texttt{12pt}
document class option:
\begin{verbatim}
\documentclass[12pt]{article}
\end{verbatim}
The default is \texttt{10pt}. This only works for these predefined
sizes. The \path{ext}- classes and the \package{extsizes} package
provide a few more sizes. Except for these options, changing font
sizes globally involves a fair amount of coding.

\section{Fonts}
\label{sec:fonts}

Several packages change the font for the entire document. However,
good math fonts are in short supply, so choices are limited if you
want matching math typesetting. Check out the \citetitle{fontcat} or
search for `font' in the \citetitle{ctancat}. The typeset samples
below have the required preamble commands on the left. Palatino:
\exa
\begin{verbatim}
\usepackage[TS1,T1]{fontenc}
\usepackage{amsmath}
\usepackage{newpxtext,newpxmath}
\end{verbatim}
\exb
\null\hspace{-3cm}\hfill
\includegraphics[height=5\baselineskip]{../samples/font_newpx}
\exc
\nextblock
The Bitstream Charter-based font setup of a previous edition of these notes:
\exa
\begin{verbatim}
\usepackage{amsmath}
\usepackage[charter]{mathdesign}
\end{verbatim}
\exb
\null\hspace{-3cm}\hfill
\includegraphics[height=5\baselineskip]{../samples/font_md}
\exc

\subsection{System fonts with \XeLaTeX{} and \LuaLaTeX}
\label{sec:systemfonts}

The \XeTeX- and \LuaTeX{} \TeX{} engines support system fonts,
including non-latin scripts and modern Unicode-based OpenType
fonts. This requires the \package{fontspec}
package.%\enlargethispage*{30pt}

Both expect Unicode input, although the usual \TeX{} notations,
(\emph{e.g.}, \verb|\"e| for \"e and \verb|` '| for quotes) are
also valid. Do \emph{not} use the \package{inputenc} package.

\textit{\XeTeX} was originally developed to gain access to Mac OS
system fonts. Later, it was ported to Linux and Windows.

\textit{\LuaTeX} has wider ambitions\footnote{In
  section~\ref{sec:import}, we already encountered its ability to
  read OpenOffice spreadsheets.}, but what matters here is that it
has adopted \XeTeX's support for system fonts and OpenType fonts.

In many cases you can switch between lualatex and xelatex without
changing your \LaTeX{} sources.

Both are available in \TS{} via the \menupath{Tools / Commands}
menu, but you can also set one of these as the default via
\menupath{Options / Configure TeXstudio... / Build / Default
  Compiler}.

\subsubsection{Warning}

The \package{fontspec} package needs information about the fonts
that it is going to load. \XeLaTeX{} and \LuaLaTeX{} each have their
own font database. If they compile a document which uses
\package{fontspec} and they fail to find the information that they
need, then they will create or update the font database. This can
take a \emph{long} time.

So please think twice before using \package{fontspec} on a
university workstation while in class!

\subsubsection{Cambria}

The Cambria font family is especially useful since it contains a
full set of mathematical symbols. It is present on most Windows
systems and is bundled with, \emph{e.g.}, the free PowerPoint viewer:

\exa
\begin{verbatim}
\usepackage{amsmath}
\usepackage{fontspec}
\usepackage{unicode-math}
\setmainfont{Cambria}
\setmathfont{Cambria Math}
\end{verbatim}
\exb
\null\hspace{-3cm}\hfill
\includegraphics[height=5\baselineskip]{../samples/font_cambria}
\exc

\subsubsection{Some standard Windows fonts}

For less serious applications, you may want to typeset a single
passage in a decorative font. If the \package{fontspec} package is
loaded, you can change midway to another font with the
\cmd{fontspec} \emph{command}:

\exa
\begin{verbatim}
\usepackage{fontspec}
...
Temporarily switch to {%
\fontspec[Mapping=tex-text]{Comic Sans MS}
Comic Sans MS} and to {%
\fontspec[Mapping=tex-text]{Tahoma}
Tahoma} and back.
\end{verbatim}
\exb
\includegraphics[width=\linewidth]{../samples/font_w32}
\exc

\subsection{OpenType fonts in \TL{} and \MK}

\TL{} and \MK{} contain several OpenType fonts, which can be used
with \XeLaTeX{} and \LuaLaTeX. If these are not also available as system
fonts then selecting them can be a bit tricky, especially with
\XeLaTeX. The safe solution is to specify them with the full
filename, including extension but excluding the directory:

\exa
\begin{verbatim}
\usepackage{amsmath}
\usepackage{fontspec}
\usepackage{unicode-math}
% a fail-safe way of specifying TL fonts
\setmainfont[
  Ligatures=TeX,
  BoldFont=texgyretermes-bold.otf,
  ItalicFont=texgyretermes-italic.otf,
  BoldItalicFont=texgyretermes-bolditalic.otf]%
{texgyretermes-regular.otf}
\setmathfont[
 math-style=ISO,bold-style=ISO,vargreek-shape=TeX]%
{texgyretermes-math.otf}
\end{verbatim}
\exb
\null\hspace{-3cm}\hfill
\includegraphics[height=5\baselineskip]{../samples/font_tgmath}
\exc
\nextblock
This way, \LaTeX{} can find the font files by the same method as all its
other files.
