LaTeX/Installation

From Wikibooks, open books for an open world
Jump to: navigation, search
LaTeX logo.svg

LaTeX

Getting Started
  1. Introduction
  2. Installation
  3. Installing Extra Packages
  4. Basics

Common Elements

  1. Document Structure
  2. Text Formatting
  3. Paragraph Formatting
  4. Colors
  5. Fonts
  6. List Structures
  7. Special Characters
  8. Internationalization
  9. Rotations
  10. Tables
  11. Title creation
  12. Page Layout
  13. Importing Graphics
  14. Floats, Figures and Captions
  15. Footnotes and Margin Notes
  16. Hyperlinks
  17. Labels and Cross-referencing

Mechanics

  1. Errors and Warnings
  2. Lengths
  3. Counters
  4. Boxes
  5. Rules and Struts

Technical Texts

  1. Mathematics
  2. Advanced Mathematics
  3. Theorems
  4. Chemical Graphics
  5. Algorithms
  6. Source Code Listings
  7. Linguistics

Special Pages

  1. Indexing
  2. Glossary
  3. Bibliography Management
  4. More Bibliographies

Special Documents

  1. Letters
  2. Presentations
  3. Teacher's Corner
  4. Curriculum Vitae

Creating Graphics

  1. Introducing Procedural Graphics
  2. MetaPost
  3. Picture
  4. PGF/TikZ
  5. PSTricks
  6. Xy-pic
  7. Creating 3D graphics

Programming

  1. Macros
  2. Plain TeX
  3. Creating Packages
  4. Themes

Miscellaneous

  1. Modular Documents
  2. Collaborative Writing of LaTeX Documents
  3. Export To Other Formats

Help and Recommendations

  1. FAQ
  2. Tips and Tricks

Appendices

  1. Authors
  2. Links
  3. Package Reference
  4. Sample LaTeX documents
  5. Index
  6. Command Glossary

edit this boxedit the TOC

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 and continue this tutorial in the next chapter. These websites offer collaboration 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 language. Using LaTeX requires a bunch 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[edit]

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[edit]

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[edit]

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.mpkg.zip 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. Further information for Mac OS X users can be found on the TeX on Mac OS X Wiki.

Microsoft Windows[edit]

Microsoft Windows users can install MiKTeX onto their computer. It has an easy installer that take care of setting up the environment and downloading core packages. This distribution has advanced features, such as automatic installation of packages, and simple interfaces to modify settings, such as default paper sizes.

There is also a port of TeX Live available for Windows.

Custom installation with TeX Live[edit]

This section targets users who want fine-grained control over their TeX distribution, like an installation with a minimum of disk space usage. If it is none of your concern, you may want to jump to the next section.

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

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

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

TeX Live groups features and packages into different concepts:

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

Minimal installation[edit]

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

  1. Download the installer at http://mirror.ctan.org/systems/texlive/tlnet/install-tl-unx.tar.gz and extract it to a temporary folder.
  2. Open a terminal in the extracted folder and log in as root.
  3. Change the umask to 022 to make sure other users will have read-only access to the installed distribution.
# umask 022
  1. Launch install-tl.
  2. Select the minimal scheme (plain only).
  3. You may want to change the directory options. For example you may want to hide your personal macro folder which is located at TEXMFHOME. It is ~/texmf by default. Replace it by ~/.texmf to hide it.
  4. Now the options:
    1. use letter size instead of A4 by default: mostly for users from the USA.
    2. 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.
    3. 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."
    4. install font/macro doc tree: useful if you are a developer, but very space consuming. Turn it off if you want to save space.
    5. install font/macro source tree: same as above.
    6. Symlinks are fine by default, change it if you know what you are doing.
  5. Select portable installation if you install the distribution to an optical disc, or any kind of external media. Leave to default for a traditional installation on the system hard drive.

At this point it should display

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

or a similar space usage.

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

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

First test[edit]

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[edit]

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. Note that as of January 2013 not all texconfig features are implemented by tlmgr. Only use texconfig when you cannot do what you want with tlmgr.

List current installation options:

tlmgr option

You can change the install options:

tlmgr option src 1
tlmgr option doc 0
tlmgr option 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[edit]

Now we have a running plainTeX 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. It may happen 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 pdftex-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.
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.
pdftex-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[edit]

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[edit]

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[edit]

