Permission is granted to copy, distribute, and/or modify this document under the terms of the Creative Commons Attribution-ShareAlike 3.0 Unported License.

Contents

If you have saved this file to your computer, click on a link in the contents to go to that section.

Getting Started

Common Elements

Mechanics

Technical Texts

Special Pages

Special Documents

Creating Graphics

Programming

Miscellaneous

Help and Recommendations

Appendices





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 π {\displaystyle \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:

The TeX Stack Exchange Q&A

the #latex IRC channel on Freenode

IRC channel on Freenode The TeX FAQ

The LaTeX.org forums

Donald Knuth's original guide to TeX, The TeXbook

Leslie Lamport's original guide to LaTeX, LaTeX: A document preparation system





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 teTeX, 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.

are groups of packages that can always be installed individually, except for the 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).

Download the installer at http://mirror.ctan.org/systems/texlive/tlnet/install-tl-unx.tar.gz and extract it to a temporary folder. Open a terminal in the extracted folder and log in as root. Change the umask permissions to 022 (user read/write/execute, group/others read/execute only) to make sure other users will have read-only access to the installed distribution.

# umask 022

Launch install-tl . Select the minimal scheme (plain only). 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. Now the options: use letter size instead of A4 by default: mostly for users from the USA. execution of restricted list of programs: 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. create 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." install font/macro doc tree: useful if you are a developer, but very space consuming. Turn it off if you want to save space. install font/macro source tree: same as above. Symlinks are fine by default, change it if you know what you are doing. 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

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

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

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.

LaTeXila

LaTeXila 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

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

LEd

LEd

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.

WinShell

WinShell

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]

SimpleLaTeX is an online editor and previewer for short LaTeX notes, which can be optionally cached or shared. Previews are available in SVG, PNG, and PDF. It also includes a simple GUI for editing tables.

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

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:

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





Installing Extra Packages

1

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 <insert package name here> .

Manual installation

Downloading packages

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 LaTeX version of LaTeX;

the package is part of a much larger bundle which you shouldn't normally update unless you change 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:

MacTeX: Users/ username /Library/texmf/ .

. Unix-type systems: Usually ~/texmf/ . If you use TexMaker on Ubuntu 18 it may be in /usr/share/texmf/

. If you use on it may be in 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)

(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).

(if you installed the files in a personal tree) or (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 .

See http://www.tug.org/fonts/fontinstall.html.

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:

See Also





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:

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. 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 } ...

Most standard LaTeX commands have a switch equivalent. Switches have no arguments, but apply on the rest of the scope, in other words the current group or environment. A switch should almost never be called outside of any scope, otherwise it will apply on the rest of the document.

Example:

% \emph is a command with argument, \em is a switch. \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.

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:

Open a terminal and navigate to the directory containing your .tex file. Type the command: xelatex hello.tex (The .tex extension is not required, although you can include it if you wish.) 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:

$ latexmk -pdf file.tex

Note that most editors will take care of it for you.

Historical versions of LaTeX

Both LaTeX and TeX were created many years before the Portable Document Format (PDF) existed, so the plain LaTeX engine, latex , emits DVI, a format designed by Donald Knuth for device-independent TeX output. This format has fallen out of general use, but can be converted into more common output formats using programs from your LaTeX distribution:

dvips converts .dvi files to .ps (PostScript).

converts files to (PostScript). dvipdf converts .dvi files to .pdf ( dvipdfm is an improved version).

You might also find Ghostscript, a set of free and open-source tools for working with PostScript, useful. Its ps2pdf converts .ps files to .pdf , and pdf2ps does the reverse.

The following diagram shows the relationships between the LaTeX source code and the formats you can create from it:

The boxed red text represents the file formats, the blue text on the arrows represents the commands you have to use, the small dark green text under the boxes represents the image formats that are supported. Any time you pass through an arrow you lose some information, which might decrease the features of your document. Therefore, you should choose the shortest route to reach your target format. This is probably the most convenient way to obtain an output in your desired format anyway. Starting from a LaTeX source, the best way is to use only latex for a DVI output, or only pdflatex for a PDF output, converting to PostScript only when it is necessary to print the document.

Note that using latex to generate DVI output keeps you from using PDF-only features, such as hyperlinks and embedded fonts.

Chapter Export To Other Formats discusses more about exporting LaTeX source to other file formats.

Files

Picking suitable filenames

