550 likes | 835 Views
Lecture 4 A Brief Introduction to LaTeX. Introduction to Information Technology. Dr. Ken Tsang 曾镜涛 Email: kentsang@uic.edu.hk http://www.uic.edu.hk/~kentsang/IT/IT3.htm Room E408 R9. What is TeX?.
E N D
Lecture 4A Brief Introduction to LaTeX Introduction to Information Technology Dr. Ken Tsang 曾镜涛 Email:kentsang@uic.edu.hk http://www.uic.edu.hk/~kentsang/IT/IT3.htm Room E408 R9
What is TeX? • TeX is a typesetting system (排版系统) written by Donald E. Knuth in 1976, who says that it is “intended for the creation of beautiful books — and especially for books that contain a lot of mathematics”
How to Pronounce TeX? • The X is really the Greek letter Chi, and is pronounced by English-speakers like ‘k’. It definitely is not pronounced ‘ks’ (the Greek letter with that sound doesn’t look remotely like the Latin alphabet X) • The name comes from the Greek word for “art” or “craft” (“techni”), which is the root of the English word technology
What is LaTeX? • LaTeX is a free high-quality document processing system that is based on TeX • LaTeX was originally written by Leslie Lamport in 1980s
How to Pronounce TeX? • Lamport never announced how one he thought people should pronounce LaTeX • A lot of people pronounce it “Lay TeX” or “Lah TeX”
Why LaTeX ? • It is the premier typesetting package in the world! • It's free!!! • It's available for many machines (Linux, Mac, Windows) • LaTeX files are ASCII • Therefore, they are very portable • You can use the editor of your choice (Some people even use MS Word)
Why LaTeX ? • The typesetting isbetter • especiallythe maths • Stylechangesareneater in LaTeX • Style files for many periodicals exist • Many MS Word users don't use styles or templates, so there's a limit to what they can do • LaTeX is extensible • If you want a new feature, find a freeadd-on or write one yourself
Disadvantages • LaTeX encourages (almost insists on) structured writing and the separation of style from content • This is not the way that many people (especially non-programmers) are used to working • Without a WYSIWYG (What You See Is What You Get), it's not always easy to find out how to do things
LaTeX vs MS Word • If you are writing a document with lots of maths, tables, cross-references, etc, and you need to format the document and bibliography to suit various publications, then LaTeX is clearly the best choice! • If your document contains many equations / figures / tables, MSWord easily runs out of memory and shows a nice blue screen of death or prints red crosses instead of your equations
LaTeX vs MS Word • LaTeXencourages authors not to worry too much about the appearance of their documents but to concentrate on getting the right content • LaTeXis based on the idea that it is better to leave document design to document designers, and to let authors get on with writing documents
“Hello World” • Suppose we want to produce the following document:
In MS Word • To produce this in most typesetting or word-processing systems, the author would have to decide what layout to use, so would select (say) 18pt Times Roman for the title, 12pt Times Italic for the name, and so on • This has two results: • Authors wasting their time with designs • A lot of badly designed documents!
In LaTeX \documentclass{article} \title{Introduction to LaTeX} \author{Bill Gates} \date{November 2007} \begin{document} \maketitle Hello world! \end{document}
Or In English • This document is an article • Its title is An Introduction to LaTex • Its author is Bill Gates • It is written in November 2007 • The document consists of a title followed by the text Hello world!
LaTeX Features • Typesetting journal articles, technical reports, books, and slide presentations • Control over large documents containing sectioning, cross-references, tables and figures • Typesetting of complex mathematical formulas • Advanced typesetting of mathematics with AMS-LaTeX
LaTeX Features • Automatic generation of bibliographies and indexes • Multi-lingual typesetting • Inclusion of artwork, and process or spot color • Using PostScript or Metafont fonts
Obtaining LaTeX • Linux • Your system distribution or vendor has probably provided a TeX system including LaTeX. Check your usual software source for a TeX package • MacOS X • A full TeX system including LaTeX, called MacTeX, is available for installation with i-Installer • http://www.tug.org/mactex/ • Windows • Check out the proTeXt system; this allows you to install a full TeX system, including LaTeX, while reading about the basics of the installation • http://www.tug.org/protext/ • Chinese TeX: http://www.ctex.org
A Quick Start (1) • The LaTeX Source: reproduce the following text in any text-editor and save it as hello.tex \documentclass{article} \begin{document} Hello World! \end{document}
A Quick Start (2) • Generating the documents • Type the command: latex hello.tex • Various bits of info about LaTeX and its progress will be displayed. • If all went well, the last two lines displayed in the console will be: Output written on hello.dvi (1 page, xxx bytes) Transcript written on hello.log • This means that your source file has been processed and the resulting document is called hello.dvi, which takes up 1 page and xxx bytes of space.
A Quick Start (3) • Viewing the documents • LaTeX has now done its job, so we can view the output • The default format is DVI(device independent), of which viewers exist freely for most platforms • However, the chances are that you would prefer to have a postscript file or PDF • Fortunately, there exist tools that can convert DVI to PS (and PDF) easily
A Quick Start (4) To Convert the document into a postscript (PS) file • Type the command: dvips hello.dvi -o hello.ps • dvips is the utility that actually performs the conversion. • The first argument hello.dvi is the DVI file to be converted. • The -oargument says that you want the output to be saved as a file. • And the argument immediately after, hello.ps, is the name you wish to call it.
A Quick Start (5) To Convert the document into a PDF file • Type the command: dvipdf hello.dvi hello.pdf • Note that there is no -o with this command, because although the utilities look almost identical, they have slightly differing syntax) • If you already have a postscript version, then type: ps2pdf hello.ps hello.pdf • Now it is simply a matter of using your preferred PS or PDF viewer to see the output • What you should see at the top left of the page are the words Hello World! and at the bottom is the current page number. All in a standard times font
LaTeX Document Structure % A simple article to illustrate document % structure. \documentclass[12pt]{article} \usepackage{times} \begin{document} …… \end{document}
LaTeX Document Structure • %: comments • \documentclass[12pt]{article} • The type of document we want to produce: article • Other classes that exist are book, report, thesis etc • 12pt: the font • \usepackage{times} • It tells Latex to utilise some external macros • \begin{document} • … • \end{document}
Top Matter • \title{How to Structure a \LaTeX{} Document} • \author{ Bill Gates\\ Computer Science and technology Program,\\ United International College,\\ Zhuhai, China\\ \texttt{billgates@webmail.uic.edu.hk}} \date{\today} • \maketitle
Abstract \begin{abstract} In this article, I shall introduce to you \LaTeX{}, a typesetting software that is much better than Microsoft Word. I shall discuss some of the fundamental topics in producing a structured document. This document itself does not go into much depth, but is instead the output of an example of how to implement structure. \end{abstract}
Sectioning Commands • \section{Introduction} • This section's content... • \section{Structure} • This section's content... • \subsection{Top Matter} • This subsection's content... • \subsubsection{Article Information} • This subsubsection's content...
Bulleted List • \begin{itemize} • \item \texttt{\textbackslash address} - The author's address. Use the new line command (\texttt{\textbackslash\textbackslash}) for line breaks. • \item \texttt{\textbackslash thanks} - Where you put any acknowledgments. • \item \texttt{\textbackslash email} - The author's email address. • \item \texttt{\textbackslash urladdr} - The URL for the author's web page. • \end{itemize}
The Bibliography • \begin{thebibliography}{9} \bibitem{lamport94} Leslie Lamport, \emph{\LaTeX: A Document Preparation System}. Addison Wesley, Massachusetts, 2nd Edition, 1994. • \end{thebibliography}
Citation • In the text, • This small document is designed to illustrate how easy it is to create a well structured document within \LaTeX\cite{lamport94}. You should quickly be able tosee how the article looks very professional, despite the content beingfar from academic. Titles, section headings, justified text, textformatting etc., is all there, and you would be surprised when you seejust how little markup was required to get this output.
The Tabular Environment \begin{tabular}{ l c r } 1 & 2 & 3 \\ 4 & 5 & 6 \\ 7 & 8 & 9 \\ \end{tabular} \begin{tabular}{|l|l|} \hline stuff & stuff \\ \hline stuff & stuff \\ \hline \end{tabular}
Mathematics Environments • text formulae • \begin{math}...\end{math} • $...$ • displayed formulae • \begin{displaymath}...\end{displaymath} • \[...]\ • \begin{equation}...\end{equation}
Summary • This lecture has given a very brief introduction to the facilities provided in LaTeX • There are many other features and packages that have not been covered • The best way to improve your LaTeX skills is to use it for ALL your assignments and papers!
References for Further Study • http://www.tug.org/ • http://www.latex-project.org • http://www.latex-project.org/guides/usrguide.pdf • LaTeX: an introduction (http://www.techscribe.co.uk/ta/latex-introduction.pdf) • The (Not So) Short Introduction to LaTeX2e (http://ctan.tug.org/tex-archive/info/lshort/english/lshort.pdf)