TEACH LATEX Aaron Sloman Oct 1998 Revised May 2000 Revised 10 Feb 2008 The file TEACH * LATEX.TEX is a demonstration file showing how you can prepare a report in latex and then run it through latex, preview it, and either print it out or produce a postscript file which you can print out later. Latex, which is based on the older and more general, but harder to use system Tex, is a very powerful document preparation package, which enables you to produce very high quality printed documents. NOTE: Since this file was written it has become possible to use a command 'pdflatex' that produces PDF files from latex source files, without the need to first create a .dvi file then a .ps file then convert to .pdf, which used to be required. See also HELP LATEX http://www.cs.bham.ac.uk/research/projects/poplog/help/latex CONTENTS -- How Latex is used -- Why use Latex? -- Setting up your .login file -- How to use the TEACH LATEX.TEX file -- Further information -- Diagrams/Figures/Pictures in Latex -- Spelling checkers -- How Latex is used -------------------------------------------------- To use Latex (or Tex) you use your favourite editor to prepare a file (e.g. myfile.tex) which contains the text you wish to print and also formatting instructions. Then latex reads that file produces a new file (e.g. myfile.dvi) which is in a "device independent" format, but which has all the information required to display the document on various devices, e.g. printers, display screens. There is a viewer called "xdvi" which can be used to display the document on the screen using the X window system (e.g. on Unix workstations, X terminals or PCs running eXceed). Another program called "dvips" can convert the .dvi file to a postscript file (e.g. myfile.ps) which is suitable for printing on a printer with multiple fonts and graphical capabilities. Postscript files can also be viewed on the screen using the "gv" viewer. Another unix utility "ps2pdf" can convert a postscript file to a PDF file (e.g. myfile.pdf) for viewing using the Acrobat Reader tool (acroread), which is available on various machines besides Unix systems, along with other freely available readers for pdf, e.g. xpdf, kpdf, evince. See also HELP * LATEX It is also possible for postscript or graphical files (.jpg, .png) produced in some other way (e.g. using graphical tools like Xfig or Tgif) to be imported into a latex file, so that the final document has figures or pictures included. There is a tool, "latex2html" which can be used to convert Latex files to html format for viewing on the web. A more recent file is "tth" which sometimes produces better results, and is much faster. -- Why use Latex? ----------------------------------------------------- Latex is used by many mathematicians, physicists, computer scientists, engineers partly because for many years it has been the most sophisticated document preparation system for producing papers containing logical and mathematical formulae. There are many conferences which require papers to be submitted in Latex format, and some journals prefer it. The main reason why it is used is probably personal preference. Some people prefer a "WYSIWYG" (What You See Is What You Get) word processor where you constantly have a view of the format of the final document. Others prefer to type their text in without caring about the final format, leaving that to formatting commands which can be made to produce the desired style. The same document can then be formatted in different ways by changing the Latex "style" files used. Latex is available free of charge (unlike Microsoft Word) for many computers and operating systems (unlike Microsoft Word, which is not portable), and there is a growing collection of tools for using latex, also free of charge. For example, some of the facilities described below in for use in Ved are programmed to run latex and its associated utilities without leaving the editor. There are probably similar facilities available for Emacs users. In fact Latex is rather awful to use on its own, as it does not have a friendly user interface. But that is compensated for by its power. So by invoking it from Ved you can use its power while avoiding its unpleasant interface. Many people who do not like using Latex at first, end up using it as their preferred means of producing project reports, articles, PhD theses, books, etc. -- Setting up your .login file ---------------------------------------- Before you can run Latex, however, you have to set up your .login file so as to enable latex when you log in. The following instructions are applicable in the School of Computer Science at Birmingham but may not be required in other places: Edit your .login file, and look for this line: # setup Latex # Set up TeX and LaTeX remove the first "#", and replace "Latex" with "Tetex", leaving setup Tetex # Set up TeX and LaTeX (using the Tetex package) After that Latex and its associated utilities will work the next time you log in. If you don't want to have to log out and then log in again after doing that, you can leave Ved, and at the shell prompt in an xterm window type this command: setup Tetex That will tell the unix system which directories to add to search lists needed by latex, by modifying some Unix environment variables. (See HELP SHELL) You can then start XVED by typing the following: xved & and you should be able to follow the instructions in the file TEACH * LATEX.TEX -- How to use the TEACH LATEX.TEX file -------------------------------- There are instructions at the beginning of the teach file in the form of "comments" preceded by the Latex comment symbol "%". The comments will tell you in detail what to do. But here is a quick overview. Get the teach file into VED. 1. Rename the file something like myproject.tex, e.g. ENTER name myproject.tex 2. Run the file through latex by doing this in VED: ENTER latex You will get some output in a latex "log file" in a new Ved window, (It also creates files myproject.aux myproject.log myproject.dvi on the magnetic disk, but not in VED.) 3. Quit that log file, then re-do ENTER latex (The second time it builds a table of contents) Quit the log file again. 4. View the result by doing this: ENTER xdvi That should cause Ved to invoke the "xdvi" previewer showing how your latex file will look if printed on a laser printer. 5. Move the mouse pointer into the XDVI window. If you press the SPACE bar or RETURN it will show the next page. If you press the "B" key it will show the previous page Examine the file to get a feel for its contents. There should be a header followed by table of contents, then numbered sections, then a bibliography, then some appendices including program code. (You can learn more about the xdvi program and how to control it in the Unix documentation file file MAN xdvi) 6. Go back to your Ved file and look at the text in the myproject.tex file starting from the line \begin{document} Try to work out how the contents of the file generate what you see in the xdvi previewer. Note that mostly latex automatically formats your code, but you don't want it to do that for programs or for program output. See how re-formatting is suppressed by: \begin{verbatim} \end{verbatim} 7. Try changing some of the text in Ved file and then redo the "ENTER latex" command After redoing it you can get the previewer to "refresh" itself by iconising and de-iconising it, or partially covering and uncovering it. More information can be found at the end of the latex file, after \end{document} -- Further information ------------------------------------------------ Note there are two versions of Latex, The old one: latex209 The new one: latex2e The initial header line of the old style latex file is different from the header line of a new style latex file. The VED "ENTER latex" command has been defined to check the header and use that to decide whether to invoke latex209 or latex2e. For a great deal more information on latex see: HELP * LATEX which is also accessible (at Birmingham) as /bham/doc/help/latex At Birmingham you can also give this address to a web browser /bham/doc/latex-help/LaTeX.html There are books on Latex, e.g. Leslie Lamport, LaTeX - A Document Preparation System, Addison-Wesley, 1985, and various Unix "man" files giving further information, which can be invoked in VED with the "ENTER man " command MAN latex MAN xdvi MAN bibtex MAN tex MAN gv MAN ps2pdf MAN pdf2ps To get very brief information about latex2html give the command latex2html -h There really ought to be a MAN file for it. -- Diagrams/Figures/Pictures in Latex --------------------------------- You can use various LaTeX commands to draw pictures, but this requires you to work out co-ordinates of lines, circles, etc. and can be tedious. (See the section on "pictures" in the Lamport book.) It is generally easier to use a drawing package to produce a postscript file, and then import that into your latex file. Postscript files, which can contain diagrams or pictures can be imported into a latex file by including commands which specify where the postscript files are and where they are to be included in the final document. (You don't copy the postscript into your latex file.) There is some information about how to do that in the HELP LATEX file. Look for sections on the Figure environment and on PostScript figures. There are several drawing packages available on unix systems. One of the most popular is called xfig, and is described briefly in MAN xfig It is very powerful, but some people find it a little unintuitive to use, and prefer a different package called TGIF, described in MAN tgif In general the best way to learn to use packages like xfig and tgif is to have somebody give you a demonstration. At some later stage I may extend this file with examples showing how to produce figures, and also how to include a bibliography and inline citations using the bibtex command. (See HELP VED_BIB). See the comment about \usepackage{graphicx} in HELP * LATEX -- Spelling checkers -------------------------------------------------- In Unix instead of monolithic packages to do everything there are usually different packages available for sub-tasks and users can choose to combine the ones that suit them best. There are two main Unix spelling checkers: The older one is described in MAN spell, and is accessible from VED as described in HELP ved_spell. The more sophisticated newer version (more likely to be on Linux systems) called "ispell" (because it can be used as an interactive spelling checker), is described in "MAN ispell" and can be invoked from Ved to check your latex and other documentation files, as described in the HELP ved_ispell file. This is likely to be superseded by "aspell", whose use in Ved is described in HELP ved_aspell . --- $poplocal/local/ved_latex/teach/latex --- Linked to $poplocal/local/teach/latex --- $usepop/pop/packages/vedlatex/teach/latex --- Copyright University of Birmingham 2008. All rights reserved.