Вы находитесь на странице: 1из 8

A Document Preparation with TEX/L TEX

August 16, 2011

Abstract In this presentation, we teach the reader the salient cosidertations in a A A bid to prepare a document with the text formatting program TEX/L TEX/L TEX 2 .

Introduction

TEX, written by Donald E. Knuth, is the most powerful formatting program for producing book quality text of scientic and technical works. It allows knowledgeable users to write codes for all sorts of features. The name TEX is chosen to emphasize that the printing of mathematical texts is an integral part of the program and not a cumbersome add-on. A The L TEX format for TEX, developed by the American scientist, Leslie Lamport, provides a set of higher-level commands for the production of complex A documents. With L TEX, even a user with no knowledge of typesetting or programming is in a position to take extensive advantage of the possiblities oered by TEX to produce a variety of text outputs in book quality within a reasonable A time. L TEX, as an o-shoot of Plain TEX, is essentially a markup language. It has provisions for automatic running heads, sectioning, tables of contents, crossreferencing, equation numbering, citations, oating tables and gures without A the author having to know how these are to be formatted. L TEX 2 is an A X3. intermediate step towards L TE

A Why choose L TEX

A L TEX knows a lot about typesetting. It can easily be used to create beautiful, A long, complex documents. Unlike other typesetting programs, L TEX produces exact rather than approximate results. It is a WYMIWYG (What You Mean Is What You Get) and not a WYSIWYG (What You See Is What You Get) A program. L TEX is easy to modify and expand using macros. It also has a well-designed set of tools that can be used to prepare any type of document. A L TEX is supported on (nearly) all computer platforms. It is free but comA mercial versions are available. TEX/L TEX document sources are in plain text
0 Muniru A. Asiru . Department of Mathematics and Statistics, The Federal Polytechnic, Bida, Nigeria. Email: maasiru@yahoo.com phone +2348034271010

A (ASCII). It is easy to use L TEX to genrate Tables of Contents, Figures,Bibliographies, A References, Indices etc that are used in a document. L TEX has the functionality to split long documents (book, etc) into smaller, more manageable pieces and each piece can easily be combined to form a whole once writing is complete. A L TEX is very stable in that when documents are interchanged the document A remains same. It is the defacto standard for scientic documents. L TEX is the soul of Mathematics. It renders mathematical expressions with the highest degree of precission.

A LTEX document structure

A Every L TEX document has the following structure.

\documentclass[options]{class} preamble \begin{document} document body \end{document}


A The rst line of a L TEX program declares the overall layout. The class species the document type. This is usually one of: article, report or book. The options is a comma-separated list used to modify the document. For example \documentclass[12pt,titlepage]{article} species that the document is an article with 12pt. Font and that each page contains the titlepage. In the same way \documentclass[a4paper,two-column]{report} menas that the document is a report, there are two-columns on each page and the paper on which the document is to be eventually printed is a4paper. The preamble contains formatting, layout, etc information; and inclusion of other macro packages. For example, the document below has a long list of preamble.

\documentclass[12pt,a4 paper]{article} \usepackage{amssymb} \usepackage{makeidx} \usepackage{latexsym} \usepackage{amsmath} \usepackage{amsfonts} %\usepackage{TikZ} \pagenumbering{arabic} \setlength{\oddsidemargin}{1.0cm} \setlength{\topmargin}{1.0cm} \setlength{\footskip}{1.0cm} \newtheorem{theorem}{Theorem} \newtheorem{lemma}[theorem]{Lemma} \newtheorem{corollary}[theorem]{Corollary} \newtheorem{remark}[theorem]{Remark} \newtheorem{proposition}[theorem]{Proposition} \newtheorem{conjecture}[theorem]{Conjecture} \newtheorem{definition}[theorem]{Definition} \numberwithin{equation}{section} 2

\numberwithin{theorem}{section} \begin{document} \end{document} The preamble always comes after the documentclass and tells us that some packages such as amssymb, makeidx,. . . are to be used. It also sets the numbering and provides how equations and theorems are to be numbered. The commands in the preamble of a document are of a global nature in that they aect the entire document. The command \begin{document} marks the beginning of the document. Everything that is typed from this point onwards is what the writer intends. A The document body is the document itself together with L TEX mark-ups. Each document ends with the command \end{document}.

