LaTeX

# Introduction

## What is TeX?

TeX is a language created by Donald Knuth to typeset documents attractively and consistently. Knuth started writing the TeX typesetting engine in 1977 to explore the potential of the digital printing equipment that was beginning to infiltrate the publishing industry at that time, in the hope that he could reverse the trend of deteriorating typographical quality that he saw affecting his own books and articles. While TeX is a programming language in the sense that it is Turing complete, its main job is to serve as a markup language for describing how your document should look. The fine control TeX offers over document structure and formatting makes it a powerful and formidable tool. TeX is renowned for being extremely stable, for running on many different kinds of computers, and for being virtually bug free. The version numbers of TeX are converging toward the mathematical constant $\pi$ , with the current version number being 3.1415926.

The name TeX is intended by its developer to be /'tɛx/, /x/ being the velar fricative, the final consonant of loch and Bach. (Donald E. Knuth, The TeXbook) The letters of the name are meant to represent the capital Greek letters tau, epsilon, and chi, as TeX is an abbreviation of τέχνη (ΤΕΧΝΗ – technē), Greek for both "art" and "craft", which is also the root word of technical. English speakers often pronounce it /'tɛk/, like the first syllable of technical.

The tools TeX offers "out of the box" are relatively primitive, and learning how to perform common tasks can require a significant time investment. Fortunately, document preparation systems based on TeX, consisting of collections of pre-built commands and macros, do exist. These systems save time by automating certain repetitive tasks; however, this convenience comes at the cost of complete design flexibility. One of the most popular macro packages is called LaTeX.

## What is LaTeX?

LaTeX (pronounced either "Lah-tech" or "Lay-tech") is a set of macros for TeX created by Leslie Lamport. Its purpose is to simplify TeX typesetting, especially for documents containing mathematical formulae. Within the typesetting system, its name is formatted as LaTeX.

TeX is both a typographical and a logical markup language, and one has to take account of both issues when writing a TeX document. On the other hand, Lamport's aim when creating LaTeX was to split those two aspects. A typesetter can make a template and then the writers can just focus on LaTeX logical markup. They might not know anything about typesetting.

In addition to the commands and options LaTeX offers, many other authors have contributed extensions, called packages or styles, which you can use for your documents. Many of these are bundled with most TeX/LaTeX software distributions; more can be found in the Comprehensive TeX Archive Network (CTAN).

## Why should I use LaTeX?

Most readers will be familiar with WYSIWYG (What You See Is What You Get) typesetting systems such as LibreOffice Writer, Microsoft Word, or Google Docs. Using LaTeX is fundamentally different from using these other programs—instead of seeing your document as it comes together, you describe how you want it to look using commands in a text file, then run that file through the LaTeX program to build the result. While this has the disadvantage of needing to pause your work and take multiple steps to see what your document looks like, there are many advantages to using LaTeX:

• You can concentrate purely on the structure and contents of the document. LaTeX will automatically ensure that the typography of your document—fonts, text sizes, line heights, and other layout considerations—are consistent according to the rules you set.
• In LaTeX, the document structure is visible to the user, and can be easily copied to another document. In WYSIWYG applications it is often not obvious how a certain formatting was produced, and it might be impossible to copy it directly for use in another document.
• Indexes, footnotes, citations and references are generated easily and automatically.
• Mathematical formulae can be easily typeset. (Quality mathematics was one of the original motivations of TeX.)
• Since the document source is plain text,
• Document sources can be read and understood with any text editor, unlike the complex binary and XML formats used with WYSIWYG programs.
• Tables, figures, equations, etc. can be generated programmatically with any language.
• Changes can be easily tracked with version control software.
• Some academic journals only accept or strongly recommend submissions in the form of LaTeX documents. Publishers offer LaTeX templates.

When the source file is processed by the LaTeX program, or engine, it can produce documents in several formats. LaTeX natively supports DVI and PDF, but by using other software you can easily create PostScript, PNG, JPEG, etc.

## Terms regarding TeX

Document preparation systems

LaTeX is a document preparation system based on TeX. So the system is the combination of the language and the macros.

Distributions

TeX distributions are collections of packages and programs (compilers, fonts, and macro packages) that enable you to typeset without having to manually fetch files and configure things.

Engines

An engine is an executable that can turn your source code into a printable output format. The engine by itself only handles the syntax. It also needs to load fonts and macros to fully understand the source code and generate output properly. The engine will determine what kind of source code it can read, and what format it can output (usually DVI or PDF).

All in all, distributions are an easy way to install what you need to use the engines and the systems you want. Distributions usually target specific operating systems. You can use different systems on different engines, but sometimes there are restrictions. Code written for TeX, LaTeX or ConTeXt are (mostly) not compatible. Additionally, engine-specific code (like font for XeTeX) may not be compiled by every engine.

When searching for information on LaTeX, you might also stumble upon XeTeX, ConTeXt, LuaTeX or other names with a -TeX suffix. Let's recap most of the terms in this table.

Systems Descriptions
AMSTeX A legacy TeX macro-based document preparation system used by the American Mathematical Society (AMS) from 1982 to 1985. It evolved into the AMS-LaTeX collection which includes the amsmath package used in nearly every LaTeX document as well as mutliple AMS publication layout standards (document classes).
ConTeXt A TeX macro-based document preparation system designed by Hans Hagen and Ton Otten of Pragma ADE in the Netherlands around 1991. It is compatible with the pdfTeX, XeTeX and LuaTeX engines.

ConTeXt assumes the content author (writer of the document’s text) and the style author (designer of the document’s layout and appearance) are the same. It has a consistent and easy to understand syntax that provides the author with the tools and freedom necessary to produce a document with any desired layout. In cases where there are no standards to follow, ConTeXt provides creative freedom at the expense of required additional effort. ConTeXt excels at producing high-quality works with creative flair, such as textbooks and literature with artistically distinctive layouts.

LaTeX A TeX macro-based document preparation system designed by Leslie Lamport.

LaTeX assumes the content author and style author are different people. This allows authors (researchers, students, etc.) to concentrate on content and forget about design while allowing publishers (journals, graduate departments, etc.) to enforce institutional standards. Separation of content and design comes with the costs of package management, a less consistent syntax, and added complexity (compared to ConTeXt) if an author wishes to deviate from the layout designer's specification (documentclass). LaTeX excels at producing high-quality academic documents that conform to publication requirements, such as journal articles and theses.

MetaFont A high-quality font system designed by Donald Knuth along with TeX.
MetaPost A descriptive vector graphics language based on MetaFont.
TeX The original language designed by Donald Knuth.
Texinfo A TeX macro-based document preparation system designed by Richard Stallman that specializes in producing technical documentation (software manuals).
Engines Descriptions
xetex, xelatex a TeX engine which supports Unicode input and .ttf and .otf fonts. See Fonts.
luatex, lualatex A TeX engine with embedded Lua support, aiming at making TeX internals more flexible. Like XeTeX, supports Unicode input and modern font files.
pdftex, pdflatex Generates PDF output.
tex, latex The "original" TeX engine. Generates DVI output.
TeX Distributions Descriptions
MacTeX A TeX Live based distribution targetting Mac OS X.
MiKTeX A TeX distribution for Windows.
TeX Live A cross-platform TeX distribution.

## What's next?

In the next chapter we discuss installing LaTeX on your system. Then we will typeset our first LaTeX file.

## Learning more

One of the most frustrating things beginners and even advanced users might encounter using LaTeX is the difficulty of changing the look of your documents. While WYSIWYG programs make it trivial to change fonts and layouts, LaTeX requires you to learn new commands and packages to do so. Subsequent chapters will cover many common use cases, but know that this book is only scratching the surface.

Coming from a community of typography enthusiasts, most LaTeX packages contain excellent documentation. This should be your first step if you have questions—if a package's manual has not been installed on your machine as part of your TeX distribution, it can be found on CTAN.

Other useful resources include:

# Installation

If this is the first time you are trying out LaTeX, you don't even need to install anything. For quick testing purpose you may just create a user account with an online LaTeX editor such as Overleaf, and continue this tutorial in the next chapter. These websites offer collaborative editing capabilities while allowing you to experiment with LaTeX syntax — without having to bother with installing and configuring a distribution and an editor. When you later feel that you would benefit from having a standalone LaTeX installation, you can return to this chapter and follow the instructions below.

LaTeX is not a program by itself; it is a document preparation system along with a language. Using LaTeX requires a series of tools. Acquiring them manually would result in downloading and installing multiple programs in order to have a suitable computer system that can be used to create LaTeX output, such as PDFs. TeX Distributions help the user in this way, in that it is a single step installation process that provides (almost) everything.

At a minimum, you'll need a TeX distribution, a good text editor and a DVI or PDF viewer. More specifically, the basic requirement is to have a TeX compiler (which is used to generate output files from source), fonts, and the LaTeX macro set. Optional, and recommended installations include an attractive editor to write LaTeX source documents (this is probably where you will spend most of your time), and a bibliographic management program to manage references if you use them a lot.

## Distributions

TeX and LaTeX are available for most computer platforms, since they were programmed to be very portable. They are most commonly installed using a distribution, such as TeX Live, MiKTeX, or MacTeX. TeX distributions are collections of packages and programs (compilers, fonts, and macro packages) that enable you to typeset without having to manually fetch files and configure things. LaTeX is just a set of macro packages built for TeX.

The recommended distributions for each of the major operating systems are:

• TeX Live is a major TeX distribution for *BSD, GNU/Linux, Mac OS X and Windows.
• MiKTeX is a Windows-specific distribution.
• MacTeX is a Mac OS-specific distribution based on TeX Live.

These, however, do not necessarily include an editor. You might be interested in other programs that are not part of the distribution, which will help you in writing and preparing TeX and LaTeX files.

### *BSD and GNU/Linux

In the past, the most common distribution used to be teTeX. As of May 2006 teTeX is no longer actively maintained and its former maintainer Thomas Esser recommended TeX Live as the replacement.[1]

The easy way to get TeX Live is to use the package manager or portage tree coming with your operating system. Usually it comes as several packages, with some of them being essential, other optional. The core TeX Live packages should be around 200-300 MB.

If your *BSD or GNU/Linux distribution does not have the TeX Live packages, you should report a wish to the bug tracking system. In that case you will need to download TeX Live yourself and run the installer by hand.

You may wish to install the content of TeX Live more selectively. See below.

### Mac OS X

Mac OS X users may use MacTeX, a TeX Live-based distribution supporting TeX, LaTeX, AMSTeX, ConTeXt, XeTeX and many other core packages. Download MacTeX.pkg on the MacTeX page, unzip it and follow the instructions. Further information for Mac OS X users can be found on the TeX on Mac OS X Wiki.

Since Mac OS X is also a Unix-based system, TeX Live is naturally available through MacPorts and Fink. Homebrew users should use the official MacTeX installer because of the unique directory structure used by TeX Live. Further information for Mac OS X users can be found on the TeX on Mac OS X Wiki.

### Microsoft Windows

Microsoft Windows users can install MiKTeX onto their computer. It has an easy installer that takes care of setting up the environment and downloading core packages. Both the basic and the complete LaTeX systems are provided, with the distribution offering advanced features such as automatic installation of packages and simple interfaces to modify settings (e.g., default paper sizes).[2]

There is also a port of TeX Live available for Windows. For more, see TeX Live on Windows.

## Custom installation with TeX Live

This section targets users who want fine-grained control over their TeX distribution, like an installation with a minimum of disk space usage. If not needed, the user may feel free to jump to the next section.

Picky users may wish to have more control over their installation. Common distributions might be tedious for the user caring about disk space. In fact, MikTeX and MacTeX and packaged TeX Live features hundreds of LaTeX packages, most of them which you will never use. Most Unix with a package manager will offer TeX Live as a set of several big packages, and you often have to install 300–400 MB for a functional system.

TeX Live features a manual installation with a lot of possible customizations. You can get the network installer at tug.org. This installer allows you to select precisely the packages you want to install. As a result, you may have everything you need for less than 100 MB. TeX Live is then managed through its own package manager, tlmgr. It will let you configure the distributions, install or remove extra packages and so on.

You will need a Unix-based operating system for the following. Mac OS X, GNU/Linux or *BSD are fine. It may work for Windows but the process must be quite different.

TeX Live groups features and packages into different concepts:

• Collections are groups of packages that can always be installed individually, except for the Essential programs and files collection. You can install collections at any time.
• Installation Schemes group collections and packages. Schemes can only be used at installation time. You can select only one scheme at a time.

### Minimal installation

We will give you general guidelines to install a minimal TeX distribution (i.e., only for plain TeX).

1. Download the installer at http://mirror.ctan.org/systems/texlive/tlnet/install-tl-unx.tar.gz and extract it to a temporary folder.
2. Open a terminal in the extracted folder and log in as root.
# umask 022

1. Launch install-tl.
2. Select the minimal scheme (plain only).
3. You may want to change the directory options. For example you may want to hide your personal macro folder which is located at TEXMFHOME. It is ~/texmf by default. Replace it by ~/.texmf to hide it.
4. Now the options:
1. use letter size instead of A4 by default: mostly for users from the USA.
2. allow execution of restricted list of programs via \write18: it is recommended to select it for security reasons. Otherwise it allows the TeX engines to call any external program. You may still configure the list afterwards.
3. create all format files: targetting a minimal disk space, the best choice depends on whether there is only one user on the system, then deselecting it is better, otherwise select it. From the help menu: "If this option is set, format files are created for system-wide use by the installer. Otherwise they will be created automatically when needed. In the latter case format files are stored in user's directory trees and in some cases have to be re-created when new packages are installed."
4. install macro/font doc tree: useful if you are a developer, but very space consuming. Turn it off if you want to save space.
5. install macro/font source tree: same as above.
6. create symlinks to standard directories: symlinks are fine by default, change it if you know what you are doing.
5. Select portable installation if you install the distribution to an optical disc, or any kind of external media. Leave to default for a traditional installation on the system hard drive.

At this point it should display

1 collections out of 85, disk space required: 40 MB


or a similar space usage.

You can now proceed to installation: start installation to hard disk.

Don't forget to add the binaries to your PATH as it's noticed at the end of the installation procedure.

### First test

In a terminal write

$tex '\empty Hello world!\bye'$ pdftex '\empty Hello world!\bye'


You should get a DVI or a PDF file accordingly.

### Configuration

Formerly, TeX distributions used to be configured with the texconfig tool from the teTeX distribution. TeX Live still features this tool, but recommends using its own tool instead: tlmgr. Tlmgr’s functionality completely subsumes texconfig.[1]

List current installation options:

tlmgr option


You can change the install options:

tlmgr option srcfiles 1
tlmgr option docfiles 0
tlmgr paper letter


See the TLMGR(1) man page for more details on its usage. If you did not install the documents as told previously, you can still access the tlmgr man page with

tlmgr help


### Installing LaTeX

Now we have a running plain TeX environment, let's install the base packages for LaTeX.

# tlmgr install latex latex-bin latexconfig latex-fonts


In this case you can omit latexconfig latex-fonts as they are auto-resolved dependencies to LaTeX. Note that tlmgr resolves some dependencies, but not all. You may need to install dependencies manually. Thankfully this is rarely too cumbersome.

Other interesting packages:

# tlmgr install amsmath babel carlisle ec geometry graphics hyperref lm  marvosym oberdiek parskip graphics-def url

 amsmath The essentials for math typesetting. babel Internationalization support. carlisle Bundle package required for some babel features. ec Required for T1 encoding. geometry For page layout. graphics The essentials to import graphics. htlatex Includes TeX4ht used in (LA )TeX to HTML (and XML and more) convertion. hyperref PDF bookmarks, PDF followable links, link style, TOC links, etc. lm One of the best Computer Modern style font available for several font encodings (such as T1). marvosym Several symbols, such as the official euro. oberdiek Bundle package required for some geometry features. parskip Let you configure paragraph breaks and indents properly. graphics-def Required for some graphics features. url Required for some hyperref features.

If you installed a package you do not need anymore, use

# tlmgr remove <package>


### Hyphenation

If you are using Babel for non-English documents, you need to install the hyphenation patterns for every language you are going to use. They are all packaged individually. For instance, use

# tlmgr install hyphen-{finnish,sanskrit}


for finnish and sanskrit hyphenation patterns.

Note that if you have been using another TeX distribution beforehand, you may still have hyphenation cache stored in you home folder. You need to remove it so that the new packages are taken into account. The TeX Live cache is usually stored in the ~/.texliveYYYY folder (YYYY stands for the year). You may safely remove this folder as it contains only generated data. TeX compilers will re-generate the cache accordingly on next compilation.

### Uninstallation

By default TeX Live will install in /usr/local/texlive. The distribution is quite proper as it will not write any file outside its folder, except for the cache (like font cache, hyphenation patters, etc.). By default,

• the system cache goes in /var/lib/texmf;
• the user cache goes in ~/.texliveYYYY.

Therefore TeX Live can be installed and uninstalled safely by removing the aforementioned folders.

Still, TeX Live provides a more convenient way to do this:

# tlmgr uninstall


You may still have to wipe out the folders if you put untracked files in them.

## Editors

TeX and LaTeX source documents (and its related auxiliary files) are all plain-text files, and can be opened and modified in almost any text editor. You should use a text editor (e.g. Notepad), not a word processor (e.g., Microsoft Word, LibreOffice Writer). Dedicated LaTeX editors are more useful than generic plain text editors, because they are usually equipped with the autocomplete feature for commands, spelling and error checking and other handy macros.

Note

Microsoft Word can accept LaTeX through Equation Editor, but it is not a full-fledged LaTeX editor.

### Cross-platform

#### Emacs

Emacs is a general purpose, extensible text processing system. Advanced users can program it (in elisp) to make Emacs the best LaTeX environment that will fit their needs. In turn beginners may prefer to use it in combination with AUCTeX and Reftex (extensions that may be installed into the Emacs program). Depending on the configuration, Emacs can provide a complete LaTeX editing environment with auto-completion, spell-checking, a complete set of keyboard shortcuts, view of table of contents, document preview and many other features.

#### gedit-latex-plugin

Gedit with gedit-latex-plugin is also worth trying out for users of GNOME. GEdit is a cross-platform application for Windows, Mac, and Linux

#### Gummi

Screenshot of Gummi.

Gummi is a LaTeX editor for Linux, which compiles the output of pdflatex in real-time and shows it on the right half of the screen[3].

#### LyX

LyX1.6.3

LyX is a popular document preparation system for Windows, Linux and Mac OS. It provides a graphical interface to LaTeX, including several popular packages. It contains formula and table editors and shows visual clues of the final document on the screen — which enables users to write LaTeX documents without worrying about the actual syntax. LyX calls this a What You See Is What You Mean (WYSIWYM) approach, since the screen only shows the structure and an approximation of the output.[4]

LyX saves a document in its own markup, from which LaTeX code can then be generated. The user is mostly isolated from the LaTeX code and is not in complete control of it, and for that reason LyX is generally not considered as a proper LaTeX editor. However, since it uses LaTeX as its underlying system, knowledge of how LaTeX works can also be useful to a LyX user. In addition, if one wants to implement a feature that is not supported in the GUI, then the use of LaTeX code may be required.

#### TeXmaker

TeXmaker is a cross-platform editor that is very similar to Kile in both features and user interface. It is also equipped with its own PDF viewer as well.

#### TeXstudio

TeXstudio is a cross-platform open source LaTeX editor forked from Texmaker.

#### TeXworks

Screenshot of TeXworks on Ubuntu 12.10.

TeXworks is a dedicated TeX editor that is included in MiKTeX and TeX Live. It was developed with the idea that a simple interface is better than a cluttered one, and thus to make it easier for the beginners of LaTeX to write their own documents. TeXworks originally came about precisely because a math professor wanted his students to have a better initial experience with LaTeX.

You can install TeXworks with the package manager of your Linux distribution or choose it as an install option in the Windows or Mac installer.

#### Vim

Vim is another general purpose text editor for a wide variety of platforms including UNIX, Mac OS X and Windows. A variety of extensions exist including LaTeX Box and Vim-LaTeX.

