LaTeX: Difference between revisions

From UMIACS
Jump to navigation Jump to search
No edit summary
(→‎LaTeX on Linux/UNIX: Revise section to include GNU module information. Trim down the example.)
Line 11: Line 11:
==LaTeX on Linux/UNIX==
==LaTeX on Linux/UNIX==


As with Windows, there are full-featured suites available to compile and convert filetypes. On our supported RHEL5 and RHEL6 systems, Kile is pre-installed and located at <tt>/usr/local/bin/kile</tt>. [https://www.tug.org/texlive/ TeX Live] is also available for Linux, with macOS support made available in [https://www.tug.org/mactex/ MacTeX]
[https://www.tug.org/mactex/ MacTeX] is available for macOS.


Most of our supported Linux systems should already have the LaTeX command-line utilities, as well as TeX Live, installed. Here is a example of using these to receive output as a PDF:
[https://www.tug.org/texlive/ TeX Live] is available for Linux. For editing LaTeX files on RHEL7, [https://www.xm1math.net/texmaker/ Texmaker] is available as a GNU module.


* Create a working directory. Traverse into it, and create a file <tt>example.tex</tt> with the following contents:
Most of our supported Linux systems come with the LaTeX command-line utilities, as well as TeX Live, installed. Supported RHEL7 workstations come with Tex Live 2013, but you can load a newer version of TeX Live as a GNU module.
 
===Checking installed packages===
 
TeX Live comes with tons of packages preinstalled. To get a list of installed packages, you must first load the TeX Live GNU module. You can then use the following command:


<pre>
<pre>
\documentclass[12pt]{article}
$ tlmgr list --only-installed</pre>
\usepackage{amsmath}
 
\title{\LaTeX}
If you know which package you are looking for, you can pipe the output into <tt>grep</tt> to search for specific packages.
\date{}
 
\begin{document}
===Compiling to PDF===
  \maketitle
  \LaTeX{} is a document preparation system for the \TeX{}
  typesetting program. It offers programmable desktop
  publishing features and extensive facilities for
  automating most aspects of typesetting and desktop
  publishing, including numbering and cross-referencing,
  tables and figures, page layout, bibliographies, and
  much more. \LaTeX{} was originally written in 1984 by
  Leslie Lamport and has become the dominant method for
  using \TeX; few people write in plain \TeX{} anymore.
  The current version is \LaTeXe.
  % This is a comment, not shown in final output.
  % The following shows typesetting power of LaTeX:
  \begin{align}
    E_0 &= mc^2                              \\
    E &= \frac{mc^2}{\sqrt{1-\frac{v^2}{c^2}}}
  \end{align}
\end{document}
</pre>


* Compile the file using the <tt>latex</tt> command. Your output should be similar to the following:
The following is an example of compiling <tt>example.tex</tt> to a PDF.


<pre>
<ol>
[jlent@opensub01 example]$ latex example.tex  
  <li>
This is pdfTeX, Version 3.1415926-2.3-1.40.12 (TeX Live 2011)
    Compile the file into a DVI file by using the <tt>latex</tt> command.
 
    <pre>
$ latex example.tex  
This is pdfTeX, Version 3.1415926-2.3-1.40.13 (TeX Live 2013)
[...]
[...]
[1] (./example.aux) )
[1] (./example.aux) )
Output written on example.dvi (1 page, 1692 bytes).
Output written on example.dvi (1 page, 1692 bytes).
Transcript written on example.log.
Transcript written on example.log.</pre>
</pre>
  </li>
 
  <li>
* Assuming no errors, this should have created a file <tt>example.dvi</tt>. Depending your system, there are two ways to convert this file to PDF format:
    Use <tt>dvipdfmx</tt> to convert <tt>example.dvi</tt> into a PDF (<tt>dvipdf</tt> or <tt>dvipdfm</tt> usually would work as well).
 
* Option 1: Using <tt>dvips</tt> and then <tt>ps2pdf</tt>:
<pre>
[jlent@opensub01 example]$ dvips example.dvi  
This is dvips(k) 5.991 Copyright 2011 Radical Eye Software (www.radicaleye.com)
' TeX output 2014.07.24:1013' -> example.ps
</opt/local/stow/texlive/2011/texmf/dvips/base/tex.pro>
</opt/local/stow/texlive/2011/texmf/dvips/base/texps.pro>.
</opt/local/stow/texlive/2011/texmf-dist/fonts/type1/public/amsfonts/cm/cmr6.pfb>
</opt/local/stow/texlive/2011/texmf-dist/fonts/type1/public/amsfonts/cm/cmmi8.pfb>
</opt/local/stow/texlive/2011/texmf-dist/fonts/type1/public/amsfonts/cm/cmsy10.pfb>
</opt/local/stow/texlive/2011/texmf-dist/fonts/type1/public/amsfonts/cm/cmex10.pfb>
</opt/local/stow/texlive/2011/texmf-dist/fonts/type1/public/amsfonts/cm/cmmi12.pfb>
</opt/local/stow/texlive/2011/texmf-dist/fonts/type1/public/amsfonts/cm/cmr8.pfb>
</opt/local/stow/texlive/2011/texmf-dist/fonts/type1/public/amsfonts/cm/cmr12.pfb>
</opt/local/stow/texlive/2011/texmf-dist/fonts/type1/public/amsfonts/cm/cmr17.pfb>
[1]
[jlent@opensub01 example]$ ps2pdf example.ps
[jlent@opensub01 example]$
</pre>
 
* Option 2: Using <tt>dvipdf</tt>:
<pre>
[jlent@opensub01 example]$ dvipdf example.dvi
[jlent@opensub01 example]$
</pre>


* Assuming there are no errors, you should now have a file <tt>example.pdf</tt> in your working directory. If your output PDF does not look quite right, you may need to use different conversion tools. Your workflow may necessarily vary depending on the contents of your document and how they are formatted and rendered.
    <pre>
$ dvipdfmx example.dvi
example.dvi -> example.pdf
[1]
12211 bytes written</pre>
  </li>
</ol>
If your output PDF does not look quite right, you may need to use different conversion tools. Your workflow may necessarily vary depending on the contents of your document and how they are formatted and rendered.


==Further Reading==
==Further Reading==

Revision as of 20:16, 24 June 2019

Background

From the main Project Page:

LaTeX is a high-quality typesetting system; it includes features designed for the production of technical and scientific documentation. LaTeX is the de facto standard for the communication and publication of scientific documents.

LaTeX on Windows

In Windows, it is highly recommended to use a full-featured suite such as TeX Live or MiKTeX. Both of these suites include everything required for end-to-end LaTeX compilation and filetype conversation. Please contact the HelpDesk for assistance with installing or using these on a UMIACS-supported Windows machine.

LaTeX on Linux/UNIX

MacTeX is available for macOS.

TeX Live is available for Linux. For editing LaTeX files on RHEL7, Texmaker is available as a GNU module.

Most of our supported Linux systems come with the LaTeX command-line utilities, as well as TeX Live, installed. Supported RHEL7 workstations come with Tex Live 2013, but you can load a newer version of TeX Live as a GNU module.

Checking installed packages

TeX Live comes with tons of packages preinstalled. To get a list of installed packages, you must first load the TeX Live GNU module. You can then use the following command:

$ tlmgr list --only-installed

If you know which package you are looking for, you can pipe the output into grep to search for specific packages.

Compiling to PDF

The following is an example of compiling example.tex to a PDF.

  1. Compile the file into a DVI file by using the latex command.
    $ latex example.tex 
    This is pdfTeX, Version 3.1415926-2.3-1.40.13 (TeX Live 2013)
    [...]
    [1] (./example.aux) )
    Output written on example.dvi (1 page, 1692 bytes).
    Transcript written on example.log.
  2. Use dvipdfmx to convert example.dvi into a PDF (dvipdf or dvipdfm usually would work as well).
    $ dvipdfmx example.dvi
    example.dvi -> example.pdf
    [1]
    12211 bytes written

If your output PDF does not look quite right, you may need to use different conversion tools. Your workflow may necessarily vary depending on the contents of your document and how they are formatted and rendered.

Further Reading