3.1

Document Example

\documentclass[a4paper,12pt]{article} \usepackage{amsfonts} \title{A Sample Document} \author{T.A Ade \and A.Q Ibe} \date{\today} \maketitle \begin{document} \section{Introduction} I am making my first document and you should read it. \section{} \subsection{} \subsubsection{} \section{} \section*{Acknowledgement} \end{document}

3.2

A L TEX commands

A L TEX has three versions of commands.

(i) Non-letter characters These are the commands &, $, %, , , {,},#, . A Each of these have special meaning telling L TEXto do something. For example % indicates comments being added to a program to aid underA standing and L TEX ignores all texts after the % till the end of the line. (ii) Backslash \ followed by single non-letter character as in \,. (iii) Backslash \ followed by one or more letters as in \quad.
A L TEX commands generally have the following structure: \COMMAND[optional argument]{mandatory argument}.

3.3

A L TEX environment/Grouping

A A L TEX enviroment groups segements of code. The body of an environmnent is treated diently from the outside. All changes inside an environment are usually local. An environment may be created within text or it may be made to stand alone. The general syntax of an environment is

\begin{environment} body of environment \end{environment} For example a center environment centering text in its body is \begin{center} centred \end{center} The equation environment \begin{equation} some equation \end{equation} displays an equation and assigns a number to the equation. The environment \begin{equation*} some equation \end{equation*} displays an equation without an equation number. Text can be grouped using { some text }. Changes inside a group are local. For example, to emphasise the text in the group we can write: This is {\em important}. Note that the command \em ends with the group. The command \emph{important} does the same thing. text

3.4

Section Levels

A The section levels for L TEXare part (1), chapter (0), section (1), subsection (2), subsubsection (3), paragraph (4) and subparagraph (5). The section level part (1) does not apply for the classle article. The paragraph (4) and subparagraph (5) are alternativley the subsubsubsection and subsubsubsubsection respectively.

3.5

A TEX/L TEX resources

A TEX/L TEX resources can be obtained from

http://www.langbein.org Comprehensive TEX Archive Network (CTAN) at http://www.ctan.org/

TEX Users Group (TUG) at http://www.tug.org/ TEX newsgroup at http://www.comp.text.tex

Articles for publication

Many editors to Mathematics and Scientic journals often do require that arA ticles be submitted using L TEX. This is because Mathematics and Scientic A writing are better presented using L TEX program. The general format of an article for publication is shown below. \documentclass[a4paper, 12pt]{article} preamble \begin{document} \author{} \date \maketitle \begin{abstract} \end{abstract} \section{} \subsection \section{} \subsection \subsubsection{} \begin{thebibliography}{99} \bibitem \end{thebibliography} \end{document}

The MSc/PhD Thesis

Many MSc/PhD students in the Sciences are being encouraged to produce their A thesis in L TEX, particularly if their work involves a lot of mathematics. If your school already has its own class le, please use it; otherwise you should use the report class le. Unless otherwise instructed you may want to start with the following skeletal layout which you can save as thesis.tex. \documentclass[a4paper]{report} \begin{document} \title{My sample MSc/PhD Thesis} \author{A. N. Anonymous} \date{July 2011} \maketitle \pagenumbering{roman} \tableofcontents \listoffigures \listoftables \chapter*{Acknowledgements} 5

\begin{abstract} \end{abstract} \pagenumbering{arabic} \chapter{Introduction} \label{ch1:intro} \chapter{Literature Review} \label{ch2:litrev} \chapter{Method} \label{ch3:method} \chapter{Analysis} \label{ch4:analysis} \chapter{Results} \label{ch5:results} \chapter{Conclusions} \label{ch6:conc} \chapter{Recommendations} \label{ch7:rec} \bibliographystyle{plain} \bibliography{thesis} \end{document} Notice that there are seven chapters in this format. Your own thesis may differ slightly from this depending on your institution and/or supervisor and/or subject of study. The good thing about creating a skeletal document is that it can have an amazing psychological eect on some people: for very little eort it can produce a document several pages long, which can give you a sense of achievement which can help give you sucient momentum to get started. Since the format of thesis.tex is a large document, each chapter can be placed in a separate le. The command \include{<filename>} can then be A used to tell L TEXto include these les. Our format thesis.tex now takes the form \documentclass[a4paper]{report} \begin{document} \title{My sample MSc/PhD Thesis} \author{A. N. Anonymous} \date{July 2011} \maketitle \pagenumbering{roman} \tableofcontents \listoffigures \listoftables \chapter*{Acknowledgements} \begin{abstract} \end{abstract} \pagenumbering{arabic} \include{intro} \include{litrev} \include{method} \include{analysis} \include{results} \include{conc} \include{rec} \bibliographystyle{plain} \bibliography{thesis} \end{document} File intro.tex: \chapter{Introduction} \label{ch:intro}\\ File litrev.tex: \chapter{Literature Review} \label{ch:litrev}\\ 6