### *BSD and GNU/Linux-only

#### Kile

Screenshot of Kile.

Kile is a LaTeX editor for KDE (cross platform), providing a powerful GUI for editing multiple documents and compiling them with many different TeX compilers. Kile is based on Kate editor, has a quick access toolbar for symbols, document structure viewer, a console and customizable build options. Kile can be run in all operating systems that can run KDE.

#### GNOME-LaTeX

GNOME-LaTeX is another text editor for Linux (GNOME).

### Mac OS X-only

#### TeXShop

TeXShop, the model for the TeXworks editor and previewer, is for Mac OS and is bundled with the MacTeX distribution. It uses multiple windows, one for editing the source, one for the preview, and one as a console for error messages. It offers one-click updating of the preview and allows easy crossfinding between the code and the preview by using CMD-click along with many features to make editing and typesetting TeX source easier.

#### TeXnicle

TeXnicle is a free editor for Mac OS that includes the ability to perform live updates. It includes a code library for the swift insertion of code and the ability to execute detailed word counts on documents. It also performs code highlighting and the editing window is customisable, permitting the user to select the font, colour, background colour of the editing environment. It is in active development.

#### Archimedes

Archimedes is an easy-to-use LaTeX and Markdown editor designed from the ground up for Mac OS X. It includes a built-in LaTeX library, code completion support, live previews, macro support, integration with sharing services, and PDF and HTML export options. Archimedes's Magic Type feature lets users insert mathematical symbols just by drawing them on their MacBook's trackpad or Magic Trackpad.

Texpad is an integrated editor and viewer for Mac OS with a companion app for iOS devices. Similar to TeXShop, Texpad requires a working MacTeX distribution to function, however it can also support other distributions side-by-side with MacTex. It offers numerous features including templates, outline viewing, auto-completion, spell checking, customizable syntax highlighting, to-do list integration, code snippets, Markdown integration, multi-lingual support, and a Mac OS native user interface. Although Texpad offers a free evaluation period, the unlocked version is a paid download.

### Windows-only

#### TeXnicCenter

TeXnicCenter is a popular free and open source LaTeX editor for Windows. It also has a similar user interface to TeXmaker and Kile.

#### WinEdt

WinEdt is a powerful and versatile text editor with strong predisposition towards creation of LaTeX/TeX documents for Windows. It has been designed and configured to integrate with TeX Systems such as MiTeX or TeX Live. Its built-in macro helps in compiling the LaTeX source to the WYSIWYG-like DVI or PDF or PS and also in exporting the document to other mark-up languages as HTML or XML.

### Online solutions

To get started without needing to install anything, you can use a web-hosted service featuring a full TeX distribution and a web LaTeX editor.

• Authorea is an integrated online framework for the creation of technical documents in collaboration. Authorea's frontend allows one to enter text in LaTeX or Markdown, as well as figures, and equations (in LaTeX or MathML). Authorea's versioning control system is entirely based on Git (as every article is a Git repository).
• CoCalc is a collaborative online workplace for computations, which also offers an editor for LaTeX documents.
• Overleaf is a secure, easy to use online LaTeX editor with integrated rapid preview - like EtherPad for LaTeX. One can start writing by creating a free account, and share the link or add collaborators to the projects before publishing it through their platform. It supports real time preview, Rich Text mode (a partial WYSIWYG mode with math expressions, ordered/unordered lists, sectional titles and figures in rendered form), bibliographies and custom styles. Since July 2017, ShareLaTeX is now part of Overleaf.[5][6]
• Verbosus is a professional online LaTeX Editor that supports collaboration with other users and is free to use. Merge conflicts can easily resolved by using a built-in merge tool that uses an implementation of the diff-algorithm to generate information required for a successful merge.

## Bibliography management

Bibliography files (*.bib) are most easily edited and modified using a management system. These graphical user interfaces all feature a database form, where information is entered for each reference item, and the resulting text file can be used directly by BibTeX.

### Cross-platform

Screenshot of JabRef.

### Mac OS X-only

Screenshot of BibDesk
• BibDesk is a bibliography manager based on a BibTeX file. It imports references from the internet and makes it easy to organize references using tags and categories[7].

## Viewers

Finally, you will need a viewer for the files to view LaTeX outputs. By default, LaTeX saves the final document as a .dvi (Device independent file format), but you will rarely want it to, as DVI files do not contain embedded fonts — not to mention that many document viewers are unable to open them.

In most scenarios, you will use a LaTeX compiler like pdflatex to produce a PDF file directly, or a tool like dvi2pdf to convert the DVI file to PDF format. Then you can view the result with any PDF viewer.

Practically all LaTeX distributions have a DVI viewer for viewing the default output of latex, and also tools such as dvi2pdf for converting the result automatically to PDF and PS formats.

The following is a list of the various PDF viewers available on the web:

## Tables and graphics tools

LaTeX is a document preparation system above all else: it does not aim at being a spreadsheet tool nor a vector graphics tool.

If LaTeX can render beautiful tables in a dynamic and flexible manner, it will not handle the handy features you could get with a spreadsheet like dynamic cells and calculus. Other tools are better at that. The ideal solution is to combine the strength of both tools: build your dynamic table with a spreadsheet, and export it to LaTeX to get a beautiful table seamlessly integrated to your document. See Tables for more details.

The graphics topic is a bit different since it is possible to write procedural graphics from within your LaTeX document. Procedural graphics produce state-of-the-art results that integrates perfectly to LaTeX (e.g. no font change), but have a steep learning curve and require a lot of time to draw.

For easier and quicker drawings, you may want to use a WYSIWYG tool (e.g., Adobe Photoshop, Canva) and export the result to a vector format like PDF. The drawback is that it will contrast in style with the rest of your document (e.g., font, size, color). Some tools have the capability to export to LaTeX, which will partially solve this issue. See Importing Graphics for more details.

## References

3. Gummi
4. LyX
5. ShareLaTeX Joins Overleaf
6. The Definitive, Non-Technical Introduction to LaTeX: Overleaf
7. BibDesk

# Installing Extra Packages

Add-on features for LaTeX are known as packages. Dozens of these are pre-installed with LaTeX and can be used in your documents immediately. They should all be stored in subdirectories of texmf/tex/latex named after each package. The directory name "texmf" stands for “TEX and METAFONT”. To find out what other packages are available and what they do, you should use the CTAN search page which includes a link to Graham Williams' comprehensive package catalogue.

A package is a file or collection of files containing extra LaTeX commands and programming which add new styling features or modify those already existing. There are two main file types: class files with .cls extension, and style files with .sty extension. There may be ancillary files as well. When you try to typeset a document which requires a package which is not installed on your system, LaTeX will warn you with an error message that it is missing. You can download updates to packages you already have (both the ones that were installed along with your version of LaTeX as well as ones you added). There is no limit to the number of packages you can have installed on your computer (apart from disk space!), but there is a configurable limit to the number that can be used inside any one LaTeX document at the same time, although it depends on how big each package is. In practice there is no problem in having even a couple of dozen packages active.

Most LaTeX installations come with a large set of pre-installed style packages, so you can use the package manager of the TeX distribution or the one on your system to manage them. See the automatic installation. But many more are available on the net. The main place to look for style packages on the Internet is CTAN. Once you have identified a package you need that is not in your distribution, use the indexes on any CTAN server to find the package you need and the directory where it can be downloaded from. See the manual installation.

## Automatic installation

If on an operating system with a package manager or a portage tree, you can often find packages in repositories.

With MikTeX there is a package manager that allows you to pick the package you want individually. As a convenient feature, upon the compilation of a file requiring non-installed packages, MikTeX will automatically prompt to install the missing ones.

With TeX Live, it is common to have the distribution packed into a few big packages. For example, to install something related to internationalization, you might have to install a package like texlive-lang. With TeX Live manually installed, use tlmgr to manage packages individually.

tlmgr install <package1> <package2> ...
tlmgr remove <package1> <package2> ...


The use of tlmgr is covered in the Installation chapter.

If you cannot find the wanted package with any of the previous methods, see the manual installation.

### Instructions for specific operating systems

On Ubuntu, with releases such as Trusty, you can use texlive and texlive-extra packages, e.g. texlive-full, texlive-latex-extra, texlive-math-extra, texlive-plain-extra, texlive-bibtex-extra, texlive-generic-extra, and language packages, which are all available here on the Ubuntu packages site, as well as here for Trusty updates. You can install these packages with sudo apt-get install <insert package name here>.

## Manual installation

What you need to look for is usually two files, one ending in .dtx and the other in .ins. The first is a DOCTeX file, which combines the package program and its documentation in a single file. The second is the installation routine (much smaller). You must always download both files. If the two files are not there, it means one of two things:

• Either the package is part of a much larger bundle which you shouldn't normally update unless you change User:Dirk Hünniger/latex version of LaTeX;
• or it's an older or relatively simple package written by an author who did not use a .dtx file.

Download the package files to a temporary directory. There will often be a readme.txt with a brief description of the package. You should of course read this file first.

### Installing a package

There are five steps to installing a LaTeX package. (These steps can also be used on the pieces of a complicated package you wrote yourself; in this case, skip straight to Step 3.)

1. Extract the files Run LaTeX on the .ins file. That is, open the file in your editor and process it as if it were a LaTeX document (which it is), or if you prefer, type latex followed by the .ins filename in a command window in your temporary directory. This will extract all the files needed from the .dtx file (which is why you must have both of them present in the temporary directory). Note down or print the names of the files created if there are a lot of them (read the log file if you want to see their names again).

2. Create the documentation Run LaTeX on the .dtx file. You might need to run it twice or more, to get the cross-references right (just like any other LaTeX document). This will create a .dvi file of documentation explaining what the package is for and how to use it. If you prefer to create PDF then run pdfLaTeX instead. If you created a .idx as well, it means that the document contains an index, too. If you want the index to be created properly, follow the steps in the indexing section. Sometimes you will see that a .glo (glossary) file has been produced. Run the following command instead:

makeindex -s gglo.ist -o name.gls name.glo


3. Install the files While the documentation is printing, move or copy the package files from your temporary directory to the right place[s] in your TeX local installation directory tree. Packages installed by hand should always be placed in your "local" directory tree, not in the directory tree containing all the pre-installed packages. This is done to a) prevent your new package accidentally overwriting files in the main TeX directories; and b) avoid your newly-installed files being overwritten when you next update your version of TeX.

For a TDS(TeX Directory Structure)-conformant system, your "local installation directory tree" is a folder and its subfolders. The outermost folder should probably be called texmf-local/ or texmf/. Its location depends on your system:

• Unix-type systems: Usually ~/texmf/. If you use TexMaker on Ubuntu 18 it may be in /usr/share/texmf/
• MikTeX: Your local directory tree can be any folder you like, as long as you then register it as a user-managed texmf directory (see http://docs.miktex.org/manual/localadditions.html#id573803)

The "right place" sometimes causes confusion, especially if your TeX installation is old or does not conform to the TeX Directory Structure(TDS). For a TDS-conformant system, the "right place" for a LaTeX .sty file is a suitably-named subdirectory of texmf/tex/latex/. "Suitably-named" means sensible and meaningful (and probably short). For a package like paralist, for example, I'd call the directory texmf/tex/latex/paralist.

Often there is just a .sty file to move, but in the case of complex packages there may be more, and they may belong in different locations. For example, new BibTeX packages or font packages will typically have several files to install. This is why it is a good idea to create a sub-directory for the package rather than dump the files into misc along with other unrelated stuff. If there are configuration or other files, read the documentation to find out if there is a special or preferred location to move them to.

Where to put files from packages
Type Directory (under texmf/ or texmf-local/) Description
.afm fonts/afm/foundry/typeface Adobe Font Metrics for Type 1 fonts
.bib bibtex/bib/bibliography BibTeX bibliography
.bst bibtex/bst/packagename BibTeX style
.cls tex/latex/base Document class file
.dvi doc package documentation
.enc fonts/enc Font encoding
.fd tex/latex/mfnfss Font Definition files for METAFONT fonts
.fd tex/latex/psnfss Font Definition files for PostScript Type 1 fonts
.map fonts/map Font mapping files
.mf fonts/source/public/typeface METAFONT outline
.pdf doc package documentation
.pfb fonts/type1/foundry/typeface PostScript Type 1 outline
.sty tex/latex/packagename Style file: the normal package content
.tex doc TeX source for package documentation
.tex tex/plain/packagename Plain TeX macro files
.tfm fonts/tfm/foundry/typeface TeX Font Metrics for METAFONT and Type 1 fonts
.ttf fonts/truetype/foundry/typeface TrueType font
.vf fonts/vf/foundry/typeface TeX virtual fonts
others tex/latex/packagename other types of file unless instructed otherwise

For most fonts on CTAN, the foundry is public.

4. Update your index Finally, run your TeX indexer program to update the package database. This program comes with every modern version of TeX and has various names depending on the LaTeX distribution you use. (Read the documentation that came with your installation to find out which it is, or consult http://www.tug.org/fonts/fontinstall.html#fndb):

• teTeX, TeX Live, fpTeX: texhash
• web2c: mktexlsr
• MacTeX: MacTeX appears to do this for you.
• MikTeX: initexmf --update-fndb (or use the GUI)
• MiKTeX 2.7 or later versions, installed on Windows XP through Windows 7: Start -> All Programs -> MikTex -> Settings. In Windows 8 use the keyword Settings and choose the option of Settings with the MiKTex logo. In Settings menu choose the first tab and click on Refresh FNDB-button (MikTex will then check the Program Files directory and update the list of File Name DataBase). After that just verify by clicking 'OK'.

5. Update font maps If your package installed any TrueType or Type 1 fonts, you need to update the font mapping files in addition to updating the index. Your package author should have included a .map file for the fonts. The map updating program is usually some variant on updmap, depending on your distribution:

• TeX Live and MacTeX: updmap --enable Map=mapfile.map (if you installed the files in a personal tree) or updmap-sys --enable Map=mapfile.map (if you installed the files in a system directory).
• MikTeX: Run initexmf --edit-config-file updmap, add the line "Map mapfile.map to the file that opens, then run initexmf --mkmaps.

The reason this process has not been automated widely is that there are still thousands of installations which do not conform to the TDS, such as old shared Unix systems and some Microsoft Windows systems, so there is no way for an installation program to guess where to put the files: you have to know this. There are also systems where the owner, user, or installer has chosen not to follow the recommended TDS directory structure, or is unable to do so for political or security reasons (such as a shared system where the user cannot write to a protected directory). The reason for having the texmf-local directory (called texmf.local on some systems) is to provide a place for local modifications or personal updates, especially if you are a user on a shared or managed system (Unix, Linux, VMS, Windows NT/2000/XP, etc.) where you may not have write-access to the main TeX installation directory tree. You can also have a personal texmf subdirectory in your own login directory. Your installation must be configured to look in these directories first, however, so that any updates to standard packages will be found there before the superseded copies in the main texmf tree. All modern TeX installations should do this anyway, but if not, you can edit texmf/web2c/texmf.cnf yourself.

## Checking package status

The universal way to check if a file is available to TeX compilers is the command-line tool kpsewhich.

$kpsewhich tikz /usr/local/texlive/2012/texmf-dist/tex/plain/pgf/frontendlayer/tikz.tex  kpsewhich will actually search for files only, not for packages. It returns the path to the file. For more details on a specific package use the command-line tool tlmgr (TeX Live only): tlmgr info <package>  The tlmgr tool has lot more options. To consult the documentation: tlmgr help  ## Package documentation To find out what commands a package provides (and thus how to use it), you need to read the documentation. In the texmf/doc subdirectory of your installation there should be directories full of .dvi files, one for every package installed. This location is distribution-specific, but is typically found in: Distribution Path MacTeX /Library/TeX/Documentation/texmf-doc/latex MiKTeX %MIKTEX_DIR%\doc\latex TeX Live$TEXMFDIST/doc/latex

Generally, most of the packages are in the latex subdirectory, although other packages (such as BibTeX and font packages) are found in other subdirectories in doc. The documentation directories have the same name of the package (e.g. amsmath), which generally have one or more relevant documents in a variety of formats (dvi, txt, pdf, etc.). The documents generally have the same name as the package, but there are exceptions (for example, the documentation for amsmath is found at latex/amsmath/amsdoc.dvi). If your installation procedure has not installed the documentation, the DVI files can all be downloaded from CTAN. Before using a package, you should read the documentation carefully, especially the subsection usually called "User Interface", which describes the commands the package makes available. You cannot just guess and hope it will work: you have to read it and find out.

You can usually automatically open any installed package documentation with the texdoc command:

texdoc <package-name>


## External resources

The best way to look for LaTeX packages is the already mentioned CTAN: Search. Additional resources form The TeX Catalogue Online:

# Basics

This tutorial is aimed at getting familiar with the bare bones of LaTeX.

Before starting, ensure you have LaTeX installed on your computer (see Installation for instructions of what you will need).

• We will first have a look at the LaTeX syntax.
• We will create our first LaTeX document.
• Then we will take you through how to feed this file through the LaTeX system to produce quality output, such as postscript or PDF.
• Finally we will have a look at the file names and types.

## The LaTeX syntax

When using LaTeX, you write a plain text file which describes the document's structure and presentation. LaTeX converts this source text, combined with markup, into a typeset document. For the purpose of analogy, web pages work in a similar way: HTML is used to describe the document, which is then rendered into on-screen output - with different colours, fonts, sizes, etc. - by your browser.

You can create an input file for LaTeX with any text editor. A minimal example looks something like the following (the commands will be explained later):

 \documentclass{article} \begin{document} Hello world! \end{document} 

### Spaces

LaTeX normalises spaces in its input files so that whitespace characters, such as a space or a tab, are treated uniformly as space. Several consecutive spaces are treated as one, space opening a line is generally ignored, and a single line break also yields space. More line breaks (empty lines) define the end of a paragraph. An example of applying these rules is presented below: the left-hand side shows the user's input (.tex), while the right-hand side depicts the rendered output (.dvi, .pdf, .ps).

 It does not matter whether you enter one or several spaces after a word. An empty line starts a new paragraph.  It does not matter whether you enter one or several spaces after a word. An empty line starts a new paragraph.

### Reserved Characters

The following symbols are reserved characters that either have a special meaning under LaTeX or are unavailable in all the fonts. If you enter them directly in your text, they will normally not print but rather make LaTeX do things you did not intend.

# $% ^ & _ { } ~ \  As you will see, these characters can be used in your documents all the same by adding a prefix backslash:  \# \$ \% \^{} \& \_ \{ \} \~{} \textbackslash{} 

In some circumstances, the square bracket characters [ ] can also be considered as reserved characters, as they are used to give optional parameters to some commands. If you want to print these directly after some command, like in this situation: \command [text] it will fail, as [text] will be considered as an option given to \command. You can achieve the correct output this way: \command {} [text].

The backslash character \ cannot be entered by adding another backslash in front of it, like so \\; this sequence is used for line breaking. For introducing a backslash in math mode, you can use \backslash instead.

The commands \~ and \^ produce respectively a tilde and a hat which is placed over the next letter. For example \~n gives ñ. That's why you need braces to specify there is no letter as argument. You can also use \textasciitilde and \textasciicircum to enter these characters; or other commands .

If you want to insert text that might contain several particular symbols (such as URIs), you can consider using the \verb command, which will be discussed later in the section on formatting. For source code, see Source Code Listings

The less-than < and greater-than > characters are the only visible ASCII characters (not reserved) that will not print correctly. See Special Characters for an explanation and a workaround.

Non-ASCII characters (e.g. accents, diacritics) can be typed in directly for most cases. However you must configure the document appropriately. The other symbols and many more can be printed with special commands as in mathematical formulae or as accents. We will tackle this issue in Special Characters.

### LaTeX groups

Sometimes a certain state should be kept local, in other words its scope should be limited. This can be done by enclosing the part to be changed locally in curly braces. In certain occasions, using braces won't be possible. LaTeX provides \bgroup and \egroup to begin and end a group, respectively.

 \documentclass{article} \begin{document} normal text {\itshape walzing \bfseries Wombat} more normal text normal text \bgroup\itshape walzing \bfseries Wombat\egroup{} more normal text \end{document} 

Environments form an implicit group.

### LaTeX environments

Environments in LaTeX have a role that is quite similar to commands, but they usually have effect on a wider part of the document. Their syntax is:

 \begin{environmentname} text to be influenced \end{environmentname} 

Between the \begin and the \end you can put other commands and nested environments. The internal mechanism of environments defines a group, which makes its usage safe (no influence on the other parts of the document). In general, environments can accept arguments as well, but this feature is not commonly used and so it will be discussed in more advanced parts of the document.

Anything in LaTeX can be expressed in terms of commands and environments.

### LaTeX commands

LaTeX commands are case sensitive, and take one of the following two formats:

1. They start with a backslash \ and then have a name consisting of letters only.
• Command names are terminated by a space, a number or any other non-letter.
2. They consist of a backslash \ and exactly one non-letter.
• Command names are terminated after that one non-letter.

Some commands need an argument, which has to be given between curly braces { } after the command name. Some commands support optional parameters, which are added after the command name in square brackets [ ]. The general syntax is:

 \commandname[option1,option2,...]{argument1}{argument2}... 

Many LaTeX formatting commands come in pairs.

1. An argument form command, where one of the arguments is the text to be formatted.
2. A scope form command, where the formatting will be applied to all text after the command until the end of the current scope. That is, until the end of the current group or environment. This form may also be called a switch command. A scope form command might still have arguments, but the text to be formatted is not an argument. This form should almost never be called outside of any scope, otherwise it will apply on the rest of the document.

An argument form command will have one argument more than its corresponding scope form command, the extra argument being the text the command affects.

Examples:

Emphasing text: \emph is an argument form command with one argument, the text to be emphasised. \em is the corresponding scope form command with no arguments.

 \emph{emphasized text}, this part is normal % Correct. {\em emphasized text}, this part is normal % Correct. \emph emphasized text, this part is normal % Incorrect: command without argument. \em{emphasized text}, this part is normal % Incorrect: switch with argument. \em emphasized text, this part is normal % Dangerous: switch outside of any environment. 

Coloring text: This example requires you to \usepackage{xcolor}. \textcolor is an argument form command with two arguments, the color and the text to be colored. \color is the corresponding scope form command with only one argument, the color.

 By default, this text is black. \textcolor{red}{This is red text.} Back to black. By default, this text is black. {\color{red}This is red text.} Back to black. 

When LaTeX encounters a % character while processing an input file, it ignores the rest of the current line, the line break, and all whitespace at the beginning of the next line.

This can be used to write notes into the input file, which will not show up in the printed version.

 This is an % stupid % Better: instructive <---- example: Supercal% ifragilist% icexpialidocious  This is an example: Supercalifragilisticexpialidocious

Note that the % character can be used to split long input lines that do not allow whitespace or line breaks, as with Supercalifragilisticexpialidocious above.

The core LaTeX language does not have a predefined syntax for commenting out regions spanning multiple lines. Refer to multiline comments for simple workarounds.

## Our first document

Now we can create our first document. We will produce the absolute bare minimum that is needed in order to get some output; the well known Hello World! approach will be suitable here.

• Open your favorite text-editor. vim, emacs, Notepad++, and other text editors will have syntax highlighting that will help to write your files.
• Reproduce the following text in your editor. This is the LaTeX source.
 % hello.tex - Our first LaTeX example! \documentclass{article} \begin{document} Hello World! \end{document} 
• Save your file as hello.tex.

When picking a name for your file, make sure it bears a .tex extension.

### What does it all mean?

 % hello.tex - Our first LaTeX example! The first line is a comment. This is because it begins with the percent symbol (%); when LaTeX sees this, it simply ignores the rest of the line. Comments are useful for people to annotate parts of the source file. For example, you could put information about the author and the date, or whatever you wish. \documentclass{article} This line is a command and tells LaTeX to use the article document class. A document class file defines the formatting standard to follow, which in this case is the generic article format. Journals, university departments, etc. can provide these files to ensure publication standards are met. In many instances, the same document content can be reformatted for submission to a different publisher simply by substituting the required document class file. There are numerous generic document classes available to choose from if one is not provided. \begin{document} This line is the beginning of the environment called document; it alerts LaTeX that content of the document is about to commence. Anything above this command is known generally to belong in the preamble. Hello World! This was the only actual line containing real content - the text that we wanted displayed on the page. \end{document} The document environment ends here. It tells LaTeX that the document source is complete, anything after this line will be ignored.

As we have said before, each of the LaTeX commands begins with a backslash (\). This is LaTeX's way of knowing that whenever it sees a backslash, to expect some commands. Comments are not classed as a command, since all they tell LaTeX is to ignore the line. Comments never affect the output of the document, provided there is no white space before the percent sign.

## Building a document

We then feed our input file into a LaTeX engine, a program which generates our final document.

There are several LaTeX engines in modern use: lualatex, xelatex, and pdflatex. There are important differences between the three, but we'll discuss those elsewhere - any of them will work for building our first document.

### Generating the document

LaTeX itself does not have a GUI, though some LaTeX installations feature a graphical front-end where you can click LaTeX into compiling your input file. Assuming you're not using one of those:

1. Open a terminal and navigate to the directory containing your .tex file.
2. Type the command: xelatex hello.tex (The .tex extension is not required, although you can include it if you wish.)
3. Various bits of info about LaTeX and its progress will be displayed. If all went well, the last two lines displayed in the console will be:
Output written on hello.pdf (1 page).
Transcript written on hello.log.


This means that your source file has been processed and the resulting document is called hello.pdf. You can view it with any PDF viewer installed on your system.

In this instance, due to the simplicity of the file, you only need to run the LaTeX command once. However, if you begin to create complex documents, including bibliographies and cross-references, etc., LaTeX needs to be executed multiple times to resolve the references. This will be discussed in the future when it comes up.

### Autobuild Systems

Compiling can be quite tricky as soon as you start working on more complex documents. A number of programs exist to automatically read in a LaTeX document and run the appropriate compilers the appropriate number of times. For example, latexmk can generate a PDF from most LaTeX files simply:


When using \textbf{} inside the alltt enviroment, note that the standard font has no bold TT font. Txtfonts has bold fonts: just add \renewcommand{\ttdefault}{txtt} after \usepackage{alltt}.

If you just want to introduce a short verbatim phrase, you don't need to use the whole environment, but you have the \verb command:

 \verb+my text+ 

The first character following \verb is the delimiter: here we have used "+", but you can use any character you like except *; \verb will print verbatim all the text after it until it finds the next delimiter. For example, the code:

 \verb;\textbf{Hi mate!}; 

will print \textbf{Hi mate!}, ignoring the effect \textbf should have on text.

For more control over formatting, however, you can try the fancyvrb package, which provides a Verbatim environment (note the capital letter) which lets you draw a rule round the verbatim text, change the font size, and even have typographic effects inside the Verbatim environment. It can also be used in conjunction with the fancybox package and it can add reference line numbers (useful for chunks of data or programming), and it can even include entire external files.

To use verbatim in beamer, the frame needs to be made fragile: \begin{frame}[fragile] .

#### Typesetting URLs

One of either the hyperref or url packages provides the \url command, which properly typesets URLs, for example:

 Go to \url{http://www.uni.edu/~myname/best-website-ever.html} for my website. 

will show this URL exactly as typed (similar to the \verb command), but the \url command also performs a hyphenless break at punctuation characters (only in PDFLaTeX, not in plain LaTeX+ dvips). It was designed for Web URLs, so it understands their syntax and will never break midway through an unpunctuated word, only at slashes and full stops. Bear in mind, however, that spaces are forbidden in URLs, so using spaces in \url arguments will fail, as will using other non-URL-valid characters.

When using this command through the hyperref package, the URL is "clickable" in the PDF document, whereas it is not linked to the web when using only the url package. Also when using the hyperref package, to remove the border placed around a URL, insert pdfborder = {0 0 0 0} inside the \hypersetup{}. (Alternately pdfborder = {0 0 0} might work if the four zeroes do not.)

You can put the following code into your preamble to change the style, how URLs are displayed to the normal font:

 \urlstyle{same} 

#### Listing environment

This is also an extension of the verbatim environment provided by the moreverb package. The extra functionality it provides is that it can add line numbers alongside the text. The command is \begin{listing}[step]{first line}. The mandatory first line argument is for specifying which line the numbering should start at. The optional step is the step between numbered lines (the default is 1, which means every line will be numbered).

To use this environment, remember to add \usepackage{moreverb} to the document preamble.

As we have seen, the only way LaTeX allows you to add comments is by using the special character %, that will comment out all the rest of the line after itself. This approach is really time-consuming if you want to insert long comments or just comment out a part of your document that you want to improve later, unless you're using an editor that automates this process. Alternatively, you can use the verbatim package, to be loaded in the preamble as usual:

 \usepackage{verbatim} 

(you can also use the comment package instead) you can use an environment called comment that will comment out everything within itself. Here is an example:

 This is another \begin{comment} rather stupid, but helpful \end{comment} example for embedding comments in your document.  This is another example for embedding comments in your document.

Note that this won’t work inside complex environments, like math for example. You may be wondering, why should I load a package called verbatim to have the possibility to add comments? The answer is straightforward: commented text is interpreted by the compiler just like verbatim text, the only difference is that verbatim text is introduced within the document, while the comment is just dropped.

Alternatively, you can define a \comment{} command, by adding the following to the document's preamble:

 \newcommand{\comment}[1]{} 

Then, to comment out text, simply do something like this:

 \comment{This is a long comment and can extend over multiple lines, etc.} But it won't show.  But it won't show.

This approach can, however, produce unwanted spaces in the document, so it may work better to use

 \newcommand{\comment}[2]{#2} 

Then if you supply only one argument to \comment{}, this has the desired effect without producing extra spaces.

Another drawback is that content is still parsed and possibly expanded, so you cannot put anything you want in it (such as LaTeX commands).

### Skipping parts of the source

A more robust way of making the TeX engine skip some part of the source is to use the TeX \iffalse-conditional. The typical use is

 This we want to keep \iffalse % ----- START THE CUT --------- But this part $$\int_{-\infty}^\infty\mathrm{d}x\,x^{-2}$$ we want to skip \fi % ---------- END THE CUT ----------- Here it begins again  This we want to keep Here it begins again

The \iffalse-conditional is always false.

### Quoting text

LaTeX provides several environments for quoting text; they have small differences and they are aimed for different types of quotations. All of them are indented on either margin, and you will need to add your own quotation marks if you want them. The provided environments are:

quote
for a short quotation, or a series of small quotes, separated by blank lines.
quotation
for use with longer quotations, of more than one paragraph, because it indents the first line of each paragraph.
verse
is for quotations where line breaks are important, such as poetry. Once in, new stanzas are created with a blank line, and new lines within a stanza are indicated using the newline command, \\. If a line takes up more than one line on the page, then all subsequent lines are indented until explicitly separated with \\.

### Abstracts

In scientific publications it is customary to start with an abstract which gives the reader a quick overview of what to expect. See Document Structure.

## Notes and References

This page uses material from Andy Roberts' Getting to grips with LaTeX with permission from the author.

# Colors

Adding colors to your text is supported by the xcolor package (supersedes package color). Using this package, you can set the font color, text background, or page background. You can choose from predefined colors or define your own colors using RGB, Hex, or CMYK. Mathematical formulas can also be colored.

To make use of these features, the xcolor package must be imported. xcolor starts from the basic facilities of the color package and extends it.

 \usepackage{xcolor} 

The package allows you to use the names of 19 base colors (black, white, blue, green, yellow, red etc.); these names are always available. Besides, the package has some options to get more predefined colors, which should be added globally. dvipsnames allows you to access more than 60 colors, and svgnames allows access to about 150 colors. If you need more color names, then you may also want to look at the x11names option that offers more than 300 colors.

The table option allows colors to be added to tables.

## Entering colored text

The simplest way to type colored text is by:

 \textcolor{declared-color}{text} 

where declared-color is a color that was defined before by \definecolor.

Another possible way by

 {\color{declared-color}some text} 

that will switch the standard text color to the color you want. It will work until the end of the current TeX group. For example:

 \emph{some black text, \color{red}followed by a red fragment}, going black again. 

The difference between \textcolor and \color is the same as that between \texttt and \ttfamily, you can use the one you prefer. The \color environment allows the text to run over multiple lines and other text environments whereas the text in \textcolor must all be one paragraph and not contain other environments.

You can change the background color of the whole page by:

 \pagecolor{declared-color} 

## Entering colored background for the text

 \colorbox{declared-color}{text} 

If the background color and the text color is changed, then:

 \colorbox{declared-color1}{\color{declared-color2}text} 

There is also \fcolorbox to make framed background color in yet another color:

 \fcolorbox{declared-color-frame}{declared-color-background}{text} 

## Predefined colors

The predefined color names are

black, blue, brown, cyan, darkgray, gray, green, lightgray, lime, magenta, olive, orange, pink, purple, red, teal, violet, white, yellow.


There may be other pre-defined colors on your system, but these should be available on all systems.

If you would like a color not pre-defined, you can use one of the 68 dvips colors, or define your own. These options are discussed in the following sections

### The 68 standard colors known to dvips

Invoke the package with the usenames and dvipsnames option. If you are using tikz or pstricks package you must declare the xcolor package before that, otherwise it will not work.

 \usepackage[dvipsnames]{xcolor} 

This above syntax may result in an error if you are using beamer with tikz. To go around it, include usenames and dvipsnames options when defining the document class.

 \documentclass[usenames,dvipsnames]{beamer} 

Be wary that the below color names are case-sensitive. For example, \color{olivegreen} raises an "undefined color" error, but \color{OliveGreen} works fine.

Name Color   Color Name
Apricot       Aquamarine
Bittersweet       Black
Blue       BlueGreen
BlueViolet       BrickRed
Brown       BurntOrange
Cerulean       CornflowerBlue
Cyan       Dandelion
DarkOrchid       Emerald
ForestGreen       Fuchsia
Goldenrod       Gray
Green       GreenYellow
JungleGreen       Lavender
LimeGreen       Magenta
Mahogany       Maroon
Melon       MidnightBlue
Mulberry       NavyBlue
OliveGreen       Orange
OrangeRed       Orchid
Peach       Periwinkle
PineGreen       Plum
ProcessBlue       Purple
RawSienna       Red
RedOrange       RedViolet
Rhodamine       RoyalBlue
RoyalPurple       RubineRed
Salmon       SeaGreen
Sepia       SkyBlue
SpringGreen       Tan
TealBlue       Thistle
Turquoise       Violet
VioletRed       White
WildStrawberry       Yellow
YellowGreen       YellowOrange

## Defining new colors

If the predefined colors are not adequate, you may wish to define your own.

### Place

Define the colors in the preamble of your document. (Reason: do so in the preamble, so that you can already refer to them in the preamble, which is useful, for instance, in an argument of another package that supports colors as arguments, such as the listings package.)

### Method

You need to include the xcolor package in your preamble to define new colors. In the abstract, the colors are defined following this scheme:

 \definecolor{name}{model}{color-spec} 

where:

• name is the name of the color; you can call it as you like
• model is the way you describe the color, and is one of gray, rgb, RGB, HTML, and cmyk.
• color-spec is the description of the color

### Color Models

Among the models you can use to describe the color are the following (several more are described in the xcolor manual):

Color Models
Model Description Color Specification Example
(0-1)
Just one number between 0 (black) and 1 (white), so 0.95 will be very light gray, 0.30 will be dark gray. \definecolor{light-gray}{gray}{0.95}
rgb Red, Green, Blue
(0-1)
Three numbers given in the form red,green,blue; the quantity of each color is represented with a number between 0 and 1. \definecolor{orange}{rgb}{1,0.5,0}
RGB Red, Green, Blue
(0-255)
Three numbers given in the form red,green,blue; the quantity of each color is represented with a number between 0 and 255. \definecolor{orange}{RGB}{255,127,0}
HTML Red, Green, Blue
(00-FF)
Six hexadecimal numbers given in the form RRGGBB; similar to what is used in HTML. \definecolor{orange}{HTML}{FF7F00}
cmyk Cyan, Magenta, Yellow, Black
(0-1)
Four numbers given in the form cyan,magenta,yellow,black; the quantity of each color is represented with a number between 0 and 1. \definecolor{orange}{cmyk}{0,0.5,1,0}

### Examples

To define a new color, follow the following example, which defines orange for you, by setting the red to the maximum, the green to one half (0.5), and the blue to the minimum:

 \definecolor{orange}{rgb}{1,0.5,0} 

The following code should give a similar results to the last code chunk.

 \definecolor{orange}{RGB}{255,127,0} 

If you loaded the xcolor package, you can define colors upon previously defined ones.

The first specifies 20 percent blue and 80 percent white; the second is a mixture of 20 percent blue and 80 percent black; and the last one is a mixture of (20*0.3) percent blue, ((100-20)*0.3) percent black and (100-30) percent green.

 \color{blue!20} \color{blue!20!black} \color{blue!20!black!30!green} 

xcolor also features a handy command to define colors from color mixes:

 \colorlet{notgreen}{blue!50!yellow} 

### Using color specifications directly

Normally one would predeclare all the colors as above, but sometimes it is convenient to directly use a color without naming it first. To achieve this, \color and \textcolor have an alternative syntax specifying the model in square brackets, and the color specification in curly braces. For example:

 {\color[rgb]{1,0,0} This text will appear red-colored} \textcolor[rgb]{0,1,0}{This text will appear green-colored} 

### Creating / Capturing colors

You may want to use colors that appear on another document, web pages, pictures, etc. Alternatively, you may want to play around with rgb values to create your own custom colors.

Image processing suites like the free GIMP suite for Linux/Windows/Mac offer color picker facilities to capture any color on your screen or synthesize colors directly from their respective rgb / hsv / hexadecimal values.

Smaller, free utilities also exist:

### Spot colors

Spot colors are customary in printing. They usually refer to pre-mixed inks based on a swatchbook (like Pantone, TruMatch or Toyo). The package colorspace extends xcolor to provide real spot colors (CMYK and CIELAB). They are defined with, say:

 \definespotcolor{mygreen}{PANTONE 7716 C}{.83, 0, .40, .11} 

# Fonts

## Font families

There are hundreds - if not thousands - of typefaces, or font families. Common examples include Times, Courier, and Helvetica. These families can generally be grouped into three main categories: serif, sans serif, and monospaced. LaTeX commands generally refer to these with the shorthand rm, sf, and tt respectively.

By default, LaTeX uses Computer Modern, a family of typefaces designed by Donald Knuth for use with TeX. It contains serif, sans serif, and monospaced fonts, each available in several weights and optical sizes.

The bodies of LaTeX documents are set in Roman (serif) type by default, but this can be changed by setting the family default:

 \renewcommand{\familydefault}{} 

where <family> is any of the following:

• \rmdefault
• \sfdefault
• \ttdefault

## Emphasizing text

In order to add some emphasis to a word or a phrase, use the \emph{text} command, which usually italicizes the text. Italics may be specified explicitly with \textit{text}.

 I want to \emph{emphasize} a word.  I want to emphasize a word.

Note that the \emph command is dynamic: if you emphasize a word which is already in an emphasized sentence, it will be reverted to the upright font.

 \emph{In this emphasized sentence, there is an emphasized \emph{word} which looks upright.}  In this emphasized sentence, there is an emphasized word which looks upright.

Text may be emphasized more heavily through the use of boldface, particularly for keywords the reader may be trying to find when reading the text. As bold text is generally read before any other text in a paragraph or even on a page, it should be used sparingly. It may also be used in place of italics when using sans-serif typefaces to provide a greater contrast with unemphasized text. Bold text can be generated with the \textbf{text} command.

 \textbf{Bold text} may be used to heavily emphasize very important words or phrases.  Bold text may be used to heavily emphasize very important words or phrases.

## Font styles

Typefaces usually come in various styles and weights, such as italic and bold. The following table lists the commands you will need to access typical font shapes.

Note: Paragraph breaks are not allowed inside the command forms.

LaTeX command Equivalent switch Output style Remarks
\textnormal{...} {\normalfont ...} document font family This is the default or normal font.
\emph{...} {\em ...} emphasis Typically italics. Using emph{} inside of italic text removes the italics on the emphasized text.
\textrm{...} {\rmfamily ...} roman font family
\textsf{...} {\sffamily ...} sans serif font family
\texttt{...} {\ttfamily ...} teletypefont family This is a fixed-width or monospace font.
\textup{...} {\upshape ...} upright shape The same as the normal typeface.
\textit{...} {\itshape ...} italic shape
\textsl{...} {\slshape ...} slanted shape A skewed version of the normal typeface (similar to, but slightly different from, italics).
\textsc{...} {\scshape ...} Small Capitals
\uppercase{...} uppercase (all caps) Also \lowercase. There are some caveats, though; see here.
\textbf{...} {\bfseries ...} bold
\textmd{...} {\mdseries ...} medium weight The normal font weight.
\textlf{...} {\lfseries ...} light A font weight lighter than normal. Not supported by all typefaces.

Generally, one should prefer the commands over their equivalent switches because the former automatically corrects spacing immediately following the end of the selected style.

You may have noticed the absence of underline - this is because underlining is a byproduct of the typewriter era, and is not recommended when bold and italic type is available instead.[2] However, underlining can be useful in some cases, such as to draw attention to changes during editing. Although underlining is available via the \underline{...} command, text underlined in this way will not break properly. Instead, use the \ul{...} command from the soul package or \uline{...} command from the ulem (underline emphasis) package. By default, the latter package also overrides \emph to underline instead of italicize the text. In the likely case that this is not your intent, use the normalem option, i.e. \usepackage[normalem]{ulem}. Both packages also provide strikethrough text with \st{...} or \sout{...}, respectively.

## Sizing text

### Built-in sizes

To scale text relative to the default body text size, use the following commands:

Command Output
\tiny sample text
\scriptsize sample text
\footnotesize sample text
\small sample text
\normalsize sample text
\large sample text
\Large sample text
\LARGE sample text
\huge sample text
\Huge sample text

These commands change the size within a given scope. For instance {\Large some words} will change the size of only some words, and does not affect the font in the rest of the document. It will work for most parts of the text.

 {\Large\tableofcontents} 

These commands cannot be used in math mode. However, part of a formula may be set in a different size by using an \mbox command containing the size command. The new size takes effect immediately after the size command; if an entire paragraph or unit is set in a certain size, the size command should include the blank line or the \end{...} which delimits the unit.

By default, \normalsize is 10 points, but this can be changed in the \documentclass declaration, e.g. \documentclass[12pt]{article}. Note that not every document class has unique sizes for all of the above size commands.

Absolute Point Sizes
size standard classes (except slides), beamer AMS classes, memoir slides
[10pt] [11pt] [12pt] [10pt] [11pt] [12pt]
\tiny 5 6 6 6 7 8 13.82
\scriptsize 7 8 8 7 8 9 16.59
\footnotesize 8 9 10 8 9 10 16.59
\small 9 10 10.95 9 10 10.95 16.59
\normalsize 10 10.95 12 10 10.95 12 19.907
\large 12 12 14.4 10.95 12 14.4 23.89
\Large 14.4 14.4 17.28 12 14.4 17.28 28.66
\LARGE 17.28 17.28 20.74 14.4 17.28 20.74 34.4
\huge 20.74 20.74 24.88 17.28 20.74 24.88 41.28
\Huge 24.88 24.88 24.88 20.74 24.88 24.88 41.28

Points in TeX follow the standard American point system in which 1 pt is approximately 0.35136 mm. The standard point size used in most modern computer programs (known as the desktop publishing point or PostScript point) has 1 pt equal to approximately 0.3527 mm while the standard European point size (known as the Didot point) had 1 pt equal to approximately 0.37597151 mm (see: point (typography)).

### Arbitrary sizes

The \tiny...\Huge commands are often enough for your needs, but you may occasionally want an arbitrary font size. This is done with \fontsize{<size>}{<line space>}\selectfont. For example:

 \fontsize{5cm}{5.5cm}\selectfont 

sets the current font size to 5cm with 5.5 centimeter leading.

If you are using the latex or pdflatex engines, you may get a warning similar to the following:

LaTeX Font Warning: Font shape OT1/cmr/m/n' in size <142.26378> not available
(Font)              size <24.88> substituted on input line 103.


This is because these older engines only support a fixed set of sizes - between 5 and 17 point. When he designed Computer Modern, Knuth created individual font files for these sizes, each with stroke widths and spacing optimized for that particular size. To avoid distorting them, scaling these fonts is disabled by default.

This issue is avoided when using lualatex or xelatex, which use Latin Modern - a vectorized version of Computer Modern - as the default font family. This still provides individual files at each of the original optical sizes, but will automatically scale the closest one when asked for an arbitrary size.

## Using alternative fonts

When TeX was originally designed in the late 1970s, vector-based fonts didn't exist in any common format - PostScript wouldn't be released until 1982. Consequently, TeX was designed to use its own font system, METAFONT. Over time, TeX (and LaTeX) were extended to support PostScript fonts, and modern LaTeX engines also support the TrueType (TTF) and OpenType (OTF) fonts found on modern systems.

### Using TTF and OTF fonts

If you are using lualatex or xelatex, you can use TTF and OTF fonts with the fontspec package:

 \documentclass{article} \usepackage{fontspec} \setmainfont[Ligatures=TeX]{Georgia} \setsansfont[Ligatures=TeX]{Arial} \begin{document} Lorem ipsum... \end{document} 

The [Ligatures=TeX] option allows you to use the standard TeX ligatures mentioned in the Text Formatting chapter instead of Unicode characters that are unlikely to be on your keyboard. For example, --- can be used to create em dashes (—), quotes can be typed like this'' instead of “like this”, and so on.

The fontspec package is extremely configurable. See the manual[3] for details, but some basics are covered below.

#### Selecting font files

Different weights and styles of a given typeface are usually stored as separate font files. A typical typeface might offer four files to represent its normal weight, italics, bold, and bold italics. Given a typefaces's name, fontspec can generally deduce the names of the individual files. However, many typefaces come in more than two weights—some versions of Futura, for example, comes in light, book, medium, demi, bold, and extra bold weights. Sometimes small caps are stored as separate files as well.

We might want to hand-pick weights to achieve a certain look or better match the weights of other fonts in our document. Continuing to use Futura as an example, say we want to use the "book" weight for our default weight, "demi" for bold, and the font files are named:

• Futura-Boo for upright book weight
• Futura-BooObl for oblique book weight
• FuturaSC-Boo for small caps, book weight
• Futura-Dem for upright demi(bold)
• Futura-DemObl for oblique demibold

Our font setup might resemble:

 \usepackage{fontspec} \setmainfont[ Ligatures=TeX, UprightFont = *-Boo, ItalicFont = *-BooObl, SmallCapsFont = *SC-Boo, BoldFont = *-Dem, BoldItalicFont = *-DemObl ]{Futura} 

Note that instead of typing out Futura-Boo, Futura-BooObl, and so on, we can use * to insert the base name.

#### Controlling font features

The OpenType (OTF) format allows type designers to embed font features that can be turned on and off, such as:

• Alternate versions of glyphs
• Lining and "oldstyle" figures, each with tabular and proportional spacing[4]
• Up to three sets of ligatures: standard, contextual, and historical
• Superscript and subscript glyphs
• Small caps (in the same file as the standard upper and lowercase characters)

All of these features can be turned on and off using different fontspec options. If we wanted to set our body text in Linux Libertine with oldstyle, proportionally-spaced figures, for example, we might set up our fonts as follows:

 \setmainfont[ Ligatures=TeX, Numbers={OldStyle, Proportional} ]{Linux Libertine} 

Features can be turned on and off using \addfontfeatures{...}. Say you wanted to set a table in lining, tabular figures:

 {\addfontfeatures{Numbers={Lining, Tabular}} \begin{tabular}{l r} Widgets: & 25 \\ Gadgets: & 6 \\ Whatsits & 24 \\ \end{tabular} } % Return to previous figure style 

### Changing fonts in latex and pdflatex

If you are not using one of the Unicode-aware engines, font selection is more complicated. (See the discussion of encoding below.) Useful resources for latex and pdflatex font configuration include:

## Font encoding

Digitising human language is a complicated topic that has evolved significantly since TeX's inception.

### Unicode

Today, text is usually represented in computer systems using Unicode. Briefly,

• A Unicode text file is made of a series of code points, each of which can represent a character to be drawn, an accent or other diacritical mark to combine with an adjacent character, or some non-printing character, such as instruction to print subsequent text right-to-left.
• One or more of these code points combines to represent a grapheme cluster or glyph, the shapes within a font that we informally call "characters".
• Modern font formats such as TrueType and OpenType contain encoding tables which map code points to the glyphs the font file contains.

LuaLaTeX and XeLaTeX use these tools to render Unicode-encoded input files (LuaLaTeX accepts UTF-8 files, while XeLaTeX is a bit more flexible and also accepts UTF-16 and UTF-32) into PDF documents.

### TeX encodings

The original TeX and LaTeX, designed long before the advent of Unicode, use a very different scheme. When using latex or pdflatex, you must choose an input encoding, which the engine uses to interpret your file, and an output encoding, which the engine uses to map your inputs to glyphs. The default font encoding is OT1, the encoding of the original Computer Modern fonts. It contains only 128 characters, many from ASCII, but leaving out some others and including a number that are not in ASCII. When accented characters are required, TeX creates them by combining a normal character with an accent. While the resulting output looks correct, this approach has some caveats compared to Unicode-based approaches:

• It prevents automatic hyphenation from working inside words containing accented characters.
• Searches for words with accents in PDFs will fail.
• Extracting (e.g., via copy-paste) the umlaut 'Ä' via a PDF viewer actually extracts the two characters '"A'.
• Some Latin letters cannot be created with this approach, to say nothing about letters of non-Latin alphabets such as Greek or Cyrillic.

To overcome these shortcomings, several other 8-bit output encodings were created. Extended Cork (EC) fonts in T1 encoding contains letters and punctuation characters for most European languages that use Latin alphabets. The LH font set contains letters necessary to typeset documents in languages using Cyrillic script. Because of the large number of Cyrillic glyphs, they are arranged into four font encodings—T2A, T2B, T2C, and X2. The CB bundle contains fonts in LGR encoding for the composition of Greek text. By using these fonts you can improve/enable hyphenation in non-English documents. Another advantage of using new CM-like fonts is that they provide fonts of CM families in all weights, shapes, and optically scaled font sizes.

All this is not possible with OT1; that's why you may want to change the font encoding of your document.

Note that different fonts support different output encodings. The default Computer Modern font does not support T1, for example. You will need Computer Modern Super (cm-super) or Latin Modern (lmodern), which are Computer Modern-like fonts with T1 support. If you have none of these, it is quite frequent (depends on your TeX installation) that tex chooses a Type3 font such as the Type3 EC, which is a bitmap font. Bitmap fonts look rather ugly when zoomed or printed.

The fontenc package tells LaTeX what font encoding to use. Font encoding is set with:

 \usepackage['encoding']{fontenc} 

where encoding is the font encoding. It is possible to load several encodings simultaneously.

There is nothing to change in your document to use CM Super fonts (assuming they are installed), they will get loaded automatically if you use T1 encoding. For lmodern, you will need to load the package after the T1 encoding has been set:

 \usepackage[T1]{fontenc} \usepackage{lmodern} 

The package ae (almost European) is obsolete. It provided some workarounds for hyphenation of words with special characters. These are not necessary any more with fonts like lmodern. Using the ae package leads to text encoding problems in PDF files generated via pdflatex (e.g. text extraction and searching), besides typographic issues.

## PDF fonts and properties

PDF documents have the capability to embed font files. It makes them portable, hence the name Portable Document Format.

Many PDF viewers have a Properties feature to list embedded fonts and document metadata.

Many Unix systems make use of the poppler tool set which features pdfinfo to list PDF metadata, and pdffonts to list embedded fonts.

## References

1. Matthew Butterick. "Bold or italic". Practical Typography.
2. Matthew Butterick. "Underlining". Practical Typography.
3. http://mirrors.ctan.org/macros/latex/contrib/fontspec/fontspec.pdf
4. Matthew Butterick. "Alternate figures". Practical Typography.

# List Structures

Convenient and predictable list formatting is one of the many advantages of using LaTeX. Users of WYSIWYG word processors can sometimes be frustrated by the software's attempts to determine when they intend lists to begin and end. As a mark-up language, LaTeX gives more control over the structure and content of lists.

## List structures

Lists often appear in documents, especially academic, as their purpose is often to present information in a clear and concise fashion. List structures in LaTeX are simply environments which essentially come in three types:

• itemize for a bullet list
• enumerate for an enumerated list and
• description for a descriptive list.

All lists follow the basic format:

 \begin{list_type} \item The first item \item The second item \item The third etc \ldots \end{list_type} 

All three of these types of lists can have multiple paragraphs per item: just type the additional paragraphs in the normal way, with a blank line between each. So long as they are still contained within the enclosing environment, they will automatically be indented to follow underneath their item.

Try out the examples below, to see what the lists look like in a real document.

 \documentclass{article} \usepackage{blindtext} \begin{document} \begin{itemize} \item \blindtext \item \blindtext \end{itemize} \begin{enumerate} \item \blindtext \item \blindtext \end{enumerate} \begin{description} \item [Ant] \blindtext \item [Elephant] \blindtext \end{description} \end{document}  Sample output of lists in LaTeX. Itemize, enumerate, and description.

LaTeX will happily allow you to insert a list environment into an existing one (up to a depth of four, more levels are available using packages). Simply begin the appropriate environment at the desired point within the current list. Latex will sort out the layout and any numbering for you.

 \begin{enumerate} \item The first item \begin{enumerate} \item Nested item 1 \item Nested item 2 \end{enumerate} \item The second item \item The third etc \ldots \end{enumerate} 

## Some special lists

Sometimes you feel the need to better align the different list items. If you are using a KOMA-script class (or package scrextend), the labeling environment is handy. It takes a mandatory argument that contains the longest of your labels.

 \documentclass[twocolumn]{article} \usepackage{blindtext} \usepackage{scrextend} \addtokomafont{labelinglabel}{\sffamily} \begin{document} \blindtext \begin{labeling}{alligator} \item [ant] really busy all the time \item [chimp] likes bananas \item [alligator] very dangerous animal, sharp teeth, long muscular tail and a bit of text that is longer than one line and shows the alignment of text quite nicely \end{labeling} \end{document} 

If you are on tight space limitations and only have short item descriptions, you may want to have the list inline. Please note that the example also shows how to change the font.

 \documentclass[twocolumn]{article} \usepackage{blindtext} \usepackage[inline]{enumitem} \usepackage{xcolor} \begin{document} \blindtext Coco likes fruit. Her favorites are: \begin{enumerate*}[label={\alph*)},font={\color{red!50!black}\bfseries}] \item bananas \item apples \item oranges and \item lemons. \end{enumerate*} \blindtext \end{document} 

If you want a horizontal list, package tasks can be handy. In combination with a package like exsheets, you can prepare exam papers for students.

 \documentclass[12pt]{article} \usepackage{tasks} \usepackage{exsheets} \SetupExSheets[question]{type=exam} \begin{document} \begin{question} Which one of the entries does not fit with the others? \begin{tasks}(4) \task mercury \task iron \task lead \task zinc \end{tasks} \end{question} \settasks{ counter-format=(tsk[r]), label-width=4ex } \begin{question} What is a funkyton? \begin{tasks}(2) \task A dancing electron \task A dancing proton \task A dancing neutron \task A Dixie Dancing Duck \end{tasks} \end{question} \end{document} 

## Customizing lists

When dealing with lists containing just a few words per item, the standard lists often take up too much space. Package enumitem provides you a simple interface to customize the appearance of lists.

You can change the appearance of lists globally in the preamble, or just for single lists using the optional argument of the environment. Have a look at the following example where the list on the right is more compact using noitemsep.

 \documentclass[twocolumn]{article} \usepackage{blindtext} \usepackage{enumitem} \begin{document} \blindtext \begin{itemize} \item more work \item more responsibility \item more satisfaction \end{itemize} \blindtext \newpage \blindtext \begin{itemize}[noitemsep] \item more work \item more responsibility \item more satisfaction \end{itemize} \blindtext \end{document} 

An example for alignment and the width of the label.

 \documentclass[twocolumn]{article} \usepackage{blindtext} \usepackage{enumitem} \begin{document} \blindtext Coco likes fruit. Her favourites are: \begin{description}[align=left] \item [Kate] some detail \item [Christina]some detail \item [Laura]some detail \end{description} \begin{description}[align=right] \item [Kate] some detail \item [Christina]some detail \item [Laura]some detail \end{description} \begin{description}[align=right,labelwidth=3cm] \item [Kate] some detail \item [Christina]some detail \item [Laura]some detail \end{description} \blindtext \end{document} 

The documentation of package enumitem goes into more detail with respect to what can be changed and how. You can even define your own lists. Environments like labeling and tasks can be changed differently, details can be found in the package documentation respectively.

## Easylist package

The easylist package allows you to create list using a more convenient syntax and with infinite nested levels. It is also very customizable.

Load the package with the control character as optional argument:

 \usepackage[ampersand]{easylist} 

The easylist environment will default to enumerations.

 \begin{easylist} & Main item~: && Sub item. && Another sub item. \end{easylist} 

It features predefined styles which you can set as optional argument.

 \begin{easylist}[itemize] % ... \end{easylist} 

Available styles:

• tractatus
• checklist - All items have empty check boxes next to them
• enumerate - The default
• itemize

You can customize lists with the \ListProperties(...) command and revert back the customization with \NewList. Yes, that's parentheses for \ListProperties parameters.

The Style parameter sets the style of counters and text, the Style* parameter sets the style of counters, and the Style** parameter sets the style of text. The parameter Numbers determines the way that the numbers are displayed and the possible values are r or R (for lower and upper case Roman numerals), l or L (for lower and upper case letters), a (for Arabic numbers, the default), and z (for Zapf's Dingbats).

The FinalMark parameter sets the punctuation of the final counter (Ex: FinalMark3={)}) while FinalSpace sets the amount of space between the item and the item's text. The Margin parameter sets the distance from the left margin (Ex: FinalSpace2=1cm). The Progressive parameter sets the distance from the left margin of all items in proportion to their level.

The Hide = n parameter prevents the first n counters from appearing in all levels. If there is a number after a parameter (Ex: Style3*) then this numbers indicates the level that it will affect (Ex: Style3=\color{red}).

Example of custom enumerate:

 \begin{easylist}[enumerate] \ListProperties(Style2*=,Numbers=a,Numbers1=R,FinalMark={)}) & Main item~: && Sub item. && Another sub item. \end{easylist} 

Note that we put the FinalMark argument between {} to avoid LaTeX understanding it as the end of the properties list. Now we change the default properties to print a custom itemize:

 \usepackage{amssymb} \ListProperties(Hide=100, Hang=true, Progressive=3ex, Style*=-- , Style2*=$\bullet$ ,Style3*=$\circ$ ,Style4*=\tiny$\blacksquare$ ) % ... \begin{easylist} & Blah & Blah && Blah &&& Blah &&&& Blah &&&&& Blah \end{easylist}  – Blah   $\bullet$  Blah    $\circ$  Blah     $\blacksquare$  Blah      – Blah

Spaces in Style parameters are important. The Style* parameter acts as a default value and easylist will use a medium dash for level 1, 5 and onward.

You can also define custom styles using LaTeX macros:


Important note: easylist has some drawbacks. First if you need to put an easylist inside an environment using the same control character as the one specified for easylist, you may get an error. To circumvent it, use the following commands provided by easylist:

 \Activate \begin{easylist} & ... \end{easylist} \Deactivate 

Besides using easylist along with figures may cause some trouble to the layout and the indentation. LaTeX lists do not have this problem.

To use easylist with Beamer, each frame that uses easylist must be marked as fragile:

 \begin{frame}[fragile] ... \begin{easylist}[itemize] ... \end{easylist} ... \end{frame} 

# Special Characters

In this chapter we will tackle matters related to input encoding, typesetting diacritics and special characters.

In the following document, we will refer to special characters for all symbols other than the lowercase letters a–z, uppercase letters A-Z, figures 0–9, and English punctuation marks.

Some languages usually need a dedicated input system to ease document writing. This is the case for Arabic, Chinese, Japanese, Korean and others. This specific matter will be tackled in Internationalization.

The rules for producing characters with diacritical marks, such as accents, differ somewhat depending whether you are in text mode, math mode, or the tabbing environment.

## Input encoding

TeX uses ASCII by default. But 128 characters is not enough to support non-English languages. TeX has its own way of doing that with commands for every diacritical marking (see Escaped codes). But if we want accents and other special characters to appear directly in the source file, we have to tell TeX that we want to use a different encoding.

There are several encodings available to LaTeX:

• ASCII: the default. Only bare English characters are supported in the source file.
• ISO-8859-1 (a.k.a., Latin 1): 8-bits encoding. It supports most characters for Latin languages, but that's it.
• UTF-8: a Unicode multi-byte encoding. Supports the complete Unicode specification.
• Others...

In the following we will assume that you want to use UTF-8.

There are some important steps to specify encoding.

• Make sure your text editor decodes the file in UTF-8.
• Make sure it saves your file in UTF-8. Most text editors do not make the distinction, but some do, such as Notepad++.
• If you are working in a terminal, make sure it is set to support UTF-8 input and output. Some old Unix terminals may not support UTF-8. PuTTY is not set to use UTF-8 by default, you have to configure it.
• Tell LaTeX that the source file is UTF-8 encoded.
 \usepackage[utf8]{inputenc} 

inputenc [1] package tells LaTeX what the text encoding format of your .tex files is.

The inputenc package allows the user to change the encoding within the document as well — by means of the command \inputencoding{'encoding name'}.

 \usepackage[utf8]{inputenc} % ... % In this area % The UTF-8 encoding is specified. % ... \inputencoding{latin1} % ... % Here the text encoding is specified as ISO Latin-1. % ... \inputencoding{utf8} % Back to the UTF-8 encoding. % ... 

### Extending the support

The LaTeX support of UTF-8 is fairly specific: it includes only a limited range of Unicode input characters. It only defines those symbols that are known to be available with the current font encoding. You might encounter a situation where using UTF-8 might result in error:

! Package inputenc Error: Unicode char \u8:ũ not set up for use with LaTeX.


This is due to the utf8 definition not necessarily having a mapping of all the character glyphs you are able to enter on your keyboard. Such characters include, for example:

ŷ Ŷ ũ Ũ ẽ Ẽ ĩ Ĩ


In such case, you may try to use the utf8x option to define more character combinations. utf8x is not officially supported, but can be viable in some cases. However, it might break up compatibility with some packages like csquotes.

Another possiblity is to stick with utf8 and to define the characters yourself. This is easy:

 \DeclareUnicodeCharacter{'codepoint'}{'TeX sequence'} 

where codepoint is the unicode codepoint of the desired character. TeX sequence is what to print when the character matching the codepoint is met. You may find codepoints on this site. Codepoints are easy to find on the web. Example:

 \DeclareUnicodeCharacter{0177}{\^y} 

Now inputting ŷ will effectively print ŷ.

## Escaped codes

In addition to direct UTF-8 input, LaTeX supports the composition of special characters as well. This is convenient if your keyboard lacks some desired accents and other diacritics.

The following accents may be placed on letters. Although "o" letter is used in most of the examples, the accents may be placed on any letter. Accents may even be placed above a "missing" letter; for example, \~{} produces a tilde over a blank space.

The following commands may be used only in paragraph (default) or LR (left-right) mode.

LaTeX command Sample Description
\{o} ò grave accent
\'{o} ó acute accent
\^{o} ô circumflex
\"{o} ö umlaut, trema or dieresis
\H{o} ő long Hungarian umlaut (double acute)
\~{o} õ tilde
\c{c} ç cedilla
\k{a} ą ogonek
\l{} ł barred l (l with stroke)
\={o} ō macron accent (a bar over the letter)
\b{o} o bar under the letter
\.{o} ȯ dot over the letter
\d{u} dot under the letter
\r{a} å ring over the letter (for å there is also the special command \aa)
\u{o} ŏ breve over the letter
\v{s} š caron/háček ("v") over the letter
\t{oo} o͡o "tie" (inverted u) over the two letters
\o{} ø slashed o (o with stroke)
{\i} ı dotless i (i without tittle)

Older versions of LaTeX would not remove the dot on top of the i and j letters when adding a diacritic. To correct this, one had to use the dotless version of these letters, by typing \i and \j. For example:

• \^{\i} should be used for i-circumflex î;
• \"{\i} should be used for i-umlaut ï.

However, current versions of LaTeX do not need this anymore (and may, in fact, crash with an error).

If a document is to be written completely in a language that requires particular diacritics several times, then using the right configuration allows those characters to be written directly in the document. For example, to achieve easier coding of umlauts, the babel package can be configured as \usepackage[german]{babel}. This provides the short hand "o for \"o. This is very useful if one needs to use some text accents in a label, since no backslash will be accepted otherwise.

More information regarding language configuration can be found in the Internationalization section.

## Less than < and greater than >

The two symbols '<' and '>' are actually ASCII characters, but you may have noticed that they will print '¡' and '¿' respectively. This is a font encoding issue. If you want them to print their real symbol, you will have to use another font encoding such as T1, loaded with the fontenc package. See Fonts for more details on font encoding.

Alternatively, they can be printed with dedicated commands:

 \textless \textgreater 

## Euro € currency symbol

When writing about money these days, you need the euro sign. The textcomp package features a \texteuro command which gives you the euro symbol as supplied by your current text font. Depending on your chosen font this may be quite far from the official symbol.

An official version of the euro symbol is provided by eurosym. Load it in the preamble (optionally with the official option):

 \usepackage[official]{eurosym} 

then you can insert it with the \euro{} command. Finally, if you want a euro symbol that matches with the current font style (e.g., bold, italics, etc.) you can use a different option:

 \usepackage[gen]{eurosym} 

again you can insert the euro symbol with \euro{}.

Alternatively, you can use the marvosym package which also provides the official euro symbol.

 \usepackage{marvosym} % ... \EUR{} 

Now that you have succeeded in printing a euro sign, you may want the '€' on your keyboard to actually print the euro sign as above. There is a simple method to do that. You must make sure you are using UTF-8 encoding along with a working \euro{} or \EUR{}command.

 \DeclareUnicodeCharacter{20AC}{\euro{}} % or \DeclareUnicodeCharacter{20AC}{\EUR{}} 

Complete example:

 \usepackage[utf8]{inputenc} \usepackage{marvosym} \DeclareUnicodeCharacter{20AC}{\EUR{}} 

## Degree symbol for temperature and math

The easiest way to print temperature and angle values is to use the \SI{value}{unit} command from the siunitx package, which works both in text and math mode:

 \usepackage{amsmath} \usepackage{siunitx} %... A $\SI{45}{\degree}$ angle. It is \SI{17}{\degreeCelsius} outside. 

A common mistake is to use the \circ command. It will not print the correct character (though $^\circ$ will). Use the textcomp package instead, which provides a \textdegree command.

 \usepackage{textcomp} %... A $45$\textdegree angle. 

For temperature, you can use the same command or opt for the gensymb package and write

 \usepackage{gensymb} \usepackage{textcomp} %... 17\,\celsius % best (with textcomp) 

Some keyboard layouts feature the degree symbol, you can use it directly if you are using UTF-8 and textcomp. For better results in terms of font quality, we recommend the use of an appropriate font, like lmodern:

 \usepackage[utf8]{inputenc} \usepackage{lmodern} \usepackage{textcomp} % ... 17\,°C 17\,℃ % best 

## Other symbols

LaTeX has many symbols at its disposal. The majority of them are within the mathematical domain, and later chapters will cover how to get access to them. For the more common text symbols, use the following commands:

Command Sample Character
\% $\%$  %
\$ $\$$
\{ $\{$  {
\_ $\_$  _
\P $\P$
\ddag n/a
\textbar n/a |
\textgreater $>$  >
\textendash n/a
\texttrademark n/a
\textexclamdown n/a ¡
\textsuperscript{a} ${\mathrm {X^{a}} }$  a
\pounds n/a £
\# $\#$  #
\& $\&$  &
\} $\}$  }
\S $\S$  §
\dag n/a
\textbackslash n/a \
\textless $<$  <
\textemdash n/a
\textregistered n/a ®
\textquestiondown n/a ¿
\textcircled{a} n/a
\copyright n/a ©

Not mentioned in above table, tilde (~) is used in LaTeX code to produce non-breakable space. To get printed tilde sign, either write \~{} or \textasciitilde{}. And a visible space can be created with \textvisiblespace.

For some more interesting symbols, the Postscript ZapfDingbats font is available thanks to the pifont package. Add the declaration to your preamble: \usepackage{pifont}. Next, the command \ding{number}, will print the specified symbol. Here is a table of the available symbols:

.

## In special environments

### Math mode

Several of the above and some similar accents can also be produced in math mode. The following commands may be used only in math mode.

LaTeX command Sample Description Text-mode equivalence
\hat{o} ${\hat {o}}$  circumflex \^
\widehat{oo} ${\widehat {oo}}$  wide version of \hat over several letters
\check{o} ${\check {o}}$  vee or check \v
\tilde{o} ${\tilde {o}}$  tilde \~
\widetilde{oo} ${\widetilde {oo}}$  wide version of \tilde over several letters
\acute{o} ${\acute {o}}$  acute accent \'
\grave{o} ${\grave {o}}$  grave accent \
\dot{o} ${\dot {o}}$  dot over the letter \.
\ddot{o} ${\ddot {o}}$  two dots over the letter (umlaut in text-mode) \"
\breve{o} ${\breve {o}}$  breve \u
\bar{o} ${\bar {o}}$  macron \=
\vec{o} ${\vec {o}}$  vector (arrow) over the letter

When applying accents to letters i and j, you can use \imath and \jmath to keep the dots from interfering with the accents:

LaTeX command Sample Description Sample with upper dot
\hat{\imath} ${\hat {\imath }}$  circumflex on letter i without upper dot ${\hat {i}}$
\vec{\jmath} ${\vec {\jmath }}$  vector (arrow) on letter j without upper dot ${\vec {j}}$

### Tabbing environment

Some of the accent marks used in running text have other uses in the tabbing environment. In that case they can be created with the following command:

• \a' for an acute accent
• \a for a grave accent
• \a= for a macron accent

## Unicode keyboard input

Some operating systems provide a keyboard combination to input any Unicode code point, the so-called unicode compose key.

Many X applications (*BSD and GNU/Linux) support the Ctrl+Shift+u combination. A "u" symbol should appear. Type the code point and press enter or space to actually print the character. Example:

<Ctrl+Shift+u> 20AC <space>


will print the euro character.

Desktop environments like GNOME and KDE may feature a customizable compose key for more memorizable sequences.

Xorg features advanced keyboard layouts with variants that let you enter a lot of characters easily with combination using the appropriate modifier, like Alt Gr. It highly depends on the selected layout+variant, so we suggest you to play a bit with your keyboard, preceding every key and dead key with the Alt Gr modifier.

In Windows, you can hold Alt and type a <codepoint> to get a desired character. For example,

<Alt> + 0252


will print the German letter ü.

# Internationalization

LaTeX requires some additional configuration to typeset documents in languages other than English. There are currently two packages providing international language support, namely, Babel and Polyglossia:

• Babel[1] works with the three main engines, namely, pdfTeX, LuaTeX and XeTeX. Depending on the engine the number of supported languages goes from about 70 to 250, and new ones can be declared easily on the fly. It also provides partial support for Plain TeX.
• Polyglossia was devised as an alternative to Babel for XeTeX (although currently also provides support for LuaTeX, but not for pdfTeX). It supports about 80 languages.

Both packages cover the major languages around the World (French, Spanish, Arabic, Chinese, Japanese, Thai, Hindi, Marathi, etc.) and handle the following tasks:

Fonts
Setting the script and language tags of the current font, if possible, and switching between fonts for each language, as specified by the user (mainly XeTeX and LuaTeX). With Babel + LuaTeX the font can be switched automatically based on script. See also the discussion of fontspec in the Fonts chapter.
Linebreaking, justification and hyphenation
Activating for each script and language the corresponding line breaking algorithm. In the case of hyphenated languages, loading the language-specific hyphenation patterns. Babel provides basic line breaking for CJK scripts, as well as non-standard hyphenation, like “ff” → “ff-f”, repeated hyphens, and ranked rules. There is also some tentative support for Arabic justificacion.
Cultural elements
Translating document labels (like “chapter”, “figure”, “bibliography”), as well as formatting dates according to language-specific conventions and formatting numbers for languages that have their own numbering system.
Bidirectional typesetting
Supporting documents that contain right to left scripts. Babel + LuaTeX uses and algorithm based on te Unicode one, which changes the direction automatically. Layout elements such as tables, margins and so on must be reversed, too, and it's done by Babel with luatex to a great extent. With XeTeX, both Babel and Polyglossia rely on the bidi package, which requires explicit markup to change the direction.
Typographical rules and transliterations
Performing miscellaneous transformation both at the character level (like transliterations) as at the typographical one (like inserting spaces or penalties at appropriate places). Babel with LuaTeX can do it automatically by means of “transforms”; with XeTeX this can be done to some extent (both Babel and Polyglossia), while in 8-bit engines many of them must be done by hand.

With Babel, LaTeX ≥ 2018-04-01, and a monolingual document in UTF-8 encoding (which is the recommended encoding), all you need in many European languages is something like, for example:

 \documentclass[french]{article} \usepackage[T1]{fontenc} % <- With XeTeX or LuaTeX, delete this line \usepackage{babel} \begin{document} Plus ça change, plus c'est la même chose! \end{document} 

In addition, there are some specialized frameworks for languages like Japanese, Corean or Chinese, described below.

## Encodings

### Unicode engines

When using the xelatex or lualatex engines, many of the problems described below are solved for you. Input files are assumed to be UTF-8 (XeLaTeX also accepts UTF-16 and UTF-32), and the engine automatically maps Unicode characters to their glyphs in the TrueType or OpenType fonts you selected for your document. (This is, of course, assuming those fonts contain the glyphs you need, so you must ensure that your fonts support the languages you are using.)

### 8-bit engines

With engines not supporting Unicode internally (latex or pdflatex), LaTeX must handle two fundamental problems:

1. Mapping the bytes of your input file into the characters of the language(s) you want to use.
2. Mapping those characters to their glyphs in the fonts your document uses.

With them, you must tell LaTeX which encoding to use for your input files, and what "output" encoding it should use to map characters to their glyphs in the fonts. In most cases (especially for multilingual documents), UTF-8 is an optimal input encoding, which is currently the default encoding.

For most Latin languages, T1 is the desired output encoding, and can be set with:

 \usepackage[T1]{fontenc} 

Other output encodings for specific languages are shown below.

For additional information, see the discussion of encoding in the Fonts chapter, as well as the Special Characters chapter.

## Polyglossia

When using XeLaTeX or LuaLaTeX, polyglossia provides an alternative to the core babel package for international language support, as described in its manual.

To use polyglossia, load it in your preamble and specify the languages you will be using, along with any language-specific options you wish. For example, in a document that contains American English and French, we might use:

 \usepackage{polyglossia} \setdefaultlanguage[variant=american]{english} \setotherlanguage{french} 

The original aim was to be compatible with babel, but there is a number of differences. For example, the standard mechanism in LaTeX to declare languages, via package or class options, is not recognized, and the user must rely on a set of new commands, as shown in the example. Unlike babel, secondary languages must be always explicitly declared. It also adds the concept of ‘language variant’, while in babel all locales are treated on an equal footing. Furthermore, a new way to switch languages has been devised, with commands like \textenglish or \textlang.

## Babel

When using the latex and pdflatex engines, as well as LuaLaTeX and XeLaTeX in many languages, internationalization is provided by the babel package. There are two ways to specify the document languages. One of them is as arguments to the package when it is loaded:

 \usepackage[language]{babel} 

Another approach is making the language a global option in order to let other packages detect and use it:

 \documentclass[language]{article} \usepackage{babel} 

Finally, babel provides total or partial support for about 200 languages with a set of ini files, which are accessed with \babelprovide. This command can be used to define easily your own language from scratch, too.

Babel will automatically activate the appropriate hyphenation rules for the language you choose. If your LaTeX format does not support hyphenation in the language of your choice, babel will still work but will disable hyphenation, which has quite a negative effect on the appearance of the typeset document (with LuaLaTeX, however, hyphenation rules can be loaded when the document is being typeset). Babel also specifies new commands for some languages, which simplify the input of special characters. See the sections about languages below for more information.

If you call babel with multiple languages:

 \usepackage[languageA,languageB]{babel} 

Short texts in a secondary language does not requiere an explicit declaration when loading babel. Just select it as explained in what follows and the basic declarations will be loaded on the fly.

The last language in the option list will be active (i.e. languageB), and you can use the command

 \selectlanguage{languageA} 

to change the active language (when the document begins, with \begin{document}, the main language is automatically selected). You can also add short pieces of text in another language using the command

 \foreignlanguage{languageB}{Text in another language} 

Babel also offers various environments for entering larger pieces of text in another language:

 \begin{otherlanguage}{languageB} Text in language B. This environment switches all language-related definitions, like the language specific names for figures, tables etc. to the other language. \end{otherlanguage} 

The starred version of this environment typesets the main text according to the rules of the other language, but keeps the language specific string for ancillary things like figures in the main language of the document. The environment hyphenrules switches only the hyphenation patterns used; it can also be used to disallow hyphenation by using the language name 'nohyphenation' (but note otherlanguage* is preferred).

The babel manual provides much more information on these and many other options.

### Font management

If you are using XeTeX or LuaTeX, Babel supports OpenType fonts with fontspec. To ease font handling, it provides the macro \babelfont, which switches the font across languages and sets the OpenType ‘language system’ (ie, language and script). Let us assume you are setting up a document in Swedish, with some words in Hebrew, with a font suited for both languages:

 \babelfont{rm}{FreeSerif} 

If, on the other hand, you have to resort to different fonts, you would say:

 \babelfont{rm}{Iwona} \babelfont[hebrew]{rm}{FreeSerif} 

Also, with version >=3.38 the locale identifiers (\language and \localeid) and the fonts can be switched without explicit markup, depending on the script (only LuaTeX). In the following example, bidi=basic switches the direction, and onchar=ids fonts switches the identifiers and the font:

 \documentclass{article} \usepackage[swedish, bidi=basic]{babel} \babelprovide[import, onchar=ids fonts]{hebrew} \babelfont{rm}{Iwona} \babelfont[hebrew]{rm}{FreeSerif} \begin{document} Svenska עִבְרִית svenska. \end{document} 

### Bidirectional texts

Babel provides basic support fo bidi texts, mainly in LuaTeX. The package option may take three values, namely, default, basic-r, and basic. With bidi=basic RTL and LTR text can be mixed without explicit markup (only LuaTeX).

### Multilingual versions

It is possible in LaTeX to typeset the content of one document in several languages and to choose upon compilation which language to output in predefined strings (chapter name, date, etc.). Using the commands above in multilingual documents can be cumbersome, and therefore babel provides a way to define shorter names. With

 \babeltags{de = german} 

You can write:

 text \textde{German text} text text \begin{de} German text \end{de} text 

There is a clear drawback to this feature, namely, the ‘prefix’ \text... is heavily overloaded in LaTeX and conflicts with existing macros may arise. The babel manual recommends to to stick to the default selectors or to define your own alternatives.

The current language can also be tested by using the iflang package by Heiko Oberdiek (the built-in feature from the babel package is not reliable). Here comes a simple example:

\IfLanguageName{ngerman}{Hallo}{Hello}


This allows to easily distinguish between two languages without the need of defining own commands. Another approach for localized strings is translator.

## Specific languages

Here is a collection of language-specific suggestions. If you have experience in a language not listed below, please add some notes about it. Some of the methods described in this chapter may be useful when dealing with non-English author names in bibliographies.

### Arabic script

Documents in the Arabic script, including Arabic, Persian, Urdu, Pashto, Kurdish, Uyghur, etc., are best typeset with either XeTeX or LuaTeX. An example with babel and LuaTeX follows (rendering by the browser may be different from an editor):

 \documentclass{article} \usepackage[bidi=basic]{babel} \babelprovide[import, main]{arabic} \babelfont{rm}{FreeSerif} \begin{document} وﻗﺪ ﻋﺮﻓﺖ ﺷﺒﻪ ﺟﺰﻳﺮة اﻟﻌﺮب ﻃﻴﻠﺔ اﻟﻌﺼﺮ اﻟﻬﻴﻠﻴﻨﻲ )اﻻﻏﺮﻳﻘﻲ( ﺑـ Arabia أو Aravia )ﺑﺎﻻﻏﺮﻳﻘﻴﺔ Αραβία (، اﺳﺘﺨﺪم اﻟﺮوﻣﺎن ﺛﻼث ﺑﺎدﺋﺎت ﺑـ “Arabia” ﻋﻠﻰ ﺛﻼث ﻣﻨﺎﻃﻖ ﻣﻦ ﺷﺒﻪ اﻟﺠﺰﻳﺮة اﻟﻌﺮﺑﻴﺔ، إﻻ أﻧﻬﺎ ﺣﻘﻴﻘﺔً ﻛﺎﻧﺖ أﻛﺒﺮ ﻣﻤﺎ ﺗﻌﺮف ﻋﻠﻴﻪ اﻟﻴﻮم. \end{document} 

With XeTeX, you may set bidi=bidi-r, but mixed LR and RL text must be marked up explicitly. The same applies to polyglossia.

babel with LuaTeX provides partial and tentative support for Arabic justification based on kashida (with the ARABIC TATWEEL Unicode character) or on the ‘justification alternatives’ OpenType table (jalt).

An alternative package for LuaTeX is arabluatex, which is an extension for LuaTeX of arabtex, described below. For XeTeX there is arabxetex.

In 8-bit engines, they can be typeset in a number of ways, one of the oldest being arabtex. Add the following code to your preamble:

 \usepackage{arabtex} 

You can input text in either romanized characters or native Arabic script encodings. Use any of the following commands and environments to enter in text:

 \< ... > \RL{ ... } \begin{arabtext} ... \end{arabtext}. 

See the ArabTeX Wikipedia article for further details.

You may also use the Arabi package within Babel to typeset Arabic and Persian

 \usepackage{cmap} \usepackage[LAE,LFE]{fontenc} \usepackage[arabic,farsi]{babel} 

You may also copy and paste from PDF files produced with Arabi thanks to the support of the cmap package. You may use Arabi with LyX, or with tex4ht to produce HTML.

### Armenian

The Armenian script uses its own characters, which will require you to install a text editor that supports Unicode and will allow you to enter UTF-8 text, such as Texmaker or WinEdt. These text editors should then be configured to compile using XeLaTeX or LuaLaTeX.

Once the text editor is set up to compile with XeLaTeX or LuaLaTeX, the fontspec package can be used to write in Armenian:

 \usepackage{fontspec} \setmainfont{DejaVu Serif} 

or

 \usepackage{fontspec} \setmainfont{Sylfaen} 

The Sylfaen font lacks italic and bold, but DejaVu Serif supports them.

See Armenian Wikibooks for further details, especially on how to configure the Unicode supporting text editors to compile with Unicode engines.

### Cyrillic script

Currently the most convenient way to typeset Cyrillic texts is with XeTeX or LuaTeX in the UTF-8 encoding. An example for Russian with these engines, which do not require encoding transformations because everything is done directly in that encoding, is:

 \documentclass{article} \usepackage[russian]{babel} \babelfont{rm}{DejaVu Serif} \begin{document} Россия, находящаяся на пересечении множества культур, а также с учётом многонационального характера её населения, — отличается высокой степенью этнокультурного многообразия и способностью к межкультурному диалогу. \end{document} 

Support for Cyrillic in non-Unicode engines is based on standard LaTeX mechanisms plus the fontenc and inputenc packages. babel includes support for the T2* encodings and for typesetting Bulgarian, Russian and Ukrainian texts using Cyrillic letters[2] with non-Unicode engines. AMS-LaTeX packages should be loaded before fontenc and babel(Why?). If you are going to use Cyrillics in mathmode, you also need to load mathtext package before fontenc:

 \usepackage{amsmath,amsthm,amssymb} \usepackage{mathtext} \usepackage[T1,T2A]{fontenc} \usepackage[english,bulgarian,russian,ukrainian]{babel} 

Generally, babel will automatically choose the default font encoding, for the above three languages this is T2A. However, documents are not restricted to a single font encoding. For multilingual documents using Cyrillic and Latin-based languages it makes sense to include Latin font encoding explicitly. Babel will take care of switching to the appropriate font encoding when a different language is selected within the document.

On modern operating systems it is beneficial to use Unicode (utf8 or utf8x) instead of KOI8-RU (koi8-ru) as an input encoding for Cyrillic text.

In addition to enabling hyphenations, translating automatically generated text strings, and activating some language specific typographic rules (like \frenchspacing), babel provides some commands allowing typesetting according to the standards of Bulgarian, Russian, or Ukrainian languages.

For all three languages, language specific punctuation is provided: the Cyrillic dash for the text (it is little narrower than Latin dash and surrounded by tiny spaces), a dash for direct speech, quotes, and commands to facilitate hyphenation:

Key combination Action
"| No ligature at this position.
"- Explicit hyphen sign, allowing hyphenation in the rest of the word.
"--- Cyrillic emdash in plain text.
"--~ Cyrillic emdash in compound names (surnames).
"--* Cyrillic emdash for denoting direct speech.
"" Similar to "-, but it produces no hyphen sign (used for compound words with hyphen, e.g. x-""y or some other signs as “disable/enable”).
"~ Compound word mark without a breakpoint.
"= Compound word mark with a breakpoint, allowing hyphenation in the composing words.
", Thinspace for initials with a breakpoint in a following surname.
"‘ German opening double quote (,,).
"’ German closing double quote (“).
"< French opening double quote (<<).
"> French closing double quote (>>).

The Russian and Ukrainian options of babel define the commands

 \Asbuk \asbuk 

which act like \Alph and \alph (commands for turning counters into letters, e.g. a, b, c...), but produce capital and small letters of Russian or Ukrainian alphabets (whichever is the active language of the document).

The Bulgarian option of babel provides the commands

 \enumBul \enumLat \enumEng 

which make \Alph and \alph produce letters of either Bulgarian or Latin (English) alphabets. The default behaviour of \Alph and \alph for the Bulgarian language option is to produce letters from the Bulgarian alphabet.

See the Bulgarian translation of "The Not So Short Introduction to LaTeX" [3] for a method to type Cyrillic letters directly from the keyboard using a different distribution.

### Chinese

Typesetting Chinese texts (and, in general, CJK script ones) is best done with a complete framework, like CJK o xeCJK, although for short texts or a few words in horizontal typesetting babel with XeTeX and LuaTeX could be enough, with basic line breaking.

#### CJK Package

One possible Chinese support is made available thanks to the CJK package collection. If you are using a package manager or a portage tree, the CJK collection is usually in a separate package because of its size (mainly due to fonts).

Make sure your document is saved using the UTF-8 character encoding. See Special Characters for more details. Put the parts where you want to write chinese characters in a CJK environment.

 \documentclass{article} \usepackage{CJK} \begin{document} \begin{CJK}{UTF8}{gbsn} 你好 You can mix Latin letters and Chinese. \end{CJK} \end{document} 

The last argument specifies the font. It must fit the desired language, since fonts are different for Chinese, Japanese and Korean. Possible choices for Chinese include:

• gbsn (简体宋体, simplified Chinese)
• gkai (简体楷体, simplified Chinese)

In CTeX distribution (which has been outdated), six more fonts for simplified Chinese are included, corresponding to default Windows fonts:

• song (宋体, Simsun)
• hei (黑体, Simhei)
• fang (仿宋, STFangSong)
• kai (楷体, STKaiti)
• li (隶书, SimLi)
• you (幼圆, SimYou)

#### xeCJK Package

When using the XeTeX engine, there is another package called xeCJK, which is based on fontspec and offers similar interface to CJK package.

When using the package, one can define CJK fonts like this:

 \documentclass{article} \usepackage{xeCJK} \setCJKmainfont{FZSSK.ttf} % use Foundertype's Chinese font, which has a free license \begin{document} 你好 You can still mix Latin letters and Chinese! \end{document} 

### Czech

Czech is fine using

 \usepackage[czech]{babel} 

UTF-8 allows you to have „czech quotation marks“ directly in your text. Otherwise, there are macros \clqq and \crqq to produce left and right quote. You can place quotated text inside \uv.

#### Copying and searching in PDF

Although czech letters with diacritical sign are displayed correctly, they are not copy-able or search-able in PDF files generated with pdfLaTeX with just command above. Using package cmap solves this for some fonts, for others is also neccessary to use command glyphtounicode.

Combinations of commands with different fonts
\usepackage{cmap}

\usepackage[resetfonts]{cmap}

\usepackage{cmap}
\input{glyphtounicode}
\pdfgentounicode=1

\usepackage{lmodern}

ešcržýáíédtnúuŠCRŽÁÚ ěščřžýáíéďťňúůŠČŘŽÁÚ ěščřžýáíéďťňúůŠČŘŽÁÚ ěščřžýáíéďťňúůŠČŘŽÁÚ
\usepackage{ebgaramond}

ešcržýáíédtnúuŠCRŽÁÚ ešcržýáíédtnúuŠCRŽÁÚ ešcržýáíédtnúuŠCRŽÁÚ ěščřžýáíéďťňúůŠČŘŽÁÚ

### Devanagari and other Indic scripts

The Devanagari script is used by many languages, including Marathi, Pāḷi, Sanskrit, Hindi, Nepali, Bodo, Konkani, Prakrit. Here is an example for Hindi with babel, for both XeTeX and LuaTeX:

 \documentclass{article} \usepackage[hindi, provide=*]{babel} \babelfont{rm}{FreeSerif} \begin{document} देवनागरी एक भारतीय लिपि है जिसमें अनेक भारतीय भाषाएँ तथा कई विदेशी भाषाएँ लिखी जाती हैं। \end{document} 

Other Indic scripts have a similar setup (Malayalam, Bengali, Sinhala, Telugu, Tamil, Kannada, Assamese, etc.).

If any additional features are required, you need an alternative approach, as illustrated in the following example for Bangla, which sets the option mapdigits for the Arabic digits to be converted to the local ones (only LuaTeX).

 \documentclass{article} \usepackage{babel} \babelprovide[import, main, mapdigits]{bengali} \babelfont{rm}{FreeSerif} \begin{document} গাইতে গাইতে গায়েন। \end{document} 

Mapping the digits is accomplished in XeTeX at the font level, with the option Mapping=, like:

 \babelfont{rm}[Mapping=bengalidigits]{FreeSerif} 

This is actually a XeTeX feature and doesn't require babel. It can be used directly with fontspec.

Support in pdfTeX is based mainly on the velthuis package. An alternative for XeTeX is latexbangla, which relies on polyglossia.

### Finnish

Finnish language hyphenation is enabled with:

 \usepackage[finnish]{babel} 

This will also automatically change document language (section names, etc.) to Finnish.

### French

As of version 3.0 of babel-french, it is advised to choose the language as a global option with the following command[4]:

 \documentclass[french]{article} \usepackage{babel} 

Formerly, you could load French language support with the following command:

 \usepackage[frenchb]{babel} 

or

 \usepackage[francais]{babel} 

There are multiple options for typesetting French documents, depending on the flavor of French: french for Parisian French, and acadian and canadien for new-world French. If you do not know or do not really care, we would recommend using french.

All enable French hyphenation, if you have configured your LaTeX system accordingly. All of these also change all automatic text into French: \chapter prints Chapitre, \today prints the current date in French and so on. A set of new commands also becomes available, which allows you to write French input files more easily. Check out the following table for inspiration:

input code rendered output
\og guillemets \fg{} « guillemets »
M\up{me}, D\up{r} Mme, Dr
1\ier{}, 1\iere{}, 1\ieres{} 1er, 1re, 1res
2\ieme{} 4\iemes{} 2e 4es
\No 1, \no 2 N° 1, n° 2
20~\degres C, 45\degres 20 °C, 45°
M. \bsc{Durand} M. Durand
\nombre{1234,56789} 1 234,567 89

You may want to typeset guillemets and other French characters directly if your keyboard has them. Running Xorg (*BSD and GNU/Linux), you may want to use the oss variant which features some nice shortcuts, like

Key combination Character
Alt Gr + w «
Alt Gr + x »
Alt Gr + Shift + é É
Alt Gr + Shift + è È
Alt Gr + Shift + ç Ç

You will need the T1 font encoding for guillemets to print properly.

For the degree character you will get an error like

! Package inputenc Error: Unicode char \u8:° not set up for use with LaTeX.


The textcomp package will fix it for you.

The great advantage of Babel for French is that it will handle some elements of French typography for you, especially non-breaking spaces before all two-parts punctuation marks. So now you can write:

 Il répondit: «Ce pain coûte-t-il 2~€?» 

The non-breaking space before the euro symbol is still necessary because currency symbols and other units or not supported in general (that's not specific to French).

You can use the numprint package along Babel. It will let you print numbers the French way.

 \usepackage[french]{babel} \usepackage[autolanguage]{numprint} % Must be loaded *after* babel. % ... \nombre{123456.123456 e-17}  $123~456,123~456\cdot 10^{-17}$

You will also notice that the layout of lists changes when switching to the French language. This is customizable using the \frenchsetup command. For more information on what the french option of babel does and how you can customize its behavior, run LaTeX on file frenchb.dtx and read the produced file frenchb.pdf or frenchb.dvi. You can get the PDF version on CTAN.

### German

You can load German language support using either one of the two following commands (pdfTeX, XeTeX and LuaTeX are supported).

For traditional ("old") German orthography use

 \usepackage[german]{babel} 

or for reform ("new") German orthography use

 \usepackage[ngerman]{babel} 

This enables German hyphenation, if you have configured your LaTeX system accordingly. It also changes all automatic text into German, e.g. “Chapter” becomes “Kapitel”. A set of new commands also becomes available, which allows you to write German input files more quickly even when you don't use the inputenc package. Check out the table below for inspiration. With inputenc, all this becomes moot, but your text also is locked in a particular encoding world.

 "A "O "U Ä Ö Ü "a "o "u "s ä ö ü ß " or \glqq „ "' or \grqq “ \glq \grq "< or \flqq « "> or \frqq » \flq \frq ‹ › \dq "

In German books you sometimes find French quotation marks («guillemets»). German typesetters, however, use them differently. A quote in a German book would look like »this«. In the German speaking part of Switzerland, typesetters use «guillemets» the same way the French do. A major problem arises from the use of commands like \flq: If you use the OT1 font encoding (which is the default) the guillemets will look like the math symbol "$\ll$ ", which turns a typesetter's stomach. T1 encoded fonts, on the other hand, do contain the required symbols. So if you are using this type of quote, make sure you use the T1 encoding.

Decimal numbers usually have to be written like 0{,}5 (not just 0,5). Packages like ziffer enable input like 0,5. Alternatively, one can use the \num command from the babel and (globally) set the decimal marker using

 \usepackage[output-decimal-marker={,}]{siunitx} % ... \num{0,5}  $0{,}5$

### Greek

This is the preamble you need to write in the Greek language.

 \usepackage[greek]{babel} 

This preamble enables hyphenation and changes all automatic text to Greek. A set of new commands also becomes available, which allows you to write Greek input files more easily.

Modern Monotonic Greek, as well as Polytonic and Ancient Greek are supported.

If you need a language in the Latin script and you are using LuaTeX, you can switch automatically the font in the following way, with no explicit markup:

 \documentclass{book} \usepackage[portuguese, greek]{babel} \babelprovide[onchar=ids fonts]{portuguese} \babelfont{rm}{FreeSerif} \babelfont[portuguese]{rm}{DejaVu Sans} \begin{document} abelha -- μελισσα \end{document} 

There is a dedicated package for XeTeX named xgreek.

### Hungarian

Use the following lines:

 \usepackage[magyar]{babel} 

### Icelandic and Faroese

The following lines can be added to write Icelandic text:

 \usepackage[icelandic]{babel} 

This changes text like Part into Hluti. It makes additional commands available:

 " or \glqq „ \grqq “ \TH Þ \th þ \DH Ð \dh ð

To make special characters such as Þ and Æ become available just add:

 \usepackage[T1]{fontenc} 

The default LATEX font encoding is OT1, but it contains only the 128 characters. The T1 encoding contains letters and punctuation characters for most of the European languages using Latin script.

### Italian

Italian is well supported by LaTeX. Just add

 \usepackage[italian]{babel} 

at the beginning of your document and the output of all the commands will be translated properly.

### Norwegian

Norwegian is well supported by LaTeX. Just add

 \usepackage[norsk]{babel} 

at the beginning of your document and the output of all the commands will be translated properly.

### Japanese

#### jlreq

The package provides the class file and JFM (Japanese font metric) files for LuaTeX-ja / pLaTeX / upLaTeX. This aims to implement Requirements for Japanese Text Layout.

#### upTeX, pTeX

There is a variant of TeX intended for Japanese named upTeX, which supports vertical typesetting.

#### luatexja

Another possible way to write in japanese is to use Lualatex and the luatex-ja package. Adapted example from the Luatexja documentation :

 \documentclass{ltjsarticle} \usepackage{luatexja} % This line is unnecessary when using ltjclasses or ltjsclasses. \begin{document} \section{はじめてのLua\TeX-ja} ちゃんと日本語が出るかな？ \subsection{出たかな？} 長い文章を入力するとちゃんと右端のところで折り返されるかな？ 大丈夫そうな気がするけど．ちょっと不安だけど何事も挑戦だよね． \end{document} 

You can also use capabilities provided by the fontspec package and those provided by luatexja-fontspec to declare the font you want to use in your paper. Let us take an example:

 % ********************************** % Basic setup \documentclass[10pt,a4paper]{article} \usepackage{fontspec} \setmainfont[Numbers={OldStyle,Proportional}]{Arno Pro} %setup of western font \usepackage{luatexja} \usepackage{luatexja-fontspec}%needed to call \setmainjfont bellow \setmainjfont[BoldFont=KozGoPr6N-Bold]{KozGoPr6N-Regular} %setup of japanese font %*********************************** \begin{document} It is a test to show japanese and english mix. テスト中です。どうですか皆さん。 \end{document} 

Use UTF-8 as your encoding. In case you don't know how to do this, take a look at Texmaker, a LaTeX editor which uses UTF-8 by default.

luatex-ja can collaborate with babel. For example:

 \documentclass{ltjbook} \usepackage[ngerman,japanese]{babel} 

For short Japanese texts (a few words or a few paragraphs) in a document in another language, babel (≥3.31) with luatex could be enough; eg:

 \usepackage[ngerman]{babel} \babelprovide[import]{japanese} \babelfont[japanese]{rm}{IPAMincho} 

For hyperref package to show the Table of Contents correctly, the encoding has to be explicitly specified.

 \usepackage[unicode=true]{hyperref} 

#### CJK, XeCJK, bxcjkjatype

Another (but old) possible Japanese support is made available thanks to the CJK or XeCJK package collection. If you are using a package manager or a portage tree, the CJK collection is usually in a separate package because of its size (mainly due to fonts).

Make sure your document is saved using the UTF-8 character encoding. See Special Characters for more details. Put the parts where you want to write japanese characters in a CJK environment.

 \documentclass{article} \usepackage{CJK} \begin{document} \begin{CJK}{UTF8}{min} こんにちは You can mix latin letters as well as hiragana, katakana and kanji. \end{CJK} \end{document} 

The last argument specifies the font. It must fit the desired language, since fonts are different for Chinese, Japanese and Korean. min is an example for Japanese.

The bxcjkjatype pack­age pro­vides a work­ing con­fig­u­ra­tion of the CJK pack­age, suit­able for Ja­panese type­set­ting of mod­er­ate qual­ity. More­over, it fa­cil­i­tates use of the CJK pack­age for pLATEX users, by pro­vid­ing com­mands that are sim­i­lar to those used by the pLATEX ker­nel and some other pack­ages used with it.

 \documentclass[pdflatex,ja=standard]{bxjsarticle} \begin{document} 吾輩は猫である。名前はまだ無い。 どこで生れたかとんと見当がつかぬ。 何でも薄暗いじめじめした所で ニャーニャー泣いていた事だけは記憶している。 吾輩はここで始めて人間というものを見た。 \end{document} 

### Korean

The two most widely used encodings for Korean text files are EUC-KR and its upward compatible extension used in Korean MS-Windows, CP949/Windows-949/UHC. In these encodings each US-ASCII character represents its normal ASCII character similar to other ASCII compatible encodings such as ISO-8859-x, EUC-JP, Big5, or Shift_JIS. On the other hand, Hangul syllables, Hanjas (Chinese characters as used in Korea), Hangul Jamos, Hiraganas, Katakanas, Greek and Cyrillic characters and other symbols and letters drawn from KS X 1001 are represented by two consecutive octets. The first has its MSB set. Until the mid-1990's, it took a considerable amount of time and effort to set up a Korean-capable environment under a non-localized (non-Korean) operating system. You can skim through the now much-outdated http://jshin.net/faq to get a glimpse of what it was like to use Korean under non-Korean OS in mid-1990's.

TeX and LaTeX were originally written for scripts with no more than 256 characters in their alphabet. To make them work for languages with considerably more characters such as Korean or Chinese, a subfont mechanism was developed. It divides a single CJK font with thousands or tens of thousands of glyphs into a set of subfonts with 256 glyphs each.

For Korean, there are three widely used packages.

• HLATEX by UN Koaunghi
• hLATEXp by CHA Jaechoon
• the CJK package by Werner Lemberg

HLATEX and hLATEXp are specific to Korean and provide Korean localization on top of the font support. They both can process Korean input text files encoded in EUC-KR. HLATEX can even process input files encoded in CP949/Windows-949/UHC and UTF-8 when used along with Λ, Ω.

The CJK package is not specific to Korean. It can process input files in UTF-8 as well as in various CJK encodings including EUC-KR and CP949/Windows-949/UHC, it can be used to typeset documents with multilingual content (especially Chinese, Japanese and Korean). The CJK package has no Korean localization such as the one offered by HLATEX and it does not come with as many special Korean fonts as HLATEX.

The ultimate purpose of using typesetting programs like TeX and LaTeX is to get documents typeset in an aesthetically satisfying way. Arguably the most important element in typesetting is a set of welldesigned fonts. The HLATEX distribution includes UHC PostScript fonts of 10 different families and Munhwabu fonts (TrueType) of 5 different families. The CJK package works with a set of fonts used by earlier versions of HLATEX and it can use Bitstream's cyberbit True-Type font.

To use the HLATEX package for typesetting your Korean text, put the following declaration into the preamble of your document:

 \usepackage{hangul} 

This command turns the Korean localization on. The headings of chapters, sections, subsections, table of content and table of figures are all translated into Korean and the formatting of the document is changed to follow Korean conventions. The package also provides automatic particle selection. In Korean, there are pairs of post-fix particles grammatically equivalent but different in form. Which of any given pair is correct depends on whether the preceding syllable ends with a vowel or a consonant. (It is a bit more complex than this, but this should give you a good picture.) Native Korean speakers have no problem picking the right particle, but it cannot be determined which particle to use for references and other automatic text that will change while you edit the document. It takes a painstaking effort to place appropriate particles manually every time you add/remove references or simply shuffle parts of your document around. HLATEX relieves its users from this boring and error-prone process.

In case you don't need Korean localization features but just want to typeset Korean text, you can put the following line in the preamble, instead.

 \usepackage{hfont} 

For more details on typesetting Korean with HLATEX, refer to the HLATEX Guide. Check out the web site of the Korean TeX User Group (KTUG).

In the FAQ section of KTUG it is recommended to use the kotex package

 \usepackage{kotex} 

### Persian script

For Persian language, there is a dedicated package called XePersian which uses XeLaTeX as the typesetting engine. Just add the following code to your preamble:

 \usepackage{xepersian} 

Moreover, Arabic script can be used to type Persian as illustrated in the corresponding section.

### Polish

If you plan to use Polish in your encoded document, use the following code:

 \usepackage{polski} \usepackage[polish]{babel} 

The above code merely allows to use Polish letters and translates the automatic text to Polish, so that "chapter" becomes "rozdział". There are a few additional things one must remember about.

#### Connectives

Polish has many single letter connectives: "a", "o", "w", "i", "u", "z", etc., grammar and typography rules don't allow for them to end a printed line. To ensure that LaTeX won't set them as last letter in the line, you have to use non breakable space:

 Noc była sierpniowa, ciepła i~słodka, Księżyc oświecał srebrnem światłem wgłębienie, tak, że twarze małego rycerza i~Basi były skąpane w blasku. Poniżej, na podwórzu zamkowem, widać było uśpione kupy żołnierzy, a~także i~ciała zabitych podczas dziennej strzelaniny, bo nie znaleziono dotąd czasu na ich pogrzebanie. 

Babel (>=3.58) with LuaTeX provides a transform for this purpose, without explicit markup, which is activated with:

 \babelprovide[transforms = oneletter.nobreak]{polish} 

#### Numerals

According to Polish grammar rules, you have to put dots after numerals in chapter, section, subsection, etc. headers.

This is achieved by redefining few LaTeX macros.

For books:


For articles:


Alternatively you can use dedicated document classes:

• the mwart class instead of article,
• and mwrep instead of report.

Those classes have much more European typography settings but do not require the use of Polish babel settings or character encoding.

Simple usage:

 \documentclass{mwart} \usepackage[polish]{babel} \usepackage{polski} \begin{document} Pójdź kińże tę chmurność w głąb flaszy. \end{document} 

Full documentation for those classes is available at http://web.archive.org/web/20040609034031/http://www.ci.pwr.wroc.pl/~pmazur/LaTeX/mwclsdoc.pdf (Polish).

#### Indentation

It may be customary (depending on publisher) to indent the first paragraph in sections and chapters:

 \usepackage{indentfirst} 

#### Hyphenation and typography

It's much more frowned upon to set pages with hyphenation between pages than it is customary in American typesetting.

To adjust penalties for hyphenation spanning pages, use this command:

 \brokenpenalty=1000 

To adjust penalties for leaving widows and orphans (clubs in TeX nomenclature) use those commands:

 \clubpenalty=1000 \widowpenalty=1000 

#### Commas in math

According to some typography rules, fractional parts of numbers should be delimited by a comma, not a dot. To make LaTeX not insert additional space in math mode after a comma (unless there is a space after the comma), use the icomma package.

 \usepackage{icomma} 

Unfortunately, it is partially incompatible with the dcolumn package. One needs to either use dots in columns with numerical data in the source file and make dcolumn switch them to commas for display or define the column as follows:

 \begin{tabular}{... D{,}{\mathord\mathcomma}{2} ...} 

The alternative is to use the numprint package, but it is much less convenient.

Another alternative is using package siunitx that lets you typeset numbers and their according units consistently. Number alignment in tables and different output modes re supported.

#### Further information

Refer the Słownik Ortograficzny (in Polish) for additional information on Polish grammar and typography rules.

### Portuguese

 \usepackage[portuguese]{babel} 

You can substitute the language for brazilian portuguese by choosing brazilian or brazil.

### Slovak

Basic settings are fine when left the same as Czech, but Slovak needs special signs for 'ď', 'ť', 'ľ'. To be able to type them from keyboard use the following settings:

 \usepackage[slovak]{babel} \usepackage[T1]{fontenc} 

### Spanish

Include the appropriate Babel option:

 \usepackage[spanish]{babel} 

The trick is that Spanish has several options and commands to control the layout. The options may be loaded either at the call to Babel, or before, by defining the command \spanishoptions. Therefore, the following commands are roughly equivalent:

 \def\spanishoptions{mexico} \usepackage[spanish]{babel} 
 \usepackage[spanish,mexico]{babel} 

On average, the former syntax should be preferred, as the latter is not recognized by some programs (LyX, latex2rtf) interacting with LaTeX.

Spanish also defines shorthands for the dot and << >> so that they are used as logical markup: the former is used as decimal marker in math mode, and the output is typically either a comma or a dot; the latter is used for quoted text, and the output is typically either «» or “”. This allows different typographical conventions with the same input, as preferences may be quite different from, say, Spain and Mexico.

Two particularly useful options are es-noquoting,es-nolists: some packages and classes are known to collide with Spanish in the way they handle active characters, and these options disable the internal workings of Spanish to allow you to overcome these common pitfalls. Moreover, these options may simplify the way LyX customizes some features of the Spanish layout from inside the GUI.

The options mexico,mexico-com provide support for local custom in Mexico: the former using decimal dot, as customary, and the latter allowing decimal comma, as formerly required by the Mexican Official Norm (NOM) of the Department of Economy for labels in foods and goods. More localizations are in the making.

The other commands modify the Spanish layout after loading Babel. Two particularly useful commands are \spanishoperators and \spanishdeactivate.

The macro \spanishoperators{<list of operators>}{ contains a list of spanish mathematical operators, and may be redefined at will. For instance, the command

 \def\spanishoperators{sen} 

only defines sen, overriding all other definitions; the command \let\spanishoperators\relax disables them all. This command supports accented or spaced operators: the \acute{<letter>} command puts an accent, and the \, command adds a small space. For instance, the following operators are defined by default.

 l\acute{i}m l\acute{i}m\,sup l\acute{i}m\,inf m\acute{a}x \acute{i}nf m\acute{i}n sen tg arc\,sen arc\,cos arc\,tg cotg cosec senh tgh 

Finally, the macro \spanishdeactivate{<list of characters>} disables some active characters, to keep you out of trouble if they are redefined by other packages. The candidates for deactivation are the set {<>."'}. Please, beware that some option preempt the availability of some active characters. In particular, you should not combine the es-noquoting option with \spanishdeactivate{<>}, or the es-noshorthands with \spanishdeactivate{<>."}.

Please check the documentation for Babel or spanish.dtx for further details.

### Thai

Both babel (luatex and xetex) and polyglossia (only xetex) support Thai. Word division in luatex is based on the standard hyphenation mechanism, so that patterns can be modified with \babelpatterns, while xetex relies on its own built-in mechanism. In pdftex you need an external tool for word segmentation (like swath). An example with babel (luatex and xetex) is:

 \documentclass{book} \usepackage{babel} \babelprovide[main, import]{thai} \babelfont{rm}{FreeSerif} \begin{document} ปัจจุบันข้าวและพริกเป็นส่วนประกอบสำคัญที่สุดของอาหารไทย \end{document} 

### Tibetan

One option to use Tibetan script in LaTeX is to add

 \usepackage{ctib} 

to your preamble and use a slightly modified Wylie transliteration for input. Refer to the excellent package documentation for details. More information can be found on [9]

### Vietnamese

The following preamble could be used to directly type Vietnamese (xetex or luatex).

 \documentclass{article} \usepackage{fontspec}% \setmainfont[Ligatures=TeX]{Linux Libertine O} 

For a document written in this language:

 \documentclass{article} \usepackage[vietnamese]{babel} 

## References

1. Babel: The multilingual framework to localize LaTeX, LuaLaTeX, XeLaTeX
2. The Not So Short Introduction to LaTeX, 2.5.6 Support for Cyrillic, Maksym Polyakov
3. The Not So Short Introduction to LaTeX, Bulgarian translation
4. babel-french documentation: "the French language should now be loaded as french, not as frenchb or francais and preferably as a global option of \documentclass. Some tolerance still exists in v3.0, but do not rely on it."

# Rotations

## The rotating package

The package rotating gives you the possibility to rotate any object of an arbitrary angle. Once you have loaded it with the standard command in the preamble:

 \usepackage{rotating} 

you can use three new environments:

 \begin{sideways} 

it will rotate the whole argument by 90 degrees counterclockwise. Moreover:

 \begin{turn}{30} 

it will turn the argument of 30 degrees. You can give any angle as an argument, whether it is positive or negative. It will leave the necessary space to avoid any overlapping of text.

 \begin{rotate}{30} 

like turn, but it will not add any extra space.

If you want to make a float sideways so that the caption is also rotated, you can use

 \begin{sidewaysfigure} 

or

 \begin{sidewaystable} 

Note, though, they will be placed on a separate page.

If you would like to rotate a TikZ picture you could use sideways together with minipage.

 \begin{figure} \begin{sideways} \begin{minipage}{17.5cm} \input{../path/to/picture} \end{minipage} \end{sideways} \centering \caption[Caption]{Caption.} \label{pic:picture} \end{figure} 

You can also use the \rotatebox command. Let's rotate a tabular inside a table for example:

 \begin{table}[p] \centering \rotatebox{90}{ \begin{minipage}{\textheight} \begin{tabular}{ 

### Options

Default is sidewaysfigures/sidewaystables are oriented depending on page number in two-sided documents (takes two passes).

The rotating package takes the following options.

counterclockwise/anticlockwise
In single-sided documents turn sidewaysfigures/sidewaystables counterclockwise.
clockwise
In single-sided documents turn sidewaysfigures/sidewaystables clockwise (default).
figuresright
In two-sided documents all sidewaysfigures/sidewaystables are same orientation (left of figure, table now bottom of page). This is the style preferred by the Chicago Manual of Style (broadside).
figuresleft
In two-sided documents all sidewaysfigures/sidewaystables are same orientation (left of figure, table now at top of page).

## The rotfloat package

When it is desirable to place the rotated table at the exact location where it appears in the source (.tex) file, rotfloat package may be used. Then one can use

 \begin{sidewaystable}[H] 

just like for normal tables. The H option can not be used without this package.

# Tables

Tables are a common feature in academic writing, often used to summarize research results. Mastering the art of table construction in LaTeX is therefore necessary to produce quality papers and with sufficient practice one can print beautiful tables of any kind.

Keeping in mind that LaTeX is not a spreadsheet, it makes sense to use a dedicated tool to build tables and then to export these tables into the document. Basic tables are not too taxing, but anything more advanced can take a fair bit of construction; in these cases, more advanced packages can be very useful. However, first it is important to know the basics. Once you are comfortable with basic LaTeX tables, you might have a look at more advanced packages or the export options of your favorite spreadsheet. Thanks to the modular nature of LaTeX, the whole process can be automated in a fairly comfortable way.

## Introduction

LaTeX has built-in support to typeset tables and provides two environments: tabular and table. To typeset material in rows and columns, the tabular environment is needed; the optional table environment is a container for floating material similar to figure, into which a tabular environment may be included.

The table environment contains the caption and defines the float for the table, i.e., where in the document the table should be positioned and whether we want it to be displayed centered. The \caption and \label commands can be used in the same way as for pictures. For more information about the table environment, see the Floating with table section.

In any case, the actual content of the table is contained within the tabular environment.

## The tabular environment

The tabular environment can be used to typeset tables with optional horizontal and vertical lines. LaTeX determines the width of the columns automatically.

The first line of the environment has the form:

 \begin{tabular}[pos]{table spec} 

The table spec argument tells LaTeX the alignment to be used in each column and the vertical lines to insert.

The number of columns does not need to be specified as it is inferred by looking at the number of arguments provided. It is also possible to add vertical lines between the columns here. The following symbols are available to describe the table columns (some of them require that the package array has been loaded):

 l left-justified column c centered column r right-justified column p{'width'} paragraph column with text vertically aligned at the top m{'width'} paragraph column with text vertically aligned in the middle (requires array package) b{'width'} paragraph column with text vertically aligned at the bottom (requires array package) | vertical line || double vertical line

By default, if the text in a column is too wide for the page, LaTeX won’t automatically wrap it. Using p{'width'} you can define a special type of column which will wrap-around the text as in a normal paragraph. You can pass the width using any unit supported by LaTeX, such as 'pt' and 'cm', or command lengths, such as \textwidth. You can find a list in chapter Lengths.

The optional parameter pos can be used to specify the vertical position of the table relative to the baseline of the surrounding text. In most cases, you will not need this option. It becomes relevant only if your table is not in a paragraph of its own. You can use the following letters:

 b bottom c center (default) t top

To specify a font format (such as bold, italic, etc.) for an entire column, you can add >{\format} before you declare the alignment. For example \begin{tabular}{ >{\bfseries}l c >{\itshape}r } will indicate a three column table with the first one aligned to the left and in bold font, the second one aligned in the center and with normal font, and the third aligned to the right and in italic. The "array" package needs to be activated in the preamble for this to work.

In the first line you have pointed out how many columns you want, their alignment and the vertical lines to separate them. Once in the environment, you have to introduce the text you want, separating between cells and introducing new lines. The commands you have to use are the following:

 & column separator \\ start new row (additional space may be specified after \\ using square brackets, such as \\[6pt]) \hline horizontal line \newline start a new line within a cell (in a paragraph column) \cline{i-j} partial horizontal line beginning in column i and ending in column j

Note, any white space inserted between these commands is purely down to one's preferences. I personally add spaces between to make it easier to read.

### Basic examples

This example shows how to create a simple table in LaTeX. It is a three-by-three table, but without any lines.

 \begin{tabular}{ l c r } 1 & 2 & 3 \\ 4 & 5 & 6 \\ 7 & 8 & 9 \\ \end{tabular}  ${\begin{array}{lcr}1&2&3\\4&5&6\\7&8&9\\\end{array}}$

Expanding upon that by including some vertical lines:

 \begin{tabular}{ l | c | r } 1 & 2 & 3 \\ 4 & 5 & 6 \\ 7 & 8 & 9 \\ \end{tabular}  ${\begin{array}{l|c||r}1&2&3\\4&5&6\\7&8&9\\\end{array}}$

To add horizontal lines to the very top and bottom edges of the table:

 \begin{tabular}{ l | c | r } \hline 1 & 2 & 3 \\ 4 & 5 & 6 \\ 7 & 8 & 9 \\ \hline \end{tabular}  ${\begin{array}{l|c||r}\hline 1&2&3\\4&5&6\\7&8&9\\\hline \end{array}}$

And finally, to add lines between all rows, as well as centering (notice the use of the center environment - of course, the result of this is not obvious from the preview on this web page):

 \begin{center} \begin{tabular}{ l | c | r } \hline 1 & 2 & 3 \\ \hline 4 & 5 & 6 \\ \hline 7 & 8 & 9 \\ \hline \end{tabular} \end{center}  ${\begin{array}{l|c||r}\hline 1&2&3\\\hline 4&5&6\\\hline 7&8&9\\\hline \end{array}}$
 \begin{center} \begin{tabular}{ | l | c | r } \hline 1 & 2 & 3 \\ \hline 4 & 5 & 6 \\ \hline 7 & 8 & 9 \\ \hline \end{tabular} \end{center}  ${\begin{array}{|l||c|||r}\hline 1&2&3\\\hline 4&5&6\\\hline \hline 7&8&9\\\hline \end{array}}$
 \begin{tabular}{|r|l|} \hline 7C0 & hexadecimal \\ 3700 & octal \\ \cline{2-2} 11111000000 & binary \\ \hline \hline 1984 & decimal \\ \hline \end{tabular} 

### Text wrapping in tables

LaTeX's algorithms for formatting tables have a few shortcomings. One is that it will not automatically wrap text in cells, even if it overruns the width of the page. For columns that will contain text whose length exceeds the column's desired width, it is recommended that you use the p attribute and specify the desired width of the column (although it may take some trial-and-error to get the result you want). For a more convenient method, have a look at The tabularx package, or The tabulary package.

Instead of p, use the m attribute to have the lines aligned toward the middle of the box or the b attribute to align along the bottom of the box.

Here is a simple example. The following code creates two tables with the same code; the only difference is that the last column of the second one has a defined width of 5 centimeters, while in the first one we didn't specify any width. Compiling this code:

 \documentclass{article} \usepackage[english]{babel} \begin{document} Without specifying width for last column: \begin{center} \begin{tabular}{| l | l | l | l |} \hline Day & Min Temp & Max Temp & Summary \\ \hline Monday & 11C & 22C & A clear day with lots of sunshine. However, the strong breeze will bring down the temperatures. \\ \hline Tuesday & 9C & 19C & Cloudy with rain, across many northern regions. Clear spells across most of Scotland and Northern Ireland, but rain reaching the far northwest. \\ \hline Wednesday & 10C & 21C & Rain will still linger for the morning. Conditions will improve by early afternoon and continue throughout the evening. \\ \hline \end{tabular} \end{center} With width specified: \begin{center} \begin{tabular}{ | l | l | l | p{5cm} |} \hline Day & Min Temp & Max Temp & Summary \\ \hline Monday & 11C & 22C & A clear day with lots of sunshine. However, the strong breeze will bring down the temperatures. \\ \hline Tuesday & 9C & 19C & Cloudy with rain, across many northern regions. Clear spells across most of Scotland and Northern Ireland, but rain reaching the far northwest. \\ \hline Wednesday & 10C & 21C & Rain will still linger for the morning. Conditions will improve by early afternoon and continue throughout the evening. \\ \hline \end{tabular} \end{center} \end{document} 

You get the following output:

Note that the first table has been cropped, since the output is wider than the page width.

### Manually broken paragraphs in table cells

Sometimes it is necessary to not rely on the breaking algorithm when using the p specifier, but rather specify the line breaks by hand. In this case it is easiest to use a \parbox:

 \begin{tabular}{cc} boring cell content & \parbox[t]{5cm}{rather long par\\new par} \end{tabular} 

Here the t argument controls the placement of the text inside the box. Other allowed values are c for center and b for bottom.

### Space between columns

To tweak the space between columns (LaTeX will by default choose very tight columns), one can alter the column separation: \setlength{\tabcolsep}{5pt}. The default value is 6pt.

One can also introduce a horizontal space with hspace like this: \begin{tabular}{r@{\hspace{1in}}rr} There are different options for the hspace length.

### Space between rows

Re-define the \arraystretch command to set the space between rows:

 \renewcommand{\arraystretch}{1.5} 

Default value is 1.0.

An alternative way to adjust the rule spacing is to add \noalign{\smallskip} before or after the \hline and \cline{i-j} commands:

 \usepackage{array} %or \usepackage{dcolumn} ... \begin{tabular}{llr} \firsthline \multicolumn{2}{c}{Item} \\ \cline{1-2} Animal & Description & Price (\$) \\ \hline Gnat & per gram & 13.65 \\ & each & 0.01 \\ Gnu & stuffed & 92.50 \\ Emu & stuffed & 33.33 \\ Armadillo & frozen & 8.99 \\ \lasthline \end{tabular}  ### Using booktabs  \usepackage{booktabs} \begin{tabular}{llr} \toprule \multicolumn{2}{c}{Item} \\ \cmidrule(r){1-2} Animal & Description & Price (\$) \\ \midrule Gnat & per gram & 13.65 \\ & each & 0.01 \\ Gnu & stuffed & 92.50 \\ Emu & stuffed & 33.33 \\ Armadillo & frozen & 8.99 \\ \bottomrule \end{tabular} 

Usually the need arises for footnotes under a table (and not at the bottom of the page), with a caption properly spaced above the table. These are addressed by the ctable package. It provides the option of a short caption given to be inserted in the list of tables, instead of the actual caption (which may be quite long and inappropriate for the list of tables). The ctable uses the booktabs package.

## Sideways tables

Tables can also be put on their side within a document using the rotating or the rotfloat package. See the Rotations chapter.

## Table with legend

To add a legend to a table the caption package can be used. With the caption package a \caption*{...} statement can be added besides the normal \caption{...}. Example:

 \begin{table} \begin{tabular}{| r | r || c | c | c |} ... \end{tabular} \caption{A normal caption} \caption*{ A legend, even a table can be used \begin{tabular}{l l} item 1 & explanation 1 \\ \end{tabular} } \end{table} 

The normal caption is needed for labels and references.

## The eqparbox package

On rare occasions, it might be necessary to stretch every row in a table to the natural width of its longest line, for instance when one has the same text in two languages and wishes to present these next to each other with lines synching up. A tabular environment helps control where lines should break, but cannot justify the text, which leads to ragged right edges. The eqparbox package provides the command \eqmakebox which is like \makebox but instead of a width argument, it takes a tag. During compilation it bookkeeps which \eqmakebox with a certain tag contains the widest text and can stretch all \eqmakeboxes with the same tag to that width. Combined with the array package, one can define a column specifier that justifies the text in all lines:comand

 \newsavebox{\tstretchbox} \newcolumntype{S}[1]{% >{\begin{lrbox}{\tstretchbox} }% l% <{\end{lrbox}% \eqmakebox[#1][s]{\unhcopy\tstretchbox} }% } 

See the documentation of the eqparbox package for more details.

## The paracol package

The various tabular environments available for LaTeX are feature rich; however, they lack the ability to automatically page break large rows. The paracol package provides automatic page breaks in between rows and in certain cases can replace the tabular environment. Such situations could be common in documents that require translations and definitions, which may also includes lists.

For further detail see the documentation of the paracol package.

## Floating with table

In WYSIWYG document processors, it is common to put tables in the middle of the text. This is what we have been doing until now. Professional documents, however, often make it a point to print tables on a dedicated page so that they do not disrupt the flow. From the point of view of the source code, one has no idea on which page the current text is going to lie, so it is hardly possible to guess which page may be appropriate for our table. LaTeX can automate this task by abstracting objects such as tables, pictures, etc., and deciding for us where they might fit best. This abstraction is called a float. Generally, an object that is floated will appear in the vicinity of its introduction in the source file, but one can choose to control its position also.

To tell LaTeX we want to use our table as a float, we need to put a table environment around the tabular environment, which is able to float and add a label and caption.

The table environment initiates a type of float just as the environment figure. In fact, the two bear a lot of similarities (positioning, captions, etc.). More information about floating environments, captions etc. can be found in Floats, Figures and Captions.

The environment names may now seem quite confusing. Let's sum it up:

• tabular is for the content itself (columns, lines, etc.).
• table is for the location of the table on the document, plus caption and label support.
 \begin{table}[position specifier] \centering \begin{tabular}{|l|} ... your table ... \end{tabular} \caption{This table shows some data} \label{tab:myfirsttable} \end{table} 

In the table, we used a label, so now we can refer to it just like any other reference:

 \ref{tab:myfirsttable} 

The table environment is also useful when you want to have a list of tables at the beginning or end of your document with the command

 \listoftables 

The captions now show up in the list of tables, if displayed.

You can set the optional parameter position specifier to define the position of the table, where it should be placed. The following characters are all possible placements. Using sequences of it define your "wishlist" to LaTeX.

 h where the table is declared (here) t at the top of the page b at the bottom of the page p on a dedicated page of floats ! override the default float restrictions. E.g., the maximum size allowed of a b float is normally quite small; if you want a large one, you need this ! parameter as well.

Default is tbp, which means that it is by default placed on the top of the page. If that's not possible, it's placed at the bottom if possible, or finally with other floating environments on an extra page.

You can force LaTeX to use one given position. E.g. [!h] forces LaTeX to place it exactly where you place it (Except when it's really impossible, e.g you place a table here and this place would be the last line on a page). Again, understand it correctly: it urges LaTeX to put the table at a specific place, but it will not be placed there if LaTeX thinks it will not look great. If you really want to place your table manually, do not use the table environment.

Centering the table horizontally works like everything else, using the \centering command just after opening the table environment, or by enclosing it with a center environment.

## Using spreadsheets and data analysis tools

For complex or dynamic tables, you may want to use a spreadsheet. You might save lots of time by building tables using specialized software and exporting them in LaTeX format. The following plugins and libraries are available for some popular software:

However, copying the generated source code to your document is not convenient at all. For maximum flexibility, generate the source code to a separate file which you can input from your main document file with the \input command. If your spreadsheet supports command-line, you can generate your complete document (table included) in one command, using a Makefile for example.

See Modular Documents for more details.

## Need more features?

Have a look at one of the following packages:

• hhline: do whatever you want with horizontal lines
• array: gives you more freedom on how to define columns
• colortbl: make your table more colorful
• threeparttable makes it possible to put footnotes both within the table and its caption
• arydshln: creates dashed horizontal and vertical lines
• ctable: allows for footnotes under table and properly spaced caption above (incorporates booktabs package)
• slashbox: create 2D tables with the first cell containing a description for both axes. Not available in Tex Live 2011 or later.
• diagbox: compatible to slashbox, come with Tex Live 2011 or later
• dcolumn: decimal point alignment of numeric cells
• rccol: advanced decimal point alignment of numeric cells with rounding
• numprint: print numbers, in the current mode (text or math) in order to use the correct font, with separators, exponent and/or rounded to a given number of digits. tabular(*), array, tabularx, and longtable environments are supported using all features of numprint
• siunitx: alignment of tabular entries
• pgfplotstable: loads, rounds, formats and postprocesses numerical tables, e.g. by importing the data directly from .csv (comma-separated value) files instead of manually writing the whole tables in LaTeX code. Programs such as Excel, LibreOffice Calc etc. can export data sheets as .csv files.

## References

1. Package multirow on CTAN

# Title creation

For documents such as basic articles, the output of \maketitle is often adequate, but longer documents (such as books and reports) often require more involved formatting. We will detail the process here.

There are several situations where you might want to create a title in a custom format, rather than in the format natively supported by LaTeX classes. While it is possible to change the output of \maketitle, it can be complicated even with minor changes to the title. In such cases it is often better to create the title from scratch, and this section will show you how to accomplish this.

## Standard Titles

Most document classes provide a simple interface to store details to be represented in the title and to typeset the actual title. The standard classes provide just four storing commands (\title, \author \thanks and \date). You can store any information you want to be shown in the title, including formatting.

The actual title will be typeset by issuing the command \maketitle. The layout is defined by the documentclass in use.

 \documentclass{article}% use option titlepage to get the title on a page of its own. \usepackage{blindtext} \title{The Triangulation of Titling Data in Non-Linear Gaussian Fashion via $\rho$ Series\thanks{No procrastination}} \date{2017\\ December} \author{John Doe\\ Magic Department\thanks{I am no longer a member of this department}, Richard Miles University \and Richard Row, \LaTeX\ Academy} \begin{document} \maketitle \section{Introduction} \blindtext \end{document} 

The command \thanks will store content, which will produce a footnote along with the title. As the name suggests, it can be used to thank someone. Or just to print an email address or similar in a footnote.

The authors are separated by the command \and, allowing author blocks to be output next to each other. In the example above, there is not enough horizontal space to fit both authors on the same line.

If \date was not defined, LaTeX will print the current date. If you want to omit the date completely, use \date{}, which stores an empty string.

The commands to store your title data can be used in the preamble. Since \maketitle does actual output, it needs to be used after \begin{document}. Usually, the title is the first thing in a document.

Please see examples for KOMA-script and memoir classes below. Both provide (different) commands to change the appearance of the title. Learn later how to completely design your own titlepage.

 \documentclass{scrbook} \setkomafont{author}{\scshape} \usepackage{blindtext} \title{How hard would it be to build a spaceship from scrap} \author{Carl Capybara\thanks{I never procrastinate} \and Walter Wombat} \subtitle{A closer look at the expenses} \subject{a funny paper} \begin{document} \maketitle \addchap{Introduction} \blindtext \end{document} 

 \documentclass{memoir}% use option titlepage to get the title on a page of its own. \usepackage{blindtext} \title{The influence of colour on the floating velocity of rubber ducks} \author{Peter Piranha} \renewcommand{\maketitlehookb}{\centering You won't expect the results} \begin{document} \maketitle \chapter{Introduction} \blindtext \end{document} 

As usual, the class documentation reveals more details about the possible commands.

## The title for journal submission

Journals follow a specific layout. To ensure this they often provide a template which defines the layout. What is available for the title (for example emails, affiliation names, keywords) heavily depends on the template and highly differs between different journals. Follow the template if the journal provides one. If they don't you should use the most basic concepts of LaTeX titles described above.

## Create a custom title for a report or book

The title page of a book or a report is the first thing a reader will see. Keep that in mind when preparing your title page.

You need to know very basic LaTeX layout commands in order to get your own title page perfect. Usually a custom titlepage does not contain any semantic markup, everything is hand crafted. Here are some of the most often needed things:

Alignment

If you want to center some text just use \centering. If you want to align it differently you can use the environment \raggedleft for right-alignment and \raggedright for left-alignment.

Images

The command for including images (a logo for example) is the following : \includegraphics[width=0.15\textwidth]{./logo}. There is no \begin{figure} as you would usually use since you don't want it to be floating, you just want it exactly where want it to be. When handling it, remember that it is considered like a big box by the TeX engine.

Text size

If you want to change the size of some text just place it within braces, {like this}, and you can use the following commands (in order of size): \Huge, \huge, \LARGE, \Large, \large, \normalsize, \small, \footnotesize, \tiny. So for example:

 {\large this text is slightly bigger than normal}, this one is not. 

Remember, if you have a block of text in a different size, even if it is a bit of text on a single line, end it with \par.

Filling the page

The command \vfill as the last item of your content will add empty space until the page is full. If you put it within the page, you will ensure that all the following text will be placed at the bottom of the page.

#### A practical example

All these tips might have made you confused. Here is a practical and compliable example. The picture in use comes with package mwe and should be available with every complete LaTeX installation. You can start testing right away.

 \documentclass[12pt,a4paper]{report} \usepackage{graphicx} \begin{document} \begin{titlepage} \centering \includegraphics[width=0.15\textwidth]{example-image-1x1}\par\vspace{1cm} {\scshape\LARGE Columbidae University \par} \vspace{1cm} {\scshape\Large Final year project\par} \vspace{1.5cm} {\huge\bfseries Pigeons love doves\par} \vspace{2cm} {\Large\itshape John Birdwatch\par} \vfill supervised by\par Dr.~Mark \textsc{Brown} \vfill % Bottom of the page {\large \today\par} \end{titlepage} \end{document} 

As you can see, the code looks "dirtier" than standard LaTeX source because you have to take care of the output as well. If you start changing fonts it gets even more complicated, but you can do it: it's only for the title and your complicated code will be isolated from all the rest within its own file.

The result is shown below

#### Integrating the title page

A title page for a book or a report to get a university degree {Bachelor, Master, Ph.D., etc.) is quite static, it doesn't really change over time. You can prepare the titlepage in its own little document and prepare a one page pdf that you later include into your real document. This is really useful, if the title page needs to have completely different margins compared to the rest of the document. It also saves compile time, though it is not much.

Assuming you have done the title page of your report in an extra document, let's pretend it is called reportTitlepage2016.pdf, you can include it quite simply. Here is a short document setup.

 \documentclass{report} \usepackage{pdfpages} \begin{document} \includepdf{reportTitlepage2016} \tableofcontents \chapter{Introducing birds} \end{document} 

## A title to be re-used multiple times

Some universities, departments and companies have strict rules how a title page of a report should look like. To ensure the very same output for all reports, a redefinition of the \maketitle command is recommended.

This is best done by an experienced LaTeX user. A simple example follows, as usual there is no real limit with respect to complexity.

As a starting point, a LaTeX package called columbidaeTitle.sty is generated that defines the complete title matter. It will later be hidden from the end user. Ideally, the person creating the package should maintain it for a long time, create an accompanying documentation and ensure user support.


This package can be loaded within a usual document. The user can set the variables for title and the like. Which commands are actually available, and which might be omissible should be written in a documentation that is bundled with the package.

Look around what happens if you leave one or the other command out.

 \documentclass{book} \usepackage{columbidaeTitle} %\supervisor{Dr. James Miller} \project{Bachelor Thesis} \author{A LaTeX enthusiast} \title{Why I want to be a duck} \begin{document} \maketitle \tableofcontents \chapter{Ducks are awesome} \end{document} 

## Packages for custom titles

The titling package[1] provides control over the typesetting of the \maketitle and \thanks commands. It is useful for small changes to the standard output.

Italian users may also want to use the frontespizio package[2]. It defines a frontispiece as used in Italy.

Package authblk [3] provides new means to typeset the authors. This is especially helpful for journal submissions without an available template.

## More titlepage examples

The titlepages package presents many different styles for title pages.

TeX.SE has a collection of titlepages.

Another small collection can be found on Github.

# Page Layout

LaTeX and the document class will normally take care of page layout issues for you. For submission to an academic publication, this entire topic will be out of your hands, as the publishers want to control the presentation. However, for your own documents, there are some obvious settings that you may wish to change: margins, page orientation and columns, to name but three. The purpose of this tutorial is to show you how to configure your pages.

We will often have to deal with TeX lengths in this chapter. You should have a look at Lengths for comprehensive details on the topic.

## Two-sided documents

Documents can be either one- or two-sided. Articles are by default one-sided, books are two-sided. Two-sided documents differentiate the left (even) and right (odd) pages, whereas one-sided do not. The most notable effect can be seen in page margins. If you want to make the article class two-sided, use \documentclass[twoside]{article}.

Many commands and variables in LaTeX take this concept into account. They are referred to as even and odd. For one-sided document, only the odd commands and variables will be in effect.

## Page dimensions

A page in LaTeX is defined by many internal parameters. Each parameter corresponds to the length of an element of the page, for example, \paperheight is the physical height of the page. Here you can see a diagram showing all the variables defining the page. All sizes are given in TeX points (pt), there are 72.27pt in an inch or 1pt ≈ 0.3515mm.

1. one inch + \hoffset
2. one inch + \voffset
3. \oddsidemargin = 31pt
4. \topmargin = 20pt
5. \headheight = 12pt
6. \headsep = 25pt
7. \textheight = 592pt
8. \textwidth = 390pt
9. \marginparsep = 10pt
10. \marginparwidth = 35pt
11. \footskip = 30pt
• \marginparpush = 7pt (not shown)
• \hoffset = 0pt
• \voffset = 0pt
• \paperwidth = 597pt
• \paperheight = 845pt

The current details plus the layout shape can be printed from a LaTeX document itself. Use the layout package and the command of the same name: \usepackage{layout} ... \layout{}

To render a frame marking the margins of a document you are currently working on, add

\usepackage{showframe}


to the document.

## Page size

It will not have been immediately obvious - because it doesn't really cause any serious problems - that the default page size for all standard document classes is US letter. This is shorter by 18 mm (about 3/4 inch), and slightly wider by 8 mm (about 1/4 inch), compared to A4 (which is the standard in almost all the rest of the world). While this is not a serious issue (most printers will print the document without any problems), it is possible to specify alternative sizes as class option. For A4 format:

 \documentclass[a4paper]{article} 

### More size options with geometry

One of the most versatile packages for page layout is the geometry package. The immediate advantage of this package is that it lets you customize the page size even with classes that do not support the options. For instance, to set the page size, add the following to your preamble:

 \usepackage[a4paper]{geometry} 

The geometry package has many pre-defined page sizes, like a4paper, built in. Others include:

• a0paper, a1paper, ..., a6paper,
• b0paper, b1paper, ..., b6paper,
• letterpaper,