TeX and LaTeX source documents (as well as related files) are all 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 (Word, OpenOffice). Dedicated LaTeX editors are more useful than generic plain text editors, because they usually have autocompletion of commands, spell and error checking and handy macros.

Cross-platform[edit]

BaKoMa TeX[edit]

BaKoMa TeX is an editor for Windows and Mac OS with WYSIWYG-like features. It takes care of compiling the LaTeX source and updating it constantly to view changes to document almost in real time.

Emacs[edit]

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 theirs needs. In turn beginners may prefer using it in combination with AUCTeX and Reftex (extensions that may be installed into the Emacs program). Depending on your configuration, Emacs can provide a complete LaTeX editing environment with auto-completion, spell-checking, a complete set of keyboard shortcuts, table of contents view, document preview and many other features.

gedit-latex-plugin[edit]

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[edit]

Screenshot of Gummi.

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

LyX[edit]

LyX1.6.3

LyX is a popular LaTeX editor for Windows, Linux and Mac OS. It contains formula and table editors and shows visual clues of the final document on the screen enabling users to write LaTeX documents without worrying about the actual syntax[3].

TeXmaker[edit]

TeXmaker is a cross-platform editor very similar to Kile in features and user interface. In addition it has its own PDF viewer.

TeXstudio[edit]

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

TeXworks[edit]

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 people in their early days with LaTeX to get to what they want to do: write their 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[edit]

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[edit]

Kile[edit]

Screenshot of Kile.

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

LaTeXila[edit]

LaTeXila is another text editor for Linux (Gnome).

Mac OS X-only[edit]

TeXShop[edit]

TeXShop is a TeXworks-like editor and previewer for Mac OS that 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.

TeXnicle[edit]

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.

Windows-only[edit]

LEd[edit]

LEd

TeXnicCenter[edit]

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

WinEdt[edit]

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 in-built 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[edit]

WinShell

Web-based[edit]

Authorea[edit]

Authorea [1] is not a LaTeX installation per se, but an integrated online framework for the creation of technical documents in collaboration. Authorea's frontend allows you to enter text in LaTeX or Markdown, as well as figures, and equations (in LaTeX or MathML). Authorea renders and compiles everything to the web (HTML5), in addition to PDF (export to numerous journal formats is provided). Authorea's versioning control system is entirely based on Git (every article is a Git repository).

Bibliography management[edit]

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[edit]

Screenshot of JabRef.

Mac OS X-only[edit]

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[4].

Viewers[edit]

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

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

Here follows a list of various PDF viewers.

  • Adobe Reader
  • epdfview
  • Evince
  • Foxit
  • Okular
  • Sumatra
  • Zathura

Tables and graphics tools[edit]

LaTeX is a document preparation system, 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 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 (font, size, etc.). Some tools have the capability to export to LaTeX, which will partially solve this issue. See Importing Graphics for more details.

Online solutions[edit]

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.

  • Google Documents or LaTeX Lab allows real-time simultaneous collaborative editing of text files for anyone with a Google account (and its option to make the document available through a URL makes local download and compilation easily scriptable).
  • LIMSUP is an online LaTeX editor allowing real time collaboration of LaTeX documents (announcement)
  • ScribTeX.com is one of the most mature systems available, with git push and pull access it allows for powerful version control. The new sign ups are now directed to use ShareLatex.com however accounts are still available upon request.
  • ShareLaTeX.com is a secure cloud based LaTeX editor offering unlimited free project. Premium accounts are available for extra features such as version control and Dropbox integration.
  • SpanDeX is a cloud-based LaTeX collaboration platform designed to make collaborating with LaTeX seamless and to reduce the learning curve to LaTeX. It offers simultaneous real-time editing and collaboration, live document preview, Dropbox integration, and a built-in LaTeX resource system.
  • 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.
  • writeLaTeX.com is a secure, easy to use online LaTeX editor with integrated rapid preview - like EtherPad for LaTeX. Start writing with one click (no signup required) and share the link. It supports real time preview, figures, bibliographies and custom styles.

References[edit]

  1. teTeX Home Page (Retrieved January 31, 2007)
  2. Gummi
  3. LyX
  4. BibDesk


Previous: Introduction Index Next: Installing Extra Packages