File File File File File

method.tex: \chapter{Method} \label{ch:method}\\ analysis.tex: \chapter{Analysis} \label{ch:analysis}\\ results.tex: \chapter{Results} \label{ch:results}\\ conc.tex: \chapter{Conclusions} \label{ch:conc}\\ rec.tex: \chapter{Recommendations} \label{ch:rec}\\

It is possible to redene \chapter, \section etc in order to change the heading style for your document. The ability to do this is one of the advantages of using A L TEX over a word processor.

A LTEX packages

A A New special feature to L TEX are added to L TEX as macro packages. There are thousands of these which can be used for many purposes. If it is desired and the necessary installations have been done, a macro package can be inA cluded into a L TEX program at the preamble stage by using the command \usepackage[options]{package}. The macro package options modify the default package behaviour.

Error Messages

A Errors do occur at times during the preparation of a long L TEX document. The most common type of errors include:

(a) typing errors for command names. For example \documentclass{article} \begin{document} These words appear in \txetbf{bold face} \end{document} Notice that the command name \textbf was mis-splet as \txetbf. A typing error is corrected by entering the proper text. Similarly, an environment name may be mispelled, for example \begin{itemie} \item This is item 1 in the list \item This is item 2 in the list \item This is item 3 in the list \end{itemize} \end{document} In this case the the environment name \begin{itemize} was mis-spelt as \begin{itemie}. (b) forgetting that some commands must be paired. For example \documentclass{article} \begin{document} \begin{center} Text here is to be centered \end{document} 7

The error here is that the command \begin{center} was ended by \end{document}. The environment \begin{center} was not ended by a \end{center}, so there is an error of pairing this command. The error of forgetting to pair commands often occur when writing displayed equations. For example, in $$y^2=4x+3 the $$ was not paired and this will result in an error. (c) non-inclusion of the major part of a document. The user may forget to begin his document with \documentclass, thus forgetting to specify the class of document, or it may be any one of preamble, \begin{document} and/or \end{document}. Generally, errors should be avoided. However, when one occurs, try to gure out what modications can be made to your program by reading the log le that A was generated by L TEX and then revisit your program to correct the error.

References
A [1] Kopka, H. and Daly, W. P. (1999). A guide to L TEX- Document Prepartion for Beginners and Advanced Users (Third Edition), (Addison Wesley, London).

[2] Tantau, T. (2007). User Guide to the Beamer Class, Version 3.07. Available at: http://latex-beamer.sourceforge.net. [3] Tantau, T. (2005). The TikZ and PGF Packages Manual for version 1.01. Available at: http://sourceforge.net/projects/pgf.
A [4] Lamport, L. et. al. (1994). L TEX 2 The macroc package for TEX Edition 1.6. Available at: http://sourceforge.net/.

[5] Doob, M. (1984). A Gentle Introduction to TEXA manual for Self-Study. Department of Mathematics, The Univeristy of Manitoba, Winnipeg, Manitoba, Canada, R3T 2N2. [6] Oetiker, T. Partl, H., Hyna, I. and Schlegl, E. (2001). The Not so Short A Introduction to L TEX 2 version 3.20. Available at: http://sourceforge.net [7] Rahtz, S. (2002). The TEXLive Guide, 7th Edition. Available at: http://sebastian.rahtz@oucs.ox.ac.uk. [8] de Boer, I.H. (1998-2002). http://www.winshell.de. Winshell 2.2.1. A. Available (1993). at: The

[9] Goossens, M., Mittlebach, F. and Samarin, A L TEXCompanion. (Addison-Wesley, London).

Вам также может понравиться