Formatting informationA beginner's introduction to typesetting with LATEXPeter FlynnSilmaril Consultants |
Contents
|
|---|---|
|
This edition of Formatting Information was prompted by the generous help I have received from TEX users too numerous to mention individually. Shortly after TUGboat published the November 2003 edition, I was reminded by a spate of email of the fragility of documentation for a system like LATEX which is constantly under development. There have been revisions to packages; issues of new distributions, new tools, and new interfaces; new books and other new documents; corrections to my own errors; suggestions for rewording; and in one or two cases mild abuse for having omitted package X which the author felt to be indispensable to users. ¶ I am grateful as always to the people who sent me corrections and suggestions for improvement. Please keep them coming: only this way can this book reflect what people want to learn. The same limitation still applies, however: no mathematics, as there are already a dozen or more excellent books on the market — as well as other online documents — dealing with mathematical typesetting in TEX and LATEX in finer and better detail than I am capable of. ¶ The structure remains the same, but I have revised and rephrased a lot of material, especially in the earlier chapters where a new user cannot be expected yet to have acquired any depth of knowledge. Many of the screenshots have been updated, and most of the examples and code fragments have been retested. ¶ As I was finishing this edition, I was asked to review an article for The PracTEX Journal, which grew out of the Practical TEX Conference in 2004. The author specifically took the writers of documentation to task for failing to explain things more clearly, and as I read more, I found myself agreeing, and resolving to clear up some specific problems areas as far as possible. It is very difficult for people who write technical documentation to remember how they struggled to learn what has now become a familiar system. So much of what we do is second nature, and a lot of it actually has nothing to do with the software, but more with the way in which we view and approach information, and the general level of knowledge of computing. If I have obscured something by making unreasonable assumptions about your knowledge, please let me know so that I can correct it. Peter Flynn is author of The HTML Handbook and Understanding SGML and XML Tools, and editor of The XML FAQ. |
This document is Copyright © 1999–2005 by Silmaril Consultants under the terms of what is now the GNU Free Documentation License (copyleft). Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included in the section entitled The GNU Free Documentation License. You are allowed to distribute, reproduce, and modify it without fee or further requirement for consent subject to the conditions in section D.5. The author has asserted his right to be identified as the author of this document. If you make useful modifications you are asked to inform the author so that the master copy can be updated. See the full text of the License in Appendix D. |
This book originally accompanied a 2-day course on using the LATEX typesetting system. It has been extensively revised and updated and can now be used for self-study or in the classroom. It is aimed at users of Linux, Macintosh, or Microsoft Windows but it can be used with LATEX systems on any platform, including other Unix workstations, mainframes, and even your Personal Digital Assistant (PDA).
The audience for the original training course was assumed to be computer-literate and composed of professional, business, academic, technical, or administrative computer users. The readers of the book (you) are mostly assumed to be in a similar position, but may also come from many other backgrounds, including hobbyists, students, and just people interested in quality typesetting. You are expected to have one or more of the following or similar objectives:
producing typesetter-quality formatting;
formatting long, complex, highly-structured, repetitive, or automatically-generated documents;1
saving time and effort by automating common tasks;
achieving or maintaining your independence from specific makes or models of proprietary hardware, software, or file formats (portability);
using Open Source software (free of restrictions, sometimes also free of charge).
LATEX is a very easy system to learn, and requires no specialist knowledge, although literacy and some familiarity with the publishing process is useful. It is, however, assumed that you are completely fluent and familiar with using your computer before you start. Specifically, effective use of this document requires that you already know and understand the following very thoroughly:
how to use a good plain-text editor (not a wordprocessor like OpenOffice, WordPerfect, or Microsoft Word, and not a toy like Microsoft Notepad);
where to find all 95 of the printable ASCII characters on your keyboard and what they mean, and how to type accents and symbols, if you use them;
how to create, open, save, close, rename, move, and delete files and folders (directories);
how to use a Web browser and/or File Transfer Protocol (FTP) program to download and save files from the Internet;
how to uncompress and unwrap (unzip or detar) downloaded files.
If you don't know how to do these things yet, it's important to go and learn them first. Trying to become familiar with the fundamentals of using a computer at the same time as learning LATEX is not likely to be as effective as doing them in order.
These are not specialist skills — they are all included in the European Computer Driving Licence (ECDL) and the relevant sections of the ECDL syllabus are noted in the margin above, so they are well within the capability of anyone who uses a computer.
By the end of this book, you should be able to undertake the following tasks:
use a plain-text editor to create and maintain your documents;
add LATEX markup to identify your document structure and formatting requirements;
typeset LATEX documents, correct simple formatting errors, and display or print the results;
identify, install, and use additional packages (using CTAN for downloading where necessary);
recognise the limitations of procedural markup systems and choose appropriate generic markup methods where appropriate.
The original course covered the following topics as separate sessions, which are represented in the book as chapters:
Where to get and how to install LATEX (teTEX, fpTEX, or proTEXt from the TEX Collection disks);
How to type LATEX documents: using an editor to create files (half a dozen editors for LATEX);
Basic structures (the Document Class Declaration and its layout options; the document environment with sections and paragraphs);
Typesetting, viewing, and printing;
The use of packages and CTAN to adapt formatting using standard tools;
Other document structures (lists, tables, figures, images, and verbatim text);
Textual tools (footnotes, marginal notes, cross-references, indexes and glossaries, and bibliographic citations);
Typographic considerations (white-space and typefaces; inline markup and font changes; extra font installation and automation);
Programmability and automation (macros and modifying LATEX's behaviour);
Conversion and compatibility with other systems (XML, Word, etc.).
A few changes have been made in the transition to printed and online form, but the basic structure is the same, and the document functions as a workbook for the course as well as a standalone self-teaching guide.
It is important to note that the document does not cover mathematical typesetting, complex tabular material, the design of large-scale macros and document classes, or the finer points of typography or typographic design, although it does refer to these topics in passing on a few occasions.
There are several other guides, introductions, and ‘get-started’ documents on the Web and on CTAN which cover these topics and more. Among the more popular are:
Getting Started with TEX, LATEX, and friends, where all beginners should start;
The (Not So) Short Guide to LATEXε: LATEXε in 131 Minutes is a good beginner's tutorial;
A Gentle Introduction to TEX: A Manual for Self-Study is a classic tutorial on Plain TEX;
Using imported graphics in LATEXε shows you how to do (almost) anything with graphics: side-by-side, rotated, etc.;
Short Math Guide for LATEX gets you started with the American Math Society's powerful packages;
A comprehensive list of symbols in TEX shows over 2,500 symbols available.
This list was taken from the CTAN search page. There are also lots of books published about TEX and LATEX: the most important of these for users of this document are listed in the last paragraph in the Foreword.
Because the TEX program (the ‘engine’ which actually does the typesetting) is separate from whichever editor you choose, TEX-based systems are available in a variety of different modes using different interfaces, depending on how you want to use them.
The normal way to run LATEX is to use a toolbar button (icon), a menu item, or a keystroke in your editor. Click on it and your document gets saved and typeset. All the other features of LATEX systems (the typeset display, spellchecker, related programs like makeindex and BIBTEX) are run the same way. This works both in a normal Graphical User Interface (GUI) as well as in text-only interfaces.
In the popular LATEX editors like Emacs, TEXshell, TEXnicCenter, WinShell, or WinEdt, a record of the typesetting process is shown in an adjoining window so that you can see the progress of pages being typeset, and any errors or warnings that may occur.2
However, the graphical interface
is useless if you want to run LATEX unattended, as part of an
automated system, perhaps in a web server or e-commerce
environment, where there is no direct connection between
user and program. The underlying TEX engine is in fact
a Command-Line Interface (CLI) program,
that is, it is used as a
‘console’ program which you run from
a standard Unix or Mac terminal or shell window (or from an
MS-DOS command window in Microsoft Windows systems). You
type the command
latex followed by the name of your
document file (see in section 4.1.2 for an example).
Commands like these let you run LATEX in an automated environment like a Common Gateway Interface (CGI) script on a web server or a batch file on a document system. All the popular distributions for Unix and Windows, both free and commercial, include this interface as standard (teTEX, fpTEX, MiKTEX, proTEXt, PC-TEX, TrueTEX, etc.).
LATEX usually displays your typeset results in a separate window, redisplayed automatically every time the document is reprocessed, because the typesetting is done separately from the editing. Some systems, however, can format the typesetting while you type, at the expense of some flexibility.
- Asynchronous typographic displays
This method is called an asynchronous typographic display because the typeset window only updates after you have typed something and reprocessed it, not while you are still typing, as it would with a wordprocessor.3
- Synchronous typographic displays
Some distributions of LATEX offer a synchronous typographic interface. In these, you type directly into the typographic display, as with a wordprocessor. Three popular examples are Textures, Scientific Word, and VTEX (see table below). At least one free version (LYX, see Figure 2.1 in section 2.3) offers a similar interface.
With a synchronous display you get Instant Textual Gratification™, but your level of control is restricted to that of the GUI you use, which cannot provide access to everything that LATEX can do. For complete control of the formatting you may still need access to your normal source (input) file in the same way as for asynchronous implementations.
- Near-synchronous displays
There are several other methods available free for Unix and some other systems for close-to-synchronous updates of the typeset display (including Jonathan Fine's Instant Preview and the TEX daemon), and for embedding typographic fragments from the typeset display back into the editor window (David Kastrup's preview-latex package).
Whatever method you choose, the TEX Collection CD and CTAN are not the only source of software. The vendors listed in Table offer excellent commercial implementations of TEX and LATEX, and if you are in a position where their enhanced support and additional features are of benefit, I urge you to support them. In most cases their companies, founders, and staff have been good friends of the TEX and LATEX communities for many years.
| Product | Platform | Company | URI |
|---|---|---|---|
| PCTEX | MS-Windows | Personal TEX, Inc | www.pctex.com/ |
| TrueTEX | MS-Windows | True TEX | truetex.com/ |
| Textures | Apple Mac | Blue Sky Research | www.bluesky.com/ |
| Scientific Word | MS-Windows | Mackichan Software | www.mackichan.com/ |
| VTEX | MS-Windows, Linux, OS/2 | MicroPress, Inc | www.micropress-inc.com/ |
This document is written and maintained in XML, using a customized version of the DocBook DTD. Conversions were made to HTML and LATEX using XSLT scripts and Michael Kay's Saxon processor.
The complete source, with all ancillary files, is available online at http://www.ctan.org/tex-archive/info/beginlatex/src/ but if you want to try processing it yourself you must install Java (from Sun, IBM, or a number of others) and Saxon (from http://saxon.sourceforge.net/), in addition to LATEX.
This document is published under the terms and conditions of the GNU Free Documentation License. Details are in this appendix.
The following typographic notations are used:
| Notation | Meaning |
|---|---|
\command |
Control sequences which perform an
action, e.g. \newpage |
| \length | Control sequences which store a dimension (measurement in units), e.g. \parskip |
| counter | Values used for counting (whole numbers, as opposed to measuring in units), e.g. secnumdepth |
| term | Defining instance of a new term |
| environment | A LATEX formatting environment |
| package | A LATEX package (available from CTAN) |
| product | Program or product name |
typewriter type |
Examples of source code (stuff you type) |
| mybook or value | Mnemonic examples of things you have to supply real-life values for |
| x | A key on your keyboard |
| Ctrl–x | Two keys pressed together |
| Esc q | Two keys pressed one after another |
| Submit | On-screen button to click |
| → | Drop-down menu with items |
Examples of longer fragments of input are shown with a border round them. Where necessary, the formatted output is shown immediately beneath. Warnings are shown with a shaded background. Exercises are shown with a double border.
As noted in this Introduction, this document accompanies a two-day introductory training course. It became obvious from repeated questions in class and afterwards, as well as from general queries on comp.text.tex that many people do not read the FAQs, do not use the TUG web site, do not buy the books and manuals, do not use the newsgroups and mailing lists, and do not download the free documentation. Instead, they try to get by using the training technique known as ‘sitting by Nelly’, which involves looking over a colleague's shoulder in the office, lab, library, pub, or classroom, and absorbing all his or her bad habits.
In the summer of 2001 I presented a short proposal on the marketing of LATEX to the annual conference of the TEX Users Group held at the University of Delaware, and showed an example of a draft brochure designed to persuade newcomers to try LATEX for their typesetting requirements. As a result of questions and suggestions, it was obvious that it needed to include a pointer to some documentation, and I agreed to make available a revised form of this document, expanded to be used outside the classroom, and to include those topics on which I have had most questions from users over the years.
It turned out to mean a significant reworking of a lot of the material. Some of it appears in almost every other manual and book on LATEX but it is essential to the beginner and therefore bears repetition. Some of it appears other forms elsewhere, and is included here because it needs explaining better. And some of it appears nowhere else but this document. I took the opportunity to revise the structure of the training course in parallel with the book (expanding it from its original one day to two days), and to include a more comprehensive index. It is by no means perfect (in both senses), and I would be grateful for comments and corrections to be sent to me at the address given under the credits.
I had originally hoped that the LATEX version of the document would be processable by any freshly-installed default LATEX system, but the need to include font samples which go well beyond the default installation, and to use some packages which the new user is unlikely to have installed, means that this document itself is not really a simple piece of LATEX, however simply it may describe the process itself.
However, as the careful reader will have already noticed, the master source of the document is not maintained in LATEX but in XML. A future task is therefore to compare the packages required with those installed by default, and flag portions of the document requiring additional features so that an abbreviated version can be generated which can be guaranteed to process even with a basic LATEX installation.
If you are just starting with LATEX, at an early opportunity you should buy or borrow a copy of LATEX: A Document Preparation System which is the original author's manual. More advanced users should get the The LATEX Companion or one of its successors. In the same series there are also the The LATEX Graphics Companion and the The LATEX Web Companion. Mathematical users might want to read Short Math Guide for LATEX.
Many people discover LATEX after years of struggling with wordprocessors and desktop publishing systems, and are amazed to find that TEX has been around for over 25 years and they hadn't heard of it. It's not a conspiracy, just ‘a well-kept secret known only to a few million people’, as one anonymous user has put it.
Perhaps a key to why it has remained so popular is that it removes the need to fiddle with the formatting while you write. Although playing around with fonts and formatting is attractive to the newcomer, it is completely counter-productive for the serious author or editor who wants to concentrate on writing — ask any journalist or professional writer.
A few years ago a new LATEX user expressed concern on the comp.text.tex newsgroup about ‘learning to write in LATEX’. Some excellent advice was posted in response to this query, which I reproduce with permission below [the bold text is my emphasis]:
No, the harder part might be writing, period. TEX/LATEX is actually easy, once you relax and stop worrying about appearance as a be-all-and-end-all. Many people have become ‘Word Processing Junkies’ and no longer ‘write’ documents, they ‘draw’ them, almost at the same level as a pre-literate 3-year old child might pretend to ‘write’ a story, but is just creating a sequence of pictures with a pad of paper and box of Crayolas — this is perfectly normal and healthy in a 3-year old child who is being creative, but is of questionable usefulness for, say, a grad student writing a Master's or PhD thesis or a business person writing a white paper, etc. For this reason, I strongly recommend not using any sort of fancy GUI ‘crutch’. Use a plain vanilla text editor and treat it like an old-fashioned typewriter. Don't waste time playing with your mouse.
Note: I am not saying that you should have no concerns about the appearance of your document, just that you should write the document (completely) first and tweak the appearance later...not [spend time on] lots of random editing in the bulk of the document itself.
(11 March 2003), comp.text.tex
Learning to write well can be hard, but authors shouldn't have to make things even harder for themselves by using manually-driven systems which break their concentration every few seconds for some footling adjustment to the appearance, simply because the software is incapable of doing it right by itself.
Don Knuth originally wrote TEX to typeset mathematics for the second edition of his master-work The Art of Computer Programming, and it remains pretty much the only typesetting program to include fully-automated mathematical formatting done the way mathematicians want it. But he also published a booklet called Mathematical Writing which shows how important it is to think about what you write, and how the computer should be able to help, not hinder.
And TEX is much more than math: it's a programmable typesetting system which can be used for almost any formatting task, and LATEX has made it usable by almost anyone. Professor Knuth generously placed the entire system in the public domain, so for many years there was no publicity of the commercial kind which would have got TEX noticed outside the technical field.
Nowadays, however, there are many companies selling TEX software or services,1 dozens of publishers accepting LATEX documents for publication, and hundreds of thousands of users using LATEX for millions of documents.2
To count yourself as a TEX or LATEX user, visit the TEX Users Group's ‘TEX Counter’ web site (and get a nice certificate!).
There is occasionally some confusion among newcomers between the two main programs, TEX and LATEX:
TEX is a typesetting program, originally written by Prof Knuth at Stanford around 1978. It implements a macro-driven typesetters' programming language of some 300 basic operations and it has formed the core of many other desktop publishing (DTP) systems. Although it is still possible to write in the raw TEX language, you need to study it in depth, and you need to be able to write macros (subprograms) to perform even the simplest of repetitive tasks.
LATEX is a user interface for TEX, designed by Leslie Lamport at Digital Equipment Corporation (DEC) in 1985 to automate all the common tasks of document preparation. It provides a simple way for authors and typesetters to use the power of TEX without having to learn the underlying language. LATEX is the recommended system for all users except professional typographic programmers and computer scientists who want to study the internals of TEX.
Both TEX and LATEX have been constantly updated since their inception. Knuth has now frozen development of the TEX engine so that users and developers can have a virtually bug-free, rock-stable platform to work with.3 Typographic programming development continues with the New Typesetting System (NTS), planned as a successor to TEX. The LATEX3 project has taken over development of LATEX, and the current version is LATEXε, which is what we are concentrating on here. Details of all developments can be had from the TUG at http://www.tug.org
CHAPTER
|
Installing TEX and LATEX |
|
This course is based on using one of the following distributions of TEX on the 2004 TEX Collection DVD or the 2003 TEX Live CD:
- teTEX
for Linux and other Unix-like systems, including Mac OS X (Thomas Esser);
- proTEXt
for Microsoft Windows (Thomas Feuerstack), based on Christian Schenk's MikTEX;
- fpTEX
for Microsoft Windows (Fabrice Popineau) from the 2003 TEX Live CD.
Many other implementations of TEX, such as Tom Kiffe's CMacTEX for the Apple Macintosh, can be downloaded from CTAN. LATEX is included with all modern distributions of TEX.
The TEX Collection CD is issued annually on behalf of most of the local TEX user groups around the world (see http://www.tug.org/lugs.html for addresses), and edited by Sebastian Rahtz, Karl Berry, Manfred Lotz, and the authors of the software mentioned above. These people give an enormous amount of their personal time and energy to building and distributing these systems, and they deserve the thanks and support of the user community for all they do.
There are many other distributions of LATEX both free and commercial, as described in this Introduction: they all process LATEX identically, but there are some differences in size, speed, packaging, and (in the case of commercial distributions) price, support, and extra software provided.
One final thing before we start: publicly-maintained software like TEX is updated faster than commercial software, so always check to see if there is a more recent version of the installation. See the item ‘Use the latest versions’ in section 1.4.3 for more details.
When you install LATEX you will have the opportunity to decide a) which plain-text editor[s] you want to use to create and maintain your documents; and b) which preview programs you want to use to see your typesetting. This isn't much use to you if you're unfamiliar with editors and previewers, so have a look at the table below, and maybe flip ahead to section 2.3 for a moment, where there are descriptions and screenshots.
The best bet is probably to install more than one — if you've got the disk space — or maybe all of them, because you can always delete the ones you don't like.
- Editors
There is a wide range of editors available: probably no other piece of software causes more flame-wars in Internet and other discussions than your choice of editor. It's a highly personal choice, so feel free to pick the one you like. My personal biases are probably revealed below, so feel equally free to ignore them.
- Previewers
For displaying your typesetting before printing, you will need a previewer. All systems come with a DVI previewer for standard LATEX, but if you are intending to produce industry-standard PostScript or PDF (Adobe Acrobat) files you will need a previewer for those formats. GSview displays both PostScript and PDF files; xpdf and Adobe's own Acrobat Reader just display PDF files.
For brief details of some of the most popular editors used for LATEX, see section 2.3.
Additional downloads
For licensing reasons, the GSview PostScript/PDF previewer, the Acrobat Reader PDF previewer, and the WinEdt editor could not be distributed on the 2003 CDs. In those cases you have to download and install them separately.
GSview is available for all platforms from http://www.ghostscript.com/gsview/index.htm (on Unix and VMS systems it's also available as GhostView and gv: see http://www.cs.wisc.edu/~ghost/)
Acrobat Reader (all platforms) can be downloaded from http://www.adobe.com/products/acrobat/readstep2.html
WinEdt (Microsoft Windows only) comes from http://www.winedt.com
Make sure your system libraries and utilities are up to date. If you are using Red Hat Linux, use yum or up2date to download and install updates. For Debian and other distributions, use apt-get or similar. On Red Hat systems, remove any RPM version of teTEX and associated utilities which may have been preinstalled, in order to avoid version conflicts.
If you are installing TEX Live to a new partition, and you have the opportunity to reformat the partition before use, use mkfs with a granularity as small as it will go (usually 1024 bytes). This avoids the partition running out of inodes because TEX uses very large numbers of very small files.
Plan the installation carefully if you are installing for multiple users (a shared machine): read section 5.2 for some comments on where to put additional files downloaded later, and see the FAQ on the same topic at http://www.tex.ac.uk/cgi-bin/texfaq2html?label=wherefiles
Above all, Read The Fine
Manual (RTFM). The documentation is in
live.html and
live.pdf on the disk in the directory
texlive2004/texmf-doc/doc/english/texlive-en/
# cd /mnt/cdrom/texlive2004 # sh install-tl.sh
The installer runs in a shell window, so it can be done even from headless systems (those with no X Window client), but it does need to be installed as root if you want to stick with the default directory locations or install it system-wide for multiple users. To install, just type the commands shown above.
The options are mostly self-explanatory, and beginners should pick the recommended scheme and leave all other settings at their defaults. The character-driven interface lets you browse around the settings changing things and looking at options before you commit to installing anything.
==================> TeX Live installation procedure <=================
===> Note: Letters/digits in <angle brackets> indicate menu items <===
===> for commands or configurable options <===
Proposed platform: Intel x86 with GNU/Linux
<P> over-ride system detection and choose platform
<B> binary systems: 1 out of 10
<S> Installation scheme (scheme_recommended)
[customizing installation scheme:
<C> standard collections <L> language collections]
20 out of 75, disk space required: 246857 kB
<D> directories:
TEXDIR (The main TeX directory) : /usr/TeX
TEXMFLOCAL (Directory for local styles etc): /usr/TeX/texmf-local
VARTEXMF (Directory for local config) : /usr/TeX/texmf-var
<O> options:
[ ] alternate directory for generated fonts ()
[ ] create symlinks in standard directories
[ ] do not install macro/font doc tree
[ ] do not install macro/font source tree
<R> do not install files, set up to run off CD or DVD
<I> start installation
<H> help, <Q> quit
Enter command:
‘Collections’ (the C and L options) are groups of LATEX packages that you can include or exclude. It's best to leave this alone unless you know you need something specific. The only options I sometimes set are under O: the ‘alternate directory for generated fonts’ may need to be on a different partition for performance reasons on a shared system; and I always select ‘create symlinks in standard directories’ so that the system works immediately after the post-installation configuration (after installation, run texconfig to adjust your local settings.
Note that the Linux/Unix installation does not install any editors: it is assumed you can do this yourself from your distribution's standard package system (most likely you will already be using Emacs or vi anyway).
This is exactly the same interface as for the Linux/Unix installation. You need the bash shell (see the warning in the manual for users of older systems).
There is a choice of graphical editors for the Mac: two are included on the DVD, TEXShop and ITEXMac, but they need to be installed separately, after installing TEX.
Before you install TEX, make sure you have enough disk space: the default installation takes about 350Mb on a modern filesystem. The installation assumes you have a fully updated version of Windows, so visit the Microsoft Web site first (http://www.microsoft.com/) and click on Windows Update. Select and install all the relevant updates for your operating system (Windows 95, 98, ME, 2000, NT, or XP). You should be doing this regularly anyway, to keep your system healthy. You may want to run ScanDisk and give your hard disks a full surface check. TEX consists of a very large number of quite small files, so it's important that your disk is in good order.
When you insert the distribution DVD or CD, it should start the setup program automatically. If you have auto-run turned off, open My Computer, double-click on the DVD or CD drive, and then double-click Autorun to start the setup program.1
Setup.exe instead,
or (for the TEX
Collection 2003 CD) go to the tpm
folder and double-click on
TeXSetup.exe.For proTEXt from the TEX Collection DVD, follow the instructions in the PDF documentation which opens automatically when you start the setup.
The documentation contains links (in large blue type) that you click on in sequence to run the installation process. (This is actually very good: everything worked first time when I did it on XP.) Basically, you need to install a) MIKTEX; b) either WinEdt (with or without some of its add-ons) or TEXnicCenter; and c) GhostScript and GSview.
You only need to install items step 3 to step 5 if you install WinEdt.
proTEXt uses the MIKTEX distribution as its core, a long-established and popular distribution for Windows.
This is optional: it's a good editor, especially for the heavy user of a MIKTEX-based system. This is a free month's trial — after that it reminds you to cough up and register.
Optional again, and only applicable if you installed WinEdt anyway. It lets you save commonly-used document settings for use in other documents of the same type.
Another optional add-on for WinEdt to provide drag-and-drop graphics insertion.
Last optional add-on for WinEdt, providing a new table editor.
This is a free equivalent to WinEdt. The interface is slightly different (see Figure 1.2) but it is becoming very popular.
These are essential for viewing the PostScript and PDF output, especially if you don't have any other PDF viewer installed.
You get a choice of editors, but the one which features in proTEXt is TEXnicCenter. This is an Integrated Development Environment (IDE) which lets you manage all the files related to each document. In many cases, of course, you'll only have one (the text itself) but if you are working with anything beyond simple articles, you'll probably have illustrations (images or diagrams), and possibly separate chapter files for larger documents, plus indexes, glossaries, bibliographies, etc. I recommend that you create a new project for each new document, even if it's a single-file article, as I did for the example in Figure 1.2.
Install LATEX itself from the → menu. If you're new to LATEX, pick Quick Install on the following screen. This gives you everything you need to get started, and doesn't ask any questions, it just installs it all straight away.
If you're installing under Windows NT, 2000, or XP, you may want to click on the option to install for all users if you have other users on your system.
If you want to use Emacs as your editor, click the option for XemTEX Support.2
After installation, right-click and drag
Xemacs.exe from the
C:\Program Files\TeXLive\bin\win32
folder out onto your desktop and let go, then pick
‘Create Shortcut’. This places
Emacs on your desktop for
easy access.
If you want to install
WinShell, run the installer
program in the support/winshell
directory. For WinEdt you
must go to their Web site (http://www.winedt.com/) for a
downloadable version.
You don't have to install just one editor: if you've got the space, install them all so you can try them out. You can always uninstall the ones you don't want afterwards.
Ghostscript is installed automatically, but for GSView you need to go to http://www.cs.wisc.edu/~ghost/gsview/, and download the most recent version.
If you use GSView, please register your copy with Ghostgum, Pty. (http://www.ghostgum.com.au/).
Please read the TEX Live update pages at http://www.tug.org/texlive/bugs.html for details of any changes since the disks were released, and download and install any additional software required.
It's always annoying when a program that's supposed to install painlessly causes trouble, and none the more so when everyone else seems to have been able to install it without problems. I've installed TEX hundreds of times and very rarely had any difficulties, but these are a few of the occasions when I did.
- Bad hard disks
As recommended in section 1.4, run a scan and defragmentation of your hard disk[s] before you start. It should take under an hour on a modern machine unless you have a very large disk, and it may need overnight on an older machine. Clean your CD or DVD drive if it's been in heavy use. TEX uses a very large number of very small files, so there is a lot of disk activity during an installation. As also recommended in section 1.2, if you have the chance to reformat the hard disk, pick the smallest granularity (cluster size) possible.
- Registry errors
This only affects Microsoft Windows users. The Registry is where Microsoft want software companies automatically to store details of all the programs you install. Unfortunately the Registry is grossly abused by marketing departments to try and foist undesirable links on you, the user. You will see this with many commercial programs, where a particular type of file you've been able to double-click on for years suddenly runs a different program. Some programs install obsolete or broken copies of program libraries (DLL files), overwriting ones which were working perfectly. Worse, the viruses, trojans, and worms which typically infect unprotected Windows systems can leave unwanted links to web pages, or change some of the ways in which Windows operates. The overall effect can be that the whole machine slows down, or that files which are expected to do one thing do another. The best solution is a thorough Registry clean-out, using one of the many programs available for the purpose.
- Use the latest versions
Before installing, check the CTAN web site (http://www.ctan.org/ for any updated copy of the installation program. This is called
install-tl.shfor Linux and Mac systems, andSetup.exefor Microsoft Windows (on the TEX Collection 2003 CD it was calledTeXSetup.exe). Just occasionally a bug slips through onto the production CD or DVD, and although it's always fixed and notified on comp.text.tex, that's a high-volume newsgroup and even the sharpest eyes may miss an announcement.- Stick to the defaults
Unless you're a computer scientist or a software engineer, I suggest you never change or fiddle with the default directories for installation. I know some of them look odd, but they're that way for a purpose, especially when it comes to avoiding directories will spaces in their names, like the notorious
C:\Program Files. Although most modern systems cope happily with spaces in filenames and directory names, they are usually A Bad Design Idea, and should be avoided like the plague (spaces are forbidden in web addresses for the same reason: the people who designed them knew the pitfalls). It may look snazzier to put the installation inMy Cute Stuff, but please don't: you'll just make it harder to find, harder to fix problems, and more embarrassing if you have to explain it to someone else trying to help you.
CHAPTER
|
Using your editor to create documents |
|
LATEX documents are all plain-text files.1 You can edit them with any editor, and transfer them to any other computer system running LATEX and they will format exactly the same. Because they are plain text they cannot corrupt your system, as they cannot be used for hiding or transporting virus infections as binary wordprocessor files can. Everything you can see is in the file and everything in the file is there for you to see: there is nothing hidden or secret and there are no manufacturers' proprietary ‘gotchas’ like suddenly going out of date with a new version.
In a LATEX document, you type your text along with markup which identifies the important parts of your document by name, for example ‘title’, ‘section’, ‘figure’, etc. LATEX does all the formatting for you automatically, using the markup to guide its internal rules and external stylesheets for typesetting.
You do not need to format any of your text in your editor, because LATEX does it all by itself when it typesets. You can of course regularise or neaten its appearance in your editor for ease of editing (for example, keeping each item in a list on a separate line), but this is not required.
You will often hear LATEX markup referred to as ‘commands’ or sometimes ‘control sequences’ (the proper TEXnical term for them). For all practical purposes these terms all mean the same thing.
This course assumes that users have one of TEXshell, TEXnicCenter, WinShell, or WinEdt (Windows only), or Emacs or LYX (any platform) installed. These are discussed briefly in section 2.3, and the menus and toolbars for running LATEX are explained in Chapter 4.
If you already know all this stuff about editors and plain-text files and running programs, and you know your system is already correctly installed (including your editor), you'd probably like to type something in and see LATEX do its job. If you don't, then skip forward to section 2.4 and read a bit more about LATEX first.
\documentclass[12pt]{article}
\usepackage{palatino,url}
\begin{document}
\section*{My first document}
This is a short example of a \LaTeX\ document I wrote
on \today. It shows a few simple features of automated
typesetting, including
\begin{itemize}
\item setting the default font size to 12pt;
\item specifying `article' type for formatting;
\item using the Palatino typeface;
\item adding special formatting for URIs;
\item formatting a heading in `section' style;
\item using the \LaTeX\ logo;
\item generating today's date;
\item formatting a list of items;
\item centering and italicizing;
\item autonumbering the pages.
\end{itemize}
\subsection*{More information}
This example was taken from `Formatting Information',
which you can download from
\url{http://www.ctan.org/tex-archive/info/beginlatex/}
and use as a teach-yourself guide.
\begin{center}
\textit{Have a nice day!}
\end{center}
\end{document}
Make sure you have a properly-installed LATEX system and a copy of a suitable editor.
Open your editor and type in the text exactly as shown in Figure 2.1. Do not make any changes or miss anything out or add anything different at this stage.
Save the document as
demo.tex
Click on the LATEX or
pdfLATEX toolbar icon or the
→ menu item; or type latex
demo or pdflatex demo in a
command window.
Click on the DVI or PDFview toolbar icon or the → menu item; or type your previewer command in a terminal shell.
(Note that there may be a pause the first time you use your DVI viewer, while WYSIWYG font files are created.2)
Click on the Print toolbar icon
within the viewer, or use the
→
menu item, or type
dvips -f demo | lpr
(Unix/Linux).
If you encounter any errors, it means you do need to study this chapter after all!
All the text of your documents can be typed into your LATEX document from a standard keyboard using any decent plain-text editor. However, it is more convenient to