||<>|| LaTeX is a markup language for describing a document. If you have used HTML, or edited a wiki then you will be familiar with the idea of using symbols or commands within a text file to describe the layout of text. LaTeX is commonly used in scientific publishing. It helps you to make well formatted papers, with good looking formulae. It also helps keep track of figure and equation numbers. LaTeX files can be converted into a huge number of formats such as PDF, PostScript, DVI, and HTML. A LaTeX file is a plain text file (ASCII or Unicode) containing the text to be printed and markup commands to specify its appearence. It can be written in a text editor such as Gedit or vim. It is converted into an output format using a LaTeX compiler. Some people like to write LaTeX files in a more integrated environment, with menus and buttons for formatting commands. There are also many add on packages that add features to LaTeX. = Installing = Like Linux, LaTeX is a collection of many interdependent tools and files. Rather than find and install them all you use a LaTeX distribution. LaTeX distributions in the Ubuntu repositories are: * TeX Live * teTeX (teTeX is [[http://www.tug.org/teTeX/|no longer supported]] and is mentioned here for legacy purposes; some of the teTeX packages in Ubuntu are transitional packages to TeX Live). == TeX Live == The preferred LaTeX distribution is the one that comes with [[https://en.wikipedia.org/wiki/TeX_Live|TeX Live]]. This is a general TeX distribution that is actively maintained by the [[http://tug.org|TeX Users Group]]. === From the Ubuntu repositories === TeX Live is available for Ubuntu and is in the Universe repository. To install TeX Live, simply install {{{texlive}}} using the Ubuntu Software Centre (or aptitude, apt-get, or synaptic). This will install a basic subset of TeX Live's functionality. To install the complete TeX Live distribution, install {{{texlive-full}}}. === From the TeX Users Group === You can also install TeX Live directly from [[http://www.tug.org/texlive/|the TeX Live website]]. This method is well documented and not technically challenging, but you will need some elementary familiarity with the Linux command-line (terminal mode). Installing TeX Live directly does not interfere with Ubuntu, and ensures that you have the latest releases of all TeX and LaTeX packages. The downside is that you periodically have to update your installation manually, using the [[http://www.tug.org/texlive/tlmgr.html|TeX Live Package Manager]]. This program has a GUI and is easy to use. === Which one do I want? === There is no point in having both the repository {{{texlive}}} installation and the direct TUG TeX Live installation: they mostly consist of the same files, and installing both with double the disk space needed and may lead to version conflicts. Choose one or the other. If you opt for TUG TeX Live, you might still find it necessary to install some additional packages from the repository, to satisfy some mutual program dependencies, but there is no problem in doing this. See [[http://www.tug.org/texlive/debian.html|the Debian documentation]] for details. If you just want TeX and LaTeX, and aren't fussy about living at the cutting edge of TeX development, then use the Ubuntu repository. But if you are using a part of the LaTeX family of packages that is in current development, then use the TeX Live distribution directly from TUG. ==== Why? ==== The TeX Users Group updates TeX Live annually in a major release. Then there are incremental updates throughout the year. As of October 2013, the {{{texlive}}} package that ships with Ubuntu (TeX Live 2013) is more or less up to date, thanks to the efforts of its maintainer. But in past years, the Ubuntu repository versions of TeXLive have sometimes lagged behind the current TeX Live annual release by one or even two years. This made the installation of TeX Live directly from TUG more attractive for people who wanted to have up-to-date versions of rapidly-evolving packages. Installing from the Ubuntu repositories is definitely easier. Point and click. Installing directly from TUG's TeX Live distribution is a bit more fiddly, but gives you more fine control over installation details, and gives you the ability to keep the TeX Live files up to date, and the responsibility for doing so. There's a final wrinkle. The Ubuntu repo version of the {{{texlive}}} package will be frozen for most of the year. But starting from 2013, to mitigate this drawback, {{{texlive}}} it will '''also''' include the {{{tlmgr}}} updating program, preset to run in user mode (see the [[http://www.tug.org/texlive/doc/tlmgr.html#USER-MODE|tlmgr's man page]] or [[http://www.preining.info/blog/2013/04/tlmgr-user-mode/|this blog entry]] for usage). So you can install the repo, and then use tlmgr yourself as desired, to selectively update parts of the distribution. Your cake and eat it. But. These updates will be stored in the directory defined as TEXMFHOME, usually ~/texmf. TeX looks for packages there first of all, so updates in ~/texmf will be found and used in preference to the main distribution. Be aware that if you go this way, the packages in your ~/texmf directory will override the system packages, '''even''' when the ones in the system directories are newer. In this scenario, the easiest way to avoid trouble is to manually run {{{tlmgr}}}'s "update all installed" option fairly regularly. == teTeX == [[http://www.tug.org/tetex/|teTeX]] was formerly a common LaTeX distribution for Linux. It is in the Main and Universe Ubuntu repositories and can be installed with synaptic or apt-get. At a minimum you will need to install the packages {{{tetex-base}}}, and {{{tetex-bin}}}. Extra packages for teTeX can be found in {{{tetex-extra}}}. As of May 2006 teTeX was no longer actively maintained and its former maintainer Thomas Esser recommended TeX Live as the replacement. = Add-on packages = LaTeX can be extended using add-on packages. Packages can either be installed using Ubuntu's packaging system, or by manually copying the files to the respective locations and updating TeX's file index using [[http://www.linuxcommand.org/man_pages/mktexlsr1.html|mktexlsr]]. It is preferable to use Ubuntu's packaging system, or the [[http://www.tug.org/texlive/tlmgr.html|TeX Live Package Manager]] that both provide menu-driven interfaces for selecting and de-selecting packages. However, if you want to roll up your sleeves and get your hands dirty, this is what you do. == Installing packages manually == <> If a package you desire is not in Ubuntu's repositories, you may look on [[http://www.ctan.org|CTAN's web site]] or [[http://www.tug.org/tex-archive/help/Catalogue/index.html|TeX Catalogue Online]] to see if they have the package. If they do, download the archive containing the files. In this example, we'll install example package {{{foo}}}, contained in {{{foo.tar.gz}}}. Once {{{foo.tar.gz}}} has finished downloading, we unzip it somewhere in our home directory: {{{ tar xvf foo.tar.gz }}} This expands to folder {{{foo/}}}. We {{{cd}}} into {{{foo/}}} and see {{{foo.ins}}}. We now run LaTeX on the file: {{{ latex foo.ins }}} This will generate {{{foo.sty}}}. We now have to copy this file into the correct location. This can be done in two ways. After these, you can use your new package in your LaTeX document by inserting {{{\usepackage{foo}}}} in the preamble. === User install === We will copy this into our personal {{{texmf}}} tree. The advantages of this solution are that if we migrate our files to a new computer, we will remember to take our {{{texmf}}} tree with us, resulting in keeping the same packages we had. The disadvantages are that if multiple users want to use the same packages, the tree will have to be copied to each user's home folder. We'll first create the necessary directory structure: {{{ cd ~ mkdir -p texmf/tex/latex/foo }}} Notice that the final directory created is labeled {{{foo}}}. It is a good idea to name directories after the packages they contain. The {{{-p}}} attribute to {{{mkdir}}} tells it to create all the necessary directories, since they don't exist. Now, using either the terminal, or the file manager, copy {{{foo.sty}}} into the directory labeled {{{foo}}}. Now, we must make LaTeX recognize the new package: {{{ texhash ~/texmf }}} === System install === We will copy the {{{foo}}} to the LaTeX system tree. The advantages are that every user on the computer can access these files. The disadvantages are, that the method uses superuser privileges, and in a possible reformat/reinstall you have to repeat the procedure. First, go to the folder your {{{foo}}} is located. The following commands will create a new directory for your files and copy it to the new folder: {{{ sudo mkdir /usr/share/texmf/tex/latex/foo sudo cp foo.sty /usr/share/texmf/tex/latex/foo }}} Then update the LaTeX package cache: {{{ sudo texhash }}} = Tips & Tricks = == Inverse Search == <> Inverse search is a feature where a mouse click in the DVI viewer can open an editor with the corresponding place in the (La)TeX source (also called "reverse search"). In {{{xdvi}}}, the default is Ctrl-Left click. In {{{kdvi}}}, Middle click is the default. For information see [[http://xdvi.sourceforge.net/inverse-search.html]]. === Emacs and xdvi === Add the following line to the file {{{.emacs}}} in your home directory: {{{ (server-start) }}} Add the following line to {{{.Xresources}}} {{{ xdvi.editor: emacsclient --no-wait +%l %f }}} Now run in the terminal: {{{ xrdb .Xresources }}} === Common between Emacs/xdvi and Kile/kdvi === We will need to have a specific LaTeX package in place to enable this feature. Download and install the LaTeX package [[http://www.ctan.org/tex-archive/help/Catalogue/entries/srcltx.html|srcltx]]. There is help on [[LaTeX#manualpkginstall|installing a LaTeX package manually]]. Once {{{srcltx}}} is installed, you need to include it in your LaTeX file. Put {{{\usepackage[active]{srcltx}}}} in the preamble of your LaTeX document. == Sharing packages with another LaTeX installation == You can tell TeXLive to use packages from another location by editing {{{/etc/texmf/texmf.d/05TeXMF.cnf}}}. Just edit the line beginning with TEXMFDIST and add the path of the packages you want to include. Make sure to separate paths with a semicolon (;). For example, to make TeXLive use packages from an existing MiKTeX installation, {{{/etc/texmf/texmf.d/05TeXMF.cnf}}} could be edited so that the following line: {{{ % The main distribution tree: TEXMFDIST = /usr/share/texmf-texlive }}} Is changed to {{{ % The main distribution tree: TEXMFDIST = /usr/share/texmf-texlive;/media/Windows_Partition/MiKTeX }}} Note that you can add more than one path, if needed. Ensure that the path you have added is correct. Then run: {{{ sudo update-texmf && sudo texhash && sudo mktexlsr }}} = Resources = * [[http://www.tug.org/interest.html|TeX Users Group]] Includes links to resources around the web * [[http://www.latex-project.org/guides/|LaTeX Documentation]] * [[http://tug.org/TeXnik/mainFAQ.cgi?file=index|A-Z list of TeX FAQs]] * [[http://en.wikibooks.org/wiki/LaTeX|Wikibook's guide to LaTeX]] * [[http://www.artofproblemsolving.com/Wiki/index.php/LaTeX|AoPS LaTeX Wiki]] * [[http://ctan.mackichan.com/macros/latex/contrib/aastex/docs/aasguide.pdf|The AASTEX LATEX Macros for Manuscript Preparation]] * [[http://www-biblio.physik.uni-bonn.de/info/downloads/thesis_guide.pdf|Users Guide to Writing a Thesis in a Physics/Astronomy Institute of the University of Bonn]] * [[http://tobi.oetiker.ch/lshort/lshort.pdf|The Not So Short Introduction to LATEX2]] * [[https://apps.ubuntu.com/cat/applications/texmaker/ | Texmaker]] ---- CategoryOffice CategoryScience