4Typesetting, Viewing and Printing
Total Page:16
File Type:pdf, Size:1020Kb
Typesetting, viewing 4and printing We’ve now got far enough to typeset what you’ve entered. I’m assuming at this stage that you have typed some sample text in the format specified in the previous chapter, and you’ve saved it in a plain•text file with a filetype of .tex and a name of your own choosing. Picking suitable filenames Never, ever use directories (folders) or file names which contain spaces. Although your op• erating system probably supports them, some don’t, and they will only cause grief and tears with TEX. Make filenames as short or as long as you wish, but strictly avoid spaces. Stick to upper• and lower•case letters without accents (A–Z and a–z), the digits 0–9, the hyphen (-), and the full point or period (.), (similar to the conventions for a Web URI): it will let you refer to TEX files over the Web more easily and make your files more portable. Formatting information ✄ 63 ✂ ✁ CHAPTER 4. TYPESETTING, VIEWING AND PRINTING Exercise 4.1: Saving your file If you haven’t already saved your file, do so now (some editors and interfaces let you type• set the document without saving it!). Pick a sensible filename in a sensible directory. Names should be short enough to display and search for, but descriptive enough to make sense. See the panel ‘Picking suitable file• names’ above for more details. 4.1 Typesetting Typesetting your document is usually done by clicking on a button in a toolbar or an entry in a menu. Which one you click on depends on what output you want — there are two formats available: A f The standard (default) LTEX program produces a device•independent (DVI) file which can be used with any TEX previewer or printer driver on any make or model of computer. There are dozens of these available: at least one of each (previewer and printer driver) should have been installed with your distribution of TEX. A f The pdfLTEX program produces an Adobe Acrobat PDF file which can be used with any suitable previewer, such as Okular, Foxit, GSview, xpdf, kpdf, or Adobe’s own Acrobat Reader. Depending on which one you choose, you may have to [re]configure your editor so that it runs the right program. They can all do all of them, but they don’t always come pre•set with buttons or menus for every possible option, because they can’t guess which one you want. 4.1.1 Running LATEX There are two ways of running LATEX: from the toolbar or menu, or from the command line. Toolbars and menus are most common in graphical systems, and are the normal way to run LATEX. Command lines are used in non•graphical systems and in automated processes where LATEX is run unattended (‘batch’ or ‘scripted’ processing). Whichever way you run LATEX, it will process your file and display a log or record of what it’s doing (see Exercise 3: it looks the same no matter what system you use). This is to let you see where (if!) there are any errors or problems. The log may appear in a subwindow or a new window, depending on your editor.1 1 Some recent versions of Emacs hide the log if there were no errors, and display it only if something went wrong. ✄ 64 Formatting information ✂ ✁ 4.1. TYPESETTING Exercise 4.2: Running LATEX from the toolbar or menu A Run LTEX on your file. According to which system you’re using this will either be the LATEX toolbar icon or the TEX menu item. TEX File Your editor may suggest you save your file if you haven’t already done so. Do it. If LATEX reports any errors — easily identifiable as lines in the log beginning with an exclamation mark (!) — don’t panic! Turn to § 4.2, identify what went wrong, and fix it in your input file. Then re•run LATEX. If there were no errors, your file is ready for displaying or printing. It is worth practising running LATEX from a command window even if you normally use a Graphical User Interface (GUI) (one with windows and a mouse), so that you understand what it does. See Figure 4.1 for an example. Exercise 4.3: Running LATEX in a terminal or console window f Under graphical Unix•based systems (Linux and Mac) you open a command (shell) window by clicking on the shell or screen icon in the control panel at the bottom of your screen. f Under Microsoft Windows you open a command window by clicking on the Start Programs Start or menu item. MS•DOS Command Prompt When the command window appears, type cd followed by the name of the folder where you saved your sample document, then press the Enter or Return key: ☛ ✟ cd Documents latex quickstart ✡ ✠ Then type latex or pdflatex followed by the name you gave the sample document, and press the Enter or Return key. 4.1.2 Standard LATEX and pdfLATEX Your editor can be set up to run the original (‘standard’) LATEX and generate DVI files, or to run pdfLATEX and generate PDF files. Both produce identical output, and differ only in the graphics file formats they can handle (see § 6.5), and in some typographic advances like microjustification. Formatting information ✄ 65 ✂ ✁ CHAPTER 4. TYPESETTING, VIEWING AND PRINTING Figure 4.1: Command•line usage Apple Mac versions of LATEX come preset to produce PDF files. Emacs does not have a default menu configured for pdfLATEX but if you have already run standard LATEX on the file, you can type the pdflatex command in the *TeX-Shell* pane. 4.2 Errors and warnings LATEX describes what it’s typesetting while it does it, and if it encounters something it doesn’t understand or can’t do, it will display a message saying what’s wrong. It may also display warnings for less serious conditions. Don’t panic if you see error messages: it’s very common for beginners to mistype or mis•spell commands, forget curly braces, type a forward slash instead of a backslash, or use a special character by mistake. Errors are easily spotted and easily corrected in your editor, and you can then run LATEX again to check you have fixed everything. Some of the most common errors are described in § 4.2 with an explanation of how to fix them. Some editors show hotlinks in the LATEX log window where you can click on an error message and the cursor will jump to the line in your document where the error was spotted. ✄ 66 Formatting information ✂ ✁ 4.2. ERRORS AND WARNINGS 4.2.1 Error messages The format of an error message is always the same. Error messages begin with an exclamation mark at the start of the line, and give a description of the error, followed by another line starting with the number, which refers to the line•number in your document file which LATEX was processing when the error was spotted. Here’s an example, showing that the user mistyped the \tableofcontents command: ☛ ✟ ! Undefined control sequence. l.6 \tableofcotnetns ✡ ✠ When LATEX finds an error like this, it displays the error message and pauses. You must type one of the following letters to continue: Key Meaning ✄x Stop immediately and exit the program. ✂ ✁ ✄q Carry on quietly as best you can and don’t bother me with any more error ✂ ✁ messages. ✄e Stop the program but re•position the text in my editor at the point where you ✂ ✁ found the error.a ✄h Try to give me more help. ✂ ✁ ✄i (followed by a correction) means input the correction in place of the error and ✂ ✁ carry on.b a. This only works if you’re using an editor which LATEX can communicate with. b. This is only a temporary fix to get the file processed. You still have to make that correction in the editor. Some systems (Emacs is one example) run LATEX with a ‘non•stop’ switch turned on, so it will always process through to the end of the file, regardless of errors, or until a limit is reached. 4.2.2 Warnings Warnings don’t begin with an exclamation mark: they are just comments by LATEX about things you might want to look into, such as overlong or underrun lines (often caused by unusual hyphenations, for example), pages running short or long, and other typographical niceties (most of which you can ignore until later). Unlike other systems, which try to hide unevennesses in the text — usually unsuccessfully — by interfering with the letter•spacing, LATEX takes the view that the author or editor should be able to contribute. While it is certainly possible to set LATEX’s parameters so that the spacing is sufficiently Formatting information ✄ 67 ✂ ✁ CHAPTER 4. TYPESETTING, VIEWING AND PRINTING sloppy that you will almost never get a warning about badly•fitting lines or pages, you will almost certainly just be delaying matters until you start to get complaints from your readers or publishers. 4.2.3 Examples Only a few common error messages are given here: those most likely to be encountered by beginners. If you find another error message not shown here, and it’s not clear what you should do, ask for help. Most error messages are self•explanatory, but be aware that the place where LATEX spots and reports an error may be later in the file than the place where it actually occurred. For example if you forget to close a curly brace which encloses, say, italics, LATEX won’t report this until something else occurs which can’t happen until the curly brace is encountered (eg the end of the document!) Some errors can only be righted by humans who can read and understand what the document is supposed to mean or look like.