file:tex.howto TeX is a "mark-up" language that is used to specify documents (books, technical articles, manuals). A variety of fonts, font-sizes, and formating options can be specified. (Although I have not been able to use any fonts other than the default "Computer modern" fonts successfully - this is essentially due to excessive complexity in using fonts, and because the basic ASCII symbols are not invariant across fonts, so that, for example, a verbatim "{" is not always a brace.) Pictures given as .ps files or as .jpg files can be embedded in a TeX document, and indices and tables-of-contents can be constructed. There are many books about using TeX, and you will need Leslie Lamport's Latex manual (2nd edition), and probably others. None of them explain things in the most-straightforward way, and not all important topics are explained sufficiently, or even at all. TeX is especially good for specifying mathematical expressions. The basic structure of the TeX notation consists of embedding commands like \alpha for the Greek letter alpha, or x_i to denote x subscripted with i. Many TeX commands replace themselves with other text, often containing other TeX commands; because of this text-substitution nature of many TeX commands, these commands are called "macros". (This history of this term goes back to early text-replacement facilities in assemblers where "macro-instructions" were commands to be replaced by a sequence of simpler commands.) The TeX document that you create is just an ASCII text-file containing appropriate "marked-up" text. The final output that we generally want is a so-called Postscript .ps file or a .pdf file. (Postscript is another language that is especially suited for describing the exact placement of text and graphics on paper or on a display-screen. Some printers contain a processor and CMOS memory containing the Postscript interpreter and can interpret the Postscript language to produce a print-out. There are also programs that convert a .ps file to the language a printer may require. A .pdf file is in essence just a compressed Postscript file (.pdf files are a common way (and probably the best way) to provide mathematical text that can be presented by a web-browser which can connect to a .pdf file interpreter like Adobe's Reader or Ghostscript.) Given a .ps file, there are programs available to create a corresponding .pdf file. To make a TeX document, we construct a .tex file, x.tex, as in the example shown below. Any text-editor program that can save a plain ASCII text-file can be used to construct (and change) the file x.tex. To "process" this .tex file, we run TeX with the 'latex' command. This constructs the output file x.dvi, and the auxilliary output files x.aux and x.log. x.dvi is the "device-independent" graphics output file that specifies the characters to be "printed", including the fonts, the exact sizes, and the exact locations (in very-high-resolution pixel-units.) [TeX fonts are "bitmap" fonts, although Postscript graphics commands can be embedded in an output .dvi file through "pictures".] The file x.dvi is not printable, but it can be processed with the dvips program to produce a printable Postscript file. Thus to process x.tex, we cd to the directory containing x.tex and use the commands: latex x [This outputs x.dvi, and also writes x.aux and x.log. latex is just the TeX program with a bunch of predefined TeX macros; these macros are called latex.] dvips x [This processes x.dvi and sends Postscript ouput to the default printer queue. The command: [dvips -o x.ps x] will write the output to disk as the Postscript file x.ps. In RH8, you must use the -o option, since dvips cannot successfully write directly to the printer. Then to print the file just use [lpr x.ps]. It is often convenient to print just part of your document. To do this, use the command: [dvips -p n -l m -o x.ps x]. This processes the file x.dvi and writes pages n through m in the resulting Postscript file x.ps.] To look at the dvifile on the screen, we can use the program xdvi. The command: [xdvi +n x.dvi] shows page n in a window. Then you must "scale" its size up by 25% or more, and you can use arrow keys and page-up and page-down keys to navigate through the document. You may get an error message if your .tex file is malformed. In that case, you note the error message and the line on which TeX noticed the problem (this is sometimes not the line in error,) and then type x to exit TeX so you can go try to fix the problem and run TeX again. --------------------------------------------- Adding a Bibliography If we want a bibliography at the end of our document, with references embedded in the text, we will first construct a .bib file, say z.bib, containing bibliographic entries in the format specified below. (This .bib file can actually contain the citations for multiple documents - it can even contain every reference we ever use.) Then we include \cite{tag} commands in our file x.tex, as well as the command \bibliographystyle{alpha} near the beginning and the command \bibliography{z} at the end of x.tex just before the \end{document} command. Then we process our file x.tex with latex via the command [latex x]. latex gathers the \bibliographystyle, \bibliography, and \cite commands and essentially records them in x.aux. The file x.dvi is created, but no bibliography is in it. Now we run the bibtex program with the command [bibtex x]. This reads the x.aux file which tells bibtex the name z.bib of the .bib "database" file and also all the citations that were found in x.tex; bibtex then extracts the specified references from z.bib, "formats" them with appropriate TeX commands and writes them into the file x.bbl. bibtex also makes up "traditional citation labels" (e.g. Knu73) on the entries in x.bbl to be used in our document. Then we run the latex program again. Now latex will add the file x.bbl into x.tex (for processing purposes only; the file x.tex is not physically changed.) And latex will add lines to x.aux for each distinct \cite command that contain the specified tag and the corresponding "traditional label" that bibtex generated and recorded in x.bbl. Then the latex program is run yet again. This time, it will use the .bib tag-to-traditional label correspondances in x.aux to replace the "\cite{tag}" commands in the body of x.tex with the traditional labels that originally came from x.bbl. The output file x.dvi now contains the desired bibliographic references and the associated bibliography, which is placed at the point where the "\bibliography" command was placed. Thus, when x.tex contains \cite commands referring to a .bib file, the commands needed to generate a Postscript file x.ps for printing are: latex x [creates x.aux] bibtex x [creates x.bbl from x.bib and x.aux] latex x [updates x.aux] latex x [creates x.dvi] dvips -o x.ps x [creates x.ps] ---------------------------------------------------- Adding an Index If we want an index generated for our document, x.tex, we embed \index{`word or phrase'} at the places where we want an index entry for the specified `word or phrase' to point to. There are a few important indexing "tricks" such as `see-also' devices and sub-index entries. For example, we write \index{entry1!sub-entry1} to generate an index sub-entry line "sub-entry1" indented under the main entry "entry1". Further features are discussed in the latex manual. We must also insert "\usepackage{makeidx} followed by the command "\makeindex" near the front of our .tex file, x.tex, and insert the command "\printindex" near the end of the file where we want the index to appear, usually just before the "\end{document}" command. When we run latex, all \index commands will be assigned the page number they should point to and this index-entry,page-number pair is written in the file x.idx. Then we run the makeindex program via the command [makeindex x]; this reads the file x.idx and writes a .tex formatted file called x.ind containing the actual index. Now when latex is run again, the file x.ind is inserted as a new chapter where the \printindex command occurs. Thus, when x.tex contains \index commands, the commands needed to generate a Postscript file x.ps for printing are: latex x [creates x.idx] makeindex x [creates x.ind] latex x [creates x.dvi from x.tex and x.ind] dvips -o x.ps x [creates x.ps] ------------------------------------------------ Example of a bibliography "database" file, x.bib @BOOK{Knott, AUTHOR = "{Gary~D.} Knott", TITLE = "Interpolating Cubic Splines", PUBLISHER = "Birkhauser, Boston", YEAR = 2000 } @ARTICLE{Foley2, AUTHOR = "{Thomas~A.} Foley", TITLE = "Interpolation with Interval and Point Tension Controls Using Cubic Weighted v-Splines", JOURNAL = "ACM Trans. on Mathematical Software", YEAR = 1987, VOLUME = 13, NUMBER = 1, PAGES = "68-96" } --------------------------------------------------- Making a .pdf file A .pdf file is essentially a compressed Postscript file [In fact, it may be exactly a compressed Postscript file, but with a bunch of bothersome features - like password codes controlling the access to the document or controlling one's ability to print the document enforced by programs which honor such codes. I don't know of any features pdf files have regarding content and layout that Postscript files don't have. But it is unpleasant to construct one, mostly because I don't know exactly the format and content of a .pdf file, and I dislike secrets. Nevertheless, many people have Adobe's PDF-reader program, so this often is the best way to provide a .tex document to others as a file.] To construct a .pdf file from a .ps file, x.ps, we use the program ps2pdf12 with the command [ps2pdf12 x.ps x.pdf] (It is important to use ps2pdf12 because this is the "lowest-common-denominator" pdf format, that most people can display and print.) The resulting .pdf file can be viewed, and more importantly, printed, with the Acrobat reader progam (or with the xpdf program on a Linux system), but the screen output is of poor quality. This is because the `ordinary' .ps file created by the dvips program uses the Postscript "type 3" bitmap fonts whose resolution was chosen for the printer, not the screen. We can make a .ps file and then a .pdf file that use "type 1" Postscript stroke fonts that work for all resolution devices. To make a .pdf file, x.pdf, with "type 1" fonts, start with the file x.dvi and use the commands: dvips -Ppdf -o x.ps x.dvi ps2pdf12 x.ps x.pdf ---------------------------------------------------- Here is the form of a "new" latex2e .tex document. ----------------------------------------------------- %& Latex %This is file ~/newtex/newtex.tex. This file is a copy of an %"old" .tex file that has been revised for processing under latex % version 2e. %%%%%%%%%%%%%%%%%% %OLD: \documentstyle[11pt,twoside,comment,ctext,g,epsf]{article} \documentclass[11pt,twoside]{article} % NEW % A style file is just a file of TeX macros to be used by "including" it % in our .tex document. A style file (*.sty) in latex2e is called a % "package". We can use a pre-provided package X.sty via the % command \usepackage{X}. % (Some packages are named with the extension .tex instead of .sty % (e.g. epsf.tex is a package that occurs in % \usr\share\texmf/tex/plain/dvips/).) % Note, the extension .sty or .tex is not (and may not be) given. % TeX-provided (or user-provided) packages (style files) are searched % for, first in the current directory, and then in various directories % determined by the "database" file ls-R, including, particularly % /usr/share/texmf/tex/latex/base/, /usr/share/texmf/tex/latex/misc/ % and /usr/share/texmf/tex/plain/ and various subdirectories of these % (e.g. the package epsf.) % Major "style" files provided by TeX are called "classes". A % class file is named with the extension .cls. Class files are % specified for use in the \documentclass[...]{class} command. % TeX-provided class files are searched for in the same way as % package files are. % The packages comment.sty and graphicx.sty are provided by TeX. % graphicx.sty is in /usr/share/texmf/tex/latex/graphics/. % comment.sty is in /usr/share/texmf/tex/latex/misc/. \usepackage{comment} \usepackage{graphicx} % ctext.sty, g.sty, and epsf.sty are home-built style files in the % current directory. (Although epsf.tex is in % /usr/share/texmf/tex/plain/dvips/, our local file epsf.sty in our working % directorty takes precedence. Personal style files should be used AFTER % all the TeX provided packages are used. \usepackage{ctext} \usepackage{g} \usepackage{epsf} % "Options" are basically switches which are passed to classes % and packages. Specifying an option such as `11pt' in the \documentclass % command "defines" it, as in C, and within a style file we can ask %"is 11pt defined?". % Thus the command \documentclass[11pt,twoside]{article} % makes the switches '11pt' and 'twoside' "available" to the article.cls % file which is read in and executed. In article.cls there will be % `declarations' of the form \DeclareOption{option}{commands} which % will execute the `commands' if the `option' has been `made available' % (defined). Sometimes the commands for a given option are stored in a % .clo file. (e.g. /usr/share/texmf/tex/latex/base/size11.clo is % included when the option "11pt" is specified.) %Here are the macros we use to embed a .eps (encapsulated Postscript file) %in our document. (An encapsulated Postscript file is just a text %file full of Postscript commands with a special "comment" line near the front %the specifies the size of a rectangle in "points" (1/72 of an inch) that %we want the picture to be scaled to fit in. % The following definition is for the old Tex 2.09 version. %\def\pict#1{ %\begin{center} %\leavevmode %\epsfxsize=4in %\epsffile{#1} %\end{center} %} % This is the new latex-2e way. \def\picture#1{% \begin{center} \includegraphics{#1} \end{center} %We use the \picture macro by writing: \picture{filen.eps} in a line %by itself where we want the picture to go. (Although TeX will "float" %pictures if they do not conveniently fit at the specified point, %unless you take special measures.) The encapsulated Postscript file %filen.eps must be in the same working directory where our .tex files %are. (I think it may be the case that the eps size comment in the file %can be overridden with a TeX macro if one knows how.) \def\setdiff{\bigtriangleup} % \def\setdiff{\mathop{\bigtriangleup}} - we do not need this % form; it is already a mathop. \newcounter{mycnt} % mycnt is used inside some of the g-files. \raggedbottom \begin{document} \bibliographystyle{alpha} {\newpage \null \vskip 2em \begin{center}% {\Large Orienting a Scribble} \vskip 1.5em {\large \lineskip .5em \begin{tabular}[t]{c}Gary D. Knott, Ph.D. \\ \\ Civilized Software Inc. \\ 12109 Heritage Park Circle\\ Silver Spring, Md. 20906 \\ Tel: 301-962-3711\\ URL: http://www.civilized.com\\ email: knott@civilized.com \end{tabular}\par}% \end{center}% \par \vskip 1.5em} \pagestyle{plain} \parskip10pt plus1pt minus1pt abstract: A constructive proof is given for the fact that a suitably-nice self-intersecting curve can always be traversed without crossing itself. \vskip .25in I recently discovered that you can traverse a ``scribble'' like that shown below, {\it without crossing your path}. (You might enjoy imagining an algorithm by which you could generate such ``random'' scribbles at will.) You may need to {\it touch} the previously-traced path at a point, or even retrace a section of it, but you need not cross it. It seems likely to me that this fact must have been observed before, perhaps many times, but I don't know of any prior report. It is convenient to restrict our attention to scribbles that are closed planar continuous curves, and moreover we want the curves we consider to self-intersect at only a finite number of points, or to overlap themselves along a finite number of disjoint connected segments (or both.) Such curves are suitably nice for our purposes. The existence of non-crossing traversal paths for such curves is linked to an interesting, and not very deep, structural regularity that is possessed by such closed planar curves. Describing these structural features is the purpose of this story. \begin{center} % OLD: \leavevmode\epsfysize=3.7in\epsffile{scribble.eps} \includegraphics[width=3.7in,height=3.7in]{scribble.eps} % NEW \end{center} \bibliography{g} % this requests just the cited references found in g.bib go here. \end{document}