LaTeX/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
editTeX and LaTeX are available for most computer platforms, since they were programmed to be very portable. They are most commonly installed using a distribution, such as TeX Live, MiKTeX, or MacTeX. TeX distributions are collections of packages and programs (compilers, fonts, and macro packages) that enable you to typeset without having to manually fetch files and configure things. LaTeX is just a set of macro packages built for TeX.
The recommended distributions for each of the major operating systems are:
- TeX Live is a major TeX distribution for *BSD, GNU/Linux, Mac OS X and Windows.
- MiKTeX is a Windows-specific distribution which can be installed on Windows or GNU/Linux.
- 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
editIn 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
editMac 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
editMicrosoft 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
editThis section targets users who want fine-grained control over their TeX distribution, like an installation with a minimum of disk space usage. If not needed, the user may feel free to jump to the next section.
Picky users may wish to have more control over their installation. Common distributions might be tedious for the user caring about disk space. In fact, MikTeX and MacTeX and packaged TeX Live features hundreds of LaTeX packages, most of them which you will never use. Most Unix with a package manager will offer TeX Live as a set of several big packages, and you often have to install 300–400 MB for a functional system.
TeX Live features a manual installation with a lot of possible customizations. You can get the network installer at tug.org. This installer allows you to select precisely the packages you want to install. As a result, you may have everything you need for less than 100 MB. TeX Live is then managed through its own package manager, tlmgr. It will let you configure the distributions, install or remove extra packages and so on.
You will need a Unix-based operating system for the following. Mac OS X, GNU/Linux or *BSD are fine. It may work for Windows but the process must be quite different.
TeX Live groups features and packages into different concepts:
- Collections are groups of packages that can always be installed individually, except for the Essential programs and files collection. You can install collections at any time.
- Installation Schemes group collections and packages. Schemes can only be used at installation time. You can select only one scheme at a time.
Minimal installation
editWe 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
All administration operations for TeX Live should be made with a 022 umask. Otherwise you will not be able to use TeX at all with an unprivileged user. |
- 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.
- allow execution of restricted list of programs via \write18: it is recommended to select it for security reasons. Otherwise it allows the TeX engines to call any external program. You may still configure the list afterwards.
- create all format files: targetting a minimal disk space, the best choice depends on whether there is only one user on the system, then deselecting it is better, otherwise select it. From the help menu: "If this option is set, format files are created for system-wide use by the installer. Otherwise they will be created automatically when needed. In the latter case format files are stored in user's directory trees and in some cases have to be re-created when new packages are installed."
- install macro/font doc tree: useful if you are a developer, but very space consuming. Turn it off if you want to save space.
- install macro/font source tree: same as above.
- create symlinks to standard directories: 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
editIn a terminal write
$ tex '\empty Hello world!\bye' $ pdftex '\empty Hello world!\bye'
You should get a DVI or a PDF file accordingly.
Configuration
editFormerly, 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
editDo not forget to set the root umask to 022 for all TeX Live administration operations. |
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
editIf 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
editBy 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
editTeX 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
editEmacs
editEmacs 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
editGedit 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
editGummi 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
editLyX 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
editTeXmaker 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
editTeXstudio is a cross-platform open source LaTeX editor forked from Texmaker.
TeXworks
editTeXworks 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
editVim 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
editKile
editKile is a LaTeX editor for KDE (cross platform), providing a powerful GUI for editing multiple documents and compiling them with many different TeX compilers. Kile is based on Kate editor, has a quick access toolbar for symbols, document structure viewer, a console and customizable build options. Kile can be run in all operating systems that can run KDE.
GNOME-LaTeX
editGNOME-LaTeX is another text editor for Linux (GNOME).
Mac OS X-only
editTeXShop
editTeXShop, 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
editTeXnicle 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
editArchimedes 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
editTexpad 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
editLEd
editTeXnicCenter
editTeXnicCenter is a popular free and open source LaTeX editor for Windows. It also has a similar user interface to TeXmaker and Kile.
WinEdt
editWinEdt 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
editOnline solutions
editTo get started without needing to install anything, you can use a web-hosted service featuring a full TeX distribution and a web LaTeX editor.
- Authorea is an integrated online framework for the creation of technical documents in collaboration. Authorea's frontend allows one to enter text in LaTeX or Markdown, as well as figures, and equations (in LaTeX or MathML). Authorea's versioning control system is entirely based on Git (as every article is a Git repository).
- CoCalc is a collaborative online workplace for computations, which also offers an editor for LaTeX documents.
- Overleaf is a secure, easy to use online LaTeX editor with integrated rapid preview - like Etherpad for LaTeX. One can start writing by creating a free account, and share the link or add collaborators to the projects before publishing it through their platform. It supports real time preview, Rich Text mode (a partial WYSIWYG mode with math expressions, ordered/unordered lists, sectional titles and figures in rendered form), bibliographies and custom styles. Since July 2017, ShareLaTeX is now part of Overleaf.[5][6]
- Verbosus is a professional online LaTeX Editor that supports collaboration with other users and is free to use. Merge conflicts can easily resolved by using a built-in merge tool that uses an implementation of the diff-algorithm to generate information required for a successful merge.
Bibliography management
editBibliography 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
editMac OS X-only
editViewers
editFinally, 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:
- PDF.js (web-library and built-in modern browsers)
- Evince (Linux GNOME)
- Foxit (Windows)
- Okular (Linux KDE)
- Preview (built-in Mac OS X)
- Reader (built-in in Windows 8 through Windows 10 1703)
- Edge PDF Viewer (built in in Windows 10)
- Adobe Acrobat Reader
- Skim (Mac OS X)
- Sumatra PDF (Windows)
- Xpdf (Linux)
- Zathura (Linux)
Tables and graphics tools
editLaTeX 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
edit- ↑ a b teTeX Home Page (Retrieved August 22, 2020)
- ↑ MikTeX — All Downloads
- ↑ Gummi
- ↑ LyX
- ↑ ShareLaTeX Joins Overleaf
- ↑ The Definitive, Non-Technical Introduction to LaTeX: Overleaf
- ↑ BibDesk