Never, ever use directories (folders) or file names that contain spaces. Although your operating system probably supports them, some don't, and they will only cause grief and tears with TeX. Make filenames as short or as long as you wish, but strictly avoid spaces. Stick to lower-case letters without accents a-z , the digits 0-9 , the hyphen ( - ), and only one full point or period ( . ) to separate the file extension (somewhat similar to the conventions for a good Web URL): it will let you refer to TeX files over the Web more easily and make your files more portable. Some operating systems do not distinguish between upper-case and lower-case letters, others do. Therefore it's best not to mix them.

Ancillary files

The TeX compilers are single-pass processes. It means that there is no way for a compiler to jump around the document, which would be useful for the table of contents and references. Indeed the compiler cannot guess at which page a specific section is going to be printed, so when the table of contents is printed before the upcoming sections, it cannot set the page numbers.

To circumvent this issue, many LaTeX commands which need to jump use ancillary files which usually have the same file name as the current document but a different extension. It stores temporary data into these files and use them for the next compilation. So to have an up-to-date table of contents, you need to compile the document twice. There is no need to re-compile if no section moved.

For example, the temporary file for the table of contents data is filename.toc .

None of these files contains unrecoverable information. It means you can delete them safely, compiling will regenerate them automatically.

When you work with various capabilities of LaTeX (index, glossaries, bibliographies, etc.) you will soon find yourself in a maze of files with various extensions and probably no clue. The following list explains the most common file types you might encounter when working with TeX:

Common file extensions in LaTeX .aux A file that transports information from one compiler run to the next. Among other things, the .aux file is used to store information associated with cross-references. .bbl Bibliography file output by BiBTeX and used by LaTeX .bib Bibliography database file. (where you can store a list of full bibliographic citations) .blg BiBTeX log file. (errors are logged here) .bst BiBTeX style file. .cls Class files define what your document looks like. They are selected with the \documentclass command. .dtx Documented TeX. This is the main distribution format for LaTeX style files. If you process a .dtx file you get documented macro code of the LaTeX package contained in the .dtx file. .ins The installer for the files contained in the matching .dtx file. If you download a LaTeX package from the net, you will normally get a .dtx and a .ins file. Run LaTeX on the .ins file to unpack the .dtx file. .fd Font description file telling LaTeX about new fonts. .dvi Device Independent File. This is the main result of a LaTeX compile run with latex . You can look at its content with a DVI previewer program or you can send it to a printer with dvips or a similar application. .pdf Portable Document Format. This is the main result of a LaTeX compile run with pdflatex . You can look at its content or print it with any PDF viewer. .log Gives a detailed account of what happened during the last compiler run. .toc Stores all your section headers. It gets read in for the next compiler run and is used to produce the table of contents. .lof This is like .toc but for the list of figures. .lot And again the same for the list of tables. .idx If your document contains an index. LaTeX stores all the words that go into the index in this file. Process this file with makeindex. .ind The processed .idx file, ready for inclusion into your document on the next compile cycle. .ilg Logfile telling what makeindex did. .sty LaTeX Macro package. This is a file you can load into your LaTeX document using the \usepackage command. .tex LaTeX or TeX input file. It can be compiled with latex . .out hyperref package file, just one for the master file.

And what now?

Common Elements

See Document Structure and the Common Elements part for all the common features that belong to every type of document.

Non-English documents and special characters

LaTeX has some nice features for most languages in the world. You can tell LaTeX to follow typography rules of the target language, ease special characters input, and so on. See Special Characters and Internationalization.

Modular document

See Modular Documents for good recommendations about the way to organize big projects into multiple files.

Questions and Issues

We highly urge you to read the FAQ if you have issues about basic features, or if you want to read essential recommendations. For the more specific questions and issues, refer to the Tips and Tricks page.

Macros for the utmost efficiency

The full power of LaTeX resides in macros. They make your documents very dynamic and flexible. See the dedicated part.

Working in a team

See chapter Collaborative Writing of LaTeX Documents.





Document Structure

The main point of writing a text is to convey ideas, information, or knowledge to the reader. The reader will understand the text better if these ideas are well-structured, and will see and feel this structure much better if the typographical form reflects the logical and semantic structure of the content.

Given only the logical and semantical structure of a text, LaTeX derives the typographical form of the text according to the “rules” given in the document class file and in various style files. LaTeX allows users to structure their documents with a variety of hierarchical constructs, including chapters, sections, subsections and paragraphs.

Global structure

When LaTeX processes an input file, it expects it to follow a certain structure. Thus every input file must contain the commands

\documentclass { ... } \begin { document } ... \end { document }

The area between \documentclass{...} and \begin{document} is called the preamble. It normally contains commands that affect the entire document.

After the preamble, the text of your document is enclosed between two commands which identify the beginning and end of the actual document:

\begin { document } ... \end { document }

You would put your text where the dots are. The reason for marking off the beginning of your text is that LaTeX allows you to insert extra setup specifications before it (where the blank line is in the example above: we'll be using this soon). The reason for marking off the end of your text is to provide a place for LaTeX to be programmed to do extra stuff automatically at the end of the document, like making an index.

A useful side-effect of marking the end of the document text is that you can store comments or temporary text underneath the \end{document} in the knowledge that LaTeX will never try to typeset them:

\end { document } ...

Preamble

Document classes

When processing an input file, LaTeX needs to know which layout standard to use. Layouts standards are contained within 'class files' which have .cls as their filename extension.

\documentclass [options] { class }

Here, the class parameter for the command \documentclass specifies the .cls file to use for the document. It is recommended to put this declaration at the very beginning. The LaTeX distribution provides additional classes for other layouts, including letters and slides. It is also possible to create your own, as is often done by journal publishers, who simply provide you with their own class file, which tells LaTeX how to format your content. But we'll be happy with the standard article class for now. The options parameter customizes the behavior of the document class. The options have to be separated by commas.

Example: an input file for a LaTeX document could start with the line

\documentclass [11pt,twoside,a4paper] { article }

which instructs LaTeX to typeset the document as an article with a base font size of 11 points, and to produce a layout suitable for double sided printing on A4 paper.

Here are some document classes that can be used with LaTeX:

Document Classes article For articles in scientific journals, presentations, short reports, program documentation, invitations, ... IEEEtran For articles with the IEEE Transactions format. proc A class for proceedings based on the article class. report For longer reports containing several chapters, small books, thesis, ... book For real books. slides For slides. The class uses big sans serif letters. memoir For changing sensibly the output of the document. It is based on the book class, but you can create any kind of document with it [2] letter For writing letters. beamer For writing presentations (see LaTeX/Presentations).

The generic document classes that come with LaTeX offer some layout flexibility, which is why they have a lot of options in common. Non-generic classes (those provided by university departments or publication houses) may have different options than those shown below or no options at all. Normally, third-party classes come with their own documentation. The most common options for the generic document classes are listed in the following table:

Document Class Options 10pt, 11pt, 12pt Sets the size of the main font in the document. If no option is specified, 10pt is assumed. a4paper, letterpaper, ... Defines the paper size. The default size is letterpaper ; However, many European distributions of TeX now come pre-set for A4, not Letter, and this is also true of all distributions of pdfLaTeX. Besides that, a5paper, b5paper, executivepaper , and legalpaper can be specified. fleqn Typesets displayed formulas left-aligned instead of centered. leqno Places the numbering of formulas on the left hand side instead of the right. titlepage, notitlepage Specifies whether a new page should be started after the document title or not. The article class does not start a new page by default, while report and book do. twocolumn Instructs LaTeX to typeset the document in two columns instead of one. twoside, oneside Specifies whether double or single sided output should be generated. The classes article and report are single sided and the book class is double sided by default. Note that this option concerns the style of the document only. The option twoside does not tell the printer you use that it should actually make a two-sided printout. landscape Changes the layout of the document to print in landscape mode. openright, openany Makes chapters begin either only on right hand pages or on the next page available. This does not work with the article class, as it does not know about chapters. The report class by default starts chapters on the next page available and the book class starts them on right hand pages. draft makes LaTeX indicate hyphenation and justification problems with a small square in the right-hand margin of the problem line so they can be located quickly by a human. It also suppresses the inclusion of images and shows only a frame where they would normally occur.

For example, if you want a report to be in 12pt type on A4, but printed one-sided in draft mode, you would use:

\documentclass [12pt,a4paper,oneside,draft] { report }

Packages

While writing your document, you will probably find that there are some areas where basic LaTeX cannot solve your problem. If you want to include graphics, colored text or source code from a file into your document, you need to enhance the capabilities of LaTeX. Such enhancements are called packages. Some packages come with the LaTeX base distribution. Others are provided separately. Modern TeX distributions come with a large number of packages pre-installed. The command to use a package is pretty simple: \usepackage :

\usepackage [options] { package }

command, where package is the name of the package and options is a list of keywords that trigger special features in the package. For example, to use the color package, which lets you typeset in colors, you would type:

\documentclass { report } \usepackage { color } \begin { document } ... \end { document }

You can pass several options to a package, each separated by a comma.

\usepackage [option1,option2,option3] { ''package _ name'' }

The document environment

Top matter

At the beginning of most documents there will be information about the document itself, such as the title and date, and also information about the authors, such as name, address, email etc. All of this type of information within LaTeX is collectively referred to as top matter. Although never explicitly specified (there is no \topmatter command) you are likely to encounter the term within LaTeX documentation.

A simple example:

\documentclass [11pt,a4paper] { report } \begin { document } \title { How to Structure a LaTeX Document } \author { Andrew Roberts } \date { December 2004 } \maketitle \end { document }

The \title , \author , and \date commands are self-explanatory. You put the title, author name, and date in curly braces after the relevant command. The title and author are usually compulsory (at least if you want LaTeX to write the title automatically); if you omit the \date command, LaTeX uses today's date by default. You always finish the top matter with the \maketitle command, which tells LaTeX that it's complete and it can typeset the title according to the information you have provided and the class (style) you are using. If you omit \maketitle , the title will never be typeset.



Using this approach, you can only create a title with a fixed layout. If you want to create your title freely, see the Title Creation section. You should remember, however, that the goal of LaTeX is to leave formatting to the documentclass designer, and if you wish to submit your work to multiple publishers then you should avoid designing a custom title.

Abstract

As most research papers have an abstract, there are predefined commands for telling LaTeX which part of the content makes up the abstract. This should appear in its logical order, therefore, after the top matter, but before the main sections of the body. This command is available for the document classes article and report, but not book.

\documentclass { article } \begin { document } \begin { abstract } Your abstract goes here... ... \end { abstract } ... \end { document }

By default, LaTeX will use the word "Abstract" as a title for your abstract. If you want to change it into anything else, e.g. "Executive Summary", add the following line before you begin the abstract environment:

\renewcommand { \abstractname }{ Executive Summary }

Sectioning commands

The commands for inserting sections are fairly intuitive. Of course, certain commands are appropriate to different document classes. For example, a book has chapters but an article doesn't. Here are some of the structure commands found in simple.tex.

\chapter { Introduction } This chapter's content... \section { Structure } This section's content... \subsection { Top Matter } This subsection's content... \subsubsection { Article Information } This subsubsection's content...

Notice that you do not need to specify section numbers; LaTeX will sort that out for you. Also, for sections, you do not need to use \begin and \end commands to indicate which content belongs to a given block.

LaTeX provides 7 levels of depth for defining sections (see table below). Each section in this table is a subsection of the one above it.

Command Level Comment \part { ''part'' } -1 not in letters \chapter { ''chapter'' } 0 only books and reports \section { ''section'' } 1 not in letters \subsection { ''subsection'' } 2 not in letters \subsubsection { ''subsubsection'' } 3 not in letters \paragraph { ''paragraph'' } 4 not in letters \subparagraph { ''subparagraph'' } 5 not in letters

All the titles of the sections are added automatically to the table of contents (if you decide to insert one). But if you make manual styling changes to your heading, for example a very long title, or some special line-breaks or unusual font-play, this would appear in the Table of Contents as well, which you almost certainly don't want. LaTeX allows you to give an optional extra version of the heading text which only gets used in the Table of Contents and any running heads, if they are in effect. This optional alternative heading goes in [square brackets] before the curly braces:

\section [Effect on staff turnover] { An analysis of the effect of the revised recruitment policies on staff turnover at divisional headquarters }

Section numbering

Numbering of the sections is performed automatically by LaTeX, so don't bother adding them explicitly, just insert the heading you want between the curly braces. Parts get roman numerals (Part I, Part II, etc.); chapters and sections get decimal numbering like this document, and appendices (which are just a special case of chapters, and share the same structure) are lettered (A, B, C, etc.).

You can change the depth to which section numbering occurs, so you can turn it off selectively. By default it is set to 3. If you only want parts, chapters, and sections numbered, not subsections or subsubsections etc., you can change the value of the secnumdepth counter using the \setcounter command, giving the depth level you wish. For example, if you want to change it to "1":

\setcounter { secnumdepth }{ 1 }

A related counter is tocdepth, which specifies what depth to take the Table of Contents to. It can be reset in exactly the same way as secnumdepth. For example:

\setcounter { tocdepth }{ 3 }

To get an unnumbered section heading which does not go into the Table of Contents, follow the command name with an asterisk before the opening curly brace:

\subsection* { Introduction }

All the divisional commands from \part* to \subparagraph* have this "starred" version which can be used on special occasions for an unnumbered heading when the setting of secnumdepth would normally mean it would be numbered.

If you want the unnumbered section to be in the table of contents anyway, use package unnumberedtotoc [1]. It provides the command

\addsec { Introduction }

which will take care of a proper header as well. \addpart and \addchap are also available. KOMA classes provide those commands by default.

If you don't want to use package unnumberedtotoc, you have to do everything by hand using \addcontentsline and \markright{} (or even \markboth{}{} ).





\section* { Introduction } \markright {} \addcontentsline { toc }{ section }{ Introduction }

Note that if you use PDF bookmarks you will need to add a phantom section so that hyperlinks will lead to the correct place in the document. The \phantomsection command is defined in the hyperref package, and is Commonly used like this:

\phantomsection \addcontentsline { toc }{ section }{ Introduction } \section* { Introduction }

For chapters you will also need to clear the page (this will also correct page numbering in the ToC):

\clearpage %or \cleardoublepage \phantomsection \addcontentsline { toc }{ chapter }{ List of Figures } \listoffigures

Section number style

See Counters.

Ordinary paragraphs

Paragraphs of text come after section headings. Simply type the text and leave a blank line between paragraphs. The blank line means "start a new paragraph here": it does not mean you get a blank line in the typeset output. For formatting paragraph indents and spacing between paragraphs, refer to the Paragraph Formatting section.

Table of contents

All auto-numbered headings get entered in the Table of Contents (ToC) automatically. You don't have to print a ToC, but if you want to, just add the command \tableofcontents at the point where you want it printed (usually after the Abstract or Summary).

Entries for the ToC are recorded each time you process your document, and reproduced the next time you process it, so you need to re-run LaTeX one extra time to ensure that all ToC pagenumber references are correctly calculated. We've already seen how to use the optional argument to the sectioning commands to add text to the ToC which is slightly different from the one printed in the body of the document. It is also possible to add extra lines to the ToC, to force extra or unnumbered section headings to be included.

The commands \listoffigures and \listoftables work in exactly the same way as \tableofcontents to automatically list all your tables and figures. If you use them, they normally go after the \tableofcontents command. The \tableofcontents command normally shows only numbered section headings, and only down to the level defined by the tocdepth counter, but you can add extra entries with the \addcontentsline command. For example if you use an unnumbered section heading command to start a preliminary piece of text like a Foreword or Preface, you can write:

\subsection* { Preface } \addcontentsline { toc }{ subsection }{ Preface }

This will format an unnumbered ToC entry for "Preface" in the "subsection" style. You can use the same mechanism to add lines to the List of Figures or List of Tables by substituting lof or lot for toc. If the hyperref package is used and the link does not point to the correct chapter, the command \phantomsection in combination with \clearpage or \cleardoublepage can be used (see also Labels and Cross-referencing):

\cleardoublepage \phantomsection \addcontentsline { toc }{ chapter }{ List of Figures } \listoffigures

To change the title of the ToC, you have to paste this command \renewcommand{\contentsname}{<New table of contents title>} in your document preamble. The List of Figures (LoF) and List of Tables (LoT) names can be changed by replacing the \contentsname with \listfigurename for LoF and \listtablename for LoT.

Depth

The default ToC will list headings of level 3 and above. To change how deep the table of contents displays automatically the following command can be used in the preamble:

\setcounter { tocdepth }{ 4 }

This will make the table of contents include everything down to paragraphs. The levels are defined above on this page. Note that this solution does not permit changing the depth dynamically.

You can change the depth of specific section type, which could be useful for PDF bookmarks (if you are using the hyperref package) :

\makeatletter \renewcommand* { \toclevel @chapter }{ -1 } % Put chapter depth at the same level as \part. \chapter { Epilogue } \renewcommand* { \toclevel @chapter }{ 0 } % Put chapter depth back to its default value. \makeatother

In order to further tune the display or the numbering of the table of contents, for instance if the appendix should be less detailed, you can make use of the tocvsec2 package (CTAN, doc).

Book structure

The standard LaTeX book class follows the same layout described above with some additions. By default a book will be two-sided, i.e. left and right margins will change according to the page number parity. Furthermore current chapter and section will be printed in the header.

If you do not make use of chapters, it is barely useful to use the book class.

Additionally the class provides macros to change the formatting of some places of the document. We will give you some advice on how to use them properly.[2]

\begin { document } \frontmatter \maketitle % Introductory chapters \chapter { Preface } % ... \mainmatter \chapter { First chapter } % ... \appendix \chapter { First Appendix } \backmatter \chapter { Last note }

The frontmatter chapters will not be numbered. Page numbers will be printed in roman numerals. Frontmatter is not supposed to have sections, so they will be numbered 0.n because there is no chapter numbering. Check the Counters chapter for a fix.

because there is no chapter numbering. Check the Counters chapter for a fix. The mainmatter chapters works as usual. The command resets the page numbering. Page numbers will be printed in arabic numerals.

The \appendix macro can be used to indicate that following sections or chapters are to be numbered as appendices. Appendices can be used for the article class too:

\appendix \section { First Appendix }

Only use the \appendix macro once for all appendices.

The backmatter behaves like the frontmatter. It has the same issue with section numbering.

As a general rule you should avoid mixing the command order. Nonetheless all commands are optional, so you might consider using only a few.

Note that the special content like the table of contents is considered as an unnumbered chapter.

Page order

This is one traditional page order for books.

Frontmatter

Half-title Empty Title page Information (copyright notice, ISBN, etc.) Dedication if any, else empty Table of contents List of figures (can be in the backmatter too) Preface chapter

Mainmatter

Main topic

Appendix

Some subordinate chapters

Backmatter

Bibliography Glossary / Index





Special pages

Comprehensive papers often feature special pages at the end, like indices, glossaries and bibliographies. Since this is quite a complex topic, we will give you details in the dedicated part Special Pages.

Bibliography

Any good research paper will have a complete list of references. LaTeX has two ways of inserting your references into a document:

you can embed them within the document itself. It's simpler, but it can be time-consuming if you are writing several papers about similar subjects so that you often have to cite the same books.

you can store them in an external BibTeX file and then link them via a command to your current document and use a Bibtex style to define how they appear. This way you can create a small database of the references you might use and simply link them, letting LaTeX work for you.

To learn how to add a bibliography to your document, see the Bibliography Management section.

Notes and references





Text Formatting

This section will guide you through text-formatting techniques. Formatting refers to most things to do with appearance including text style and spacing. Formatting may also refer to paragraph and page layout, here we will focus on the customization of words and sentences.

Writers use formatting techniques to differentiate textual elements from the rest of the text. The many ways in which writers wish to differentiate textual elements give rise to many formatting techniques. Italicization is often used to add emphasis to key words or phrases. Footnotes are useful for providing extra information or clarification without interrupting the main flow of the text. For these reasons, formatting is very important. However, it is also very easy to abuse, and a document that has been over-done can look and read worse than one with none at all.

LaTeX is so flexible that we will actually only skim the surface, as you can have much more control over the presentation of your document if you wish. Having said that, one of the purposes of LaTeX is to take away the stress of having to deal with the physical presentation yourself, so you need not get too carried away!

Spacing

Line Spacing

If you want to use larger inter-line spacing in a document, you can change its value by putting the

\linespread { factor }

command into the preamble of your document. Use \linespread{1.3} for "one and a half" line spacing, and \linespread{1.6} for "double" line spacing. Normally the lines are not spread, so the default line spread factor is 1. This may not be ideal in all situations: see http://tex.stackexchange.com/questions/30073/why-is-the-linespread-factor-as-it-is .

The setspace package allows more fine-grained control over line spacing. To set "one and a half" line spacing document-wide, but not where it is usually unnecessary (e.g. footnotes, captions):

\usepackage { setspace } %\singlespacing \onehalfspacing %\doublespacing %\setstretch{1.1}

To change line spacing within the document, the setspace package provides the environments singlespace , onehalfspace , doublespace and spacing :

This paragraph has \\ default \\ line spacing. \begin { doublespace } This paragraph has \\ double \\ line spacing. \end { doublespace } \begin { spacing }{ 2.5 } This paragraph has \\ huge gaps \\ between lines. \end { spacing }

Non-breaking spaces

This essential feature is a bit unknown to newcomers, although it is available on most WYSIWYG document processors. A non-breaking space between two tokens (e.g. words, punctuation marks) prevents the processors from inserting a line break between them. Additionally, a non-breaking space cannot be enlarged. It is very important for a consistent reading.

LaTeX uses the '~' symbol as a non-breaking space. You would usually use non-breaking spaces for punctuation marks in some languages, for units and currencies, for initials, etc. In French typography, you would put a non-breaking space before all two-parts punctuation marks.

Examples:

D.~Knuth EUR~50

Sentence-spacing -- space between words and sentences

To get a straight right margin in the output, LaTeX inserts varying amounts of space between the words. By default, it follows traditional typesetting practice and inserts more space at the end of a sentence to assist the reader: an em-space rather than a word-space. This can be approximated on a typewriter or computer keyboard by pressing the space bar twice rather than once. After the invention of the typewriter, English practice was to press the spacebar twice between sentences (but not around various other punctuation), while French practice was to press the spacebar once (but then also again around various other punctuation).

However, the extra space added at the end of sentences is latterly considered typographically old-fashioned in current mass-market English language printing. (The practice was discovered in the fifteenth century to be preferred by readers (despite being ongoingly resented by some typographers as more effortful and less graphically attractive) and, for this ongoing reason, remained the standard throughout the fifteenth, sixteenth, seventeenth, eighteenth, nineteenth, and twentieth centuries. Typesetting technology changes around WWII encouraged mass-market publishers to increasingly use single spacing for cost/profit reasons, and in the late 1980s the then-innovative Macintosh DTP technology created a suddenly wide platform for the University of Chicago Press to reintroduce and evangelize William Morris's failed nineteenth century attempt to popularize the rejected early fifteenth century's close-set type as a Norm, but this time to people without industry or market knowledge. "French Spacing" was redefined at this time in the USA (only) as a pejorative term to describe its opposite: to mean em-spacing between sentences rather than word-spacing. LaTeX users should note that Donald Knuth created TeX specifically to correct what he described as the ugliness and unreadability of then-(70s, pre-MacintoshDTP)-machine-typesetting, that he later added the FrenchSpacing option not as default but as a lengthily-specified option, i.e. that original TeX assumed the user wanted reader-centric typesetting (em-spacing sentences not word-spacing), and that Donald Knuth explicitly coded the FrenchSpacing option to implement precisely the opposite of what current post-University-of-Chicago typographers declare it to mean despite him being "otherwise" regarded as extremely intelligent and extremely well informed.) Most modern typesetters treat the end of sentence space the same as the interword space. (See for example, Bringhurst's Elements of Typographic Style.)

The additional space after periods can be disabled with the command

\frenchspacing

which tells LaTeX not to insert more space after a period than after ordinary character. Frenchspacing can be turned off later in your document via the

onfrenchspacing command.

If an author wishes to use the wider end-of-sentence spacing, care must be exercised so that punctuation marks are not misinterpreted as ends of sentences. TeX assumes that sentences end with periods, question marks or exclamation marks. Although if a period follows an uppercase letter, this is not taken as a sentence ending, since periods after uppercase letters normally occur in abbreviations. Any exception from these assumptions has to be specified by the author. A backslash before a space generates a space that will not be enlarged. A tilde ‘ ~ ’ character generates a non-breaking space. The command \@ before a period specifies that this period terminates a sentence even when it follows an uppercase letter. (If you are using \frenchspacing , then none of these exceptions need be specified.)

Stretched spaces

You can insert a horizontal stretched space with \hfill in a line so that the rest gets "pushed" toward the right margin. For instance this may be useful in the header.

Author Name \hfill \today

Similarly you can insert vertical stretched space with \vfill . It may be useful for special pages.

\maketitle \vfill \tableofcontents \clearpage \section { My first section } % ...

See Lengths for more details.

Manual spacing

The spaces between words and sentences, between paragraphs, sections, subsections, etc. is determined automatically by LaTeX. It is against LaTeX philosophy to insert spaces manually and will usually lead to bad formatting. Manual spacing is a matter of macro writing and package creation.

See Lengths for more details.

Hyphenation

LaTeX hyphenates words whenever necessary. Hyphenation rules will vary for different languages. LaTeX only supports English by default, so if you want to have correct hyphenation rules for your desired language, see Internationalization.

If the hyphenation algorithm does not find the correct hyphenation points, you can remedy the situation by using the following commands to tell TeX about the exception. The command

\hyphenation { word list }

causes the words listed in the argument (separated by blanks) to be hyphenated only at the points marked by “-”. The argument of the command should only contain words built from normal letters, or rather characters that are considered to be normal letters by LaTeX. It is known that the hyphenation algorithm does not find all correct American English hyphenation points for several words. A log of known exceptions is published periodically in the TUGboat journal. (2012 list: https://www.tug.org/TUGboat/tb33-1/tb103hyf.pdf).

The hyphenation hints are stored for the language that is active when the hyphenation command occurs. This means that if you place a hyphenation command into the preamble of your document it will influence the English language hyphenation. If you place the command after the \begin{document} and you are using some package for national language support like babel, then the hyphenation hints will be active in the language activated through babel. The example below will allow “hyphenation” to be hyphenated as well as “Hyphenation”, and it prevents “FORTRAN”, “Fortran” and “fortran” from being hyphenated at all. No special characters or symbols are allowed in the argument. Example:

\hyphenation { FORTRAN Hy-phen-a-tion }

With babel, the recommended command to set hyphenation exceptions is \babelhyphenation . When LuaTeX is used, babel also allows to add new patterns and modify existing ones (with \babelpatterns ), as well as to define non-standard rules (like ‘ff’ to ‘ff-f’ in some languages, or ranked hyphenation) to be applied without explicit mark-up (with \babelposthyphenation ).

The command \- inserts a discretionary hyphen into a word. This also becomes the only point where hyphenation is allowed in this word. This command is especially useful for words containing special characters (e.g., accented characters), because LaTeX does not automatically hyphenate words containing special characters.

\begin { minipage }{ 2in } I think this is: su \- per \- cal \- % i \- frag \- i \- lis \- tic \- ex \- pi \- % al \- i \- do \- cious \end { minipage } I think this is: supercalifragi- listicexpialidocious {\displaystyle {\begin{array}{l}{\mbox{I think this is: supercalifragi-}}\\{\mbox{listicexpialidocious}}\end{array}}}

LaTeX does not hyphenate compound words that contain a dash[1]. There are two packages that can add back flexibility. The hyphenat package supplies the \hyp command. This command typesets the dash and then subjects the constituent words to automatic hyphenation. After loading the package:

\usepackage { hyphenat }

one should write, instead of electromagnetic-endioscopy:

electromagnetic \hyp {} endioscopy

The extdash package also offers features for controlling the hyphenation of compound words containing dashes — as opposed to the words themselves which it leaves to LaTeX. The shortcuts option enables a more compressed syntax:

\usepackage [shortcuts] { extdash }

Typical usage is as follows, assuming the compressed syntax. In both cases, LaTeX can break and hyphenate the constituent words, but in the latter case, it will not break after the L:

electromagnetic \- /endioscopy L \= /approximation

One or more words can be kept together on the one line with the standard LaTeX command:

\mbox { text }

This prevents hyphenation and causes its argument to be kept together under all circumstances. For example:

My phone number will change soon. It will be \mbox { 0116 291 2319 } .

\fbox is similar to \mbox , but in addition there will be a visible box drawn around the content.

To avoid hyphenation altogether, the penalty for hyphenation can be set to an extreme value:

\hyphenpenalty =100000

You can change the degree to which LaTeX will hyphenate by changing the value of \tolerance=1000 and \hyphenpenalty=1000 . You'll have to experiment with the values to achieve the desired effect. A document which has a low tolerance value will cause LaTeX not to tolerate uneven spacing between words, hyphenating words more frequently than in documents with higher tolerances. Also note that using a higher text width will decrease the probability of encountering badly hyphenated word. For example adding

\usepackage { geometry }

will widen the text width and reduce the amount of margin overruns.

Quote-marks

LaTeX treats left and right quotes as different entities. For single quotes, a grave accent, ` (on American keyboards, this symbol is found on the tilde key; adjacent to the number 1 key on most keyboards) gives a left quote mark, and an apostrophe, ' gives a right. For double quotes, simply double the symbols, and LaTeX will interpret them accordingly. (Don't use the " for right double quotes: when the babel package is used for some languages (e.g. German), the " is redefined to produce an umlaut accent; using " for right double quotes will either lead to bad spacing or it being used to produce an umlaut). On British keyboards, ' ` ' is left of the ' 1 ' key and shares the key with ' ¬ ', and sometimes ' ¦ ' or ' | '. The apostrophe (') key is to the right of the colon/semicolon key and shares it with the ' @ ' symbol.





To `quote' in LaTeX To ``quote'' in LaTeX To ``quote" in LaTeX To ,,quote'' in LaTeX ,,German quotation marks`` <<French quotation marks>> ``Please press the `x' key.'' ,,Proszę, naciśnij klawisz <<x>>''.

The right quote is also used for apostrophe in LaTeX without trouble.

For left bottom quote and European quoting style you need to use T1 font encoding enabled by:

\usepackage [T1] { fontenc }

See Fonts for more details on 