21

USIG LATEX

Contents

  • Introduction
  • Create LaTeX document
  • Components of a LaTeX document
  • LaTeX commands
    • Typing LaTeX commands, page numbering and headings, creating a title page, sections, cross-references, abstracts, double spacing, hyphenation, quotation marks, changing the appearance of words, spacing between words, indenting, centering text, line breaks, mathematical formulas, greek letters, exponents and subscripts, fractions, functions, relations, spacing in math mode, constructing tables, bulleted list, numbered lists, bibliographies, graphic file formats, graphics package, including graphics
  • Solved example—Title for your article, a section, a bulleted list, a numbered list, a paragraph, display some mathematical formulae

Why this chapter

Nowadays, the production of long articles and books uses a document preparation system that produces publication-quality typeset documents. The document preparation system includes programmable desktop publishing features and facilities for automating cross-referencing, tables, figures, page layout, bibliography etc. LaTeX is a family of programs designed to produce high quality typeset documents. The purpose of this chapter is to introduce you to LaTeX.

21.1 INTRODUCTION

TeX is a computer program for typesetting documents, created by D. E. Knuth. Typesetting involves formatting of the input text. TeX is a mathematical typesetting markup language. A file created using TeX may be printed on different kinds of printers and high-resolution typesetting machines. TeX is widely used by publishers to typeset books and mathematical journals.

LaTeX is a variant of TeX, written by Leslie Lamport. LaTeX is a document preparation system and document markup language for the TeX typesetting programs. LaTeX focuses on the structure of the document; TeX focuses on the visual typesetting details. LaTeX is a popular method of using TeX.

LaTeX is a family of programs designed to produce publication-quality typeset documents. It is particularly strong when working with mathematical symbols. It is suited for the production of long articles and books. It facilitates automatic numbering of chapters, sections, theorems, equations etc., and cross-referencing. LaTeX is widely used by academia and scientists because of its high-quality typesetting features achieved due to TeX. It offers programmable desktop publishing features.

LaTeX is free software, distributed under the LaTeX Project Public License. Here, we work in the Windows environment, while working with LaTeX.

21.2 CREATE LATEX DOCUMENT

To create a TeX document—

  • Create a TeX file using a text editor. Some editors are specifically created for working with LaTeX like WinEdt.
  • Save the TeX file with the .tex extension.
  • Compile and run the TeX file. If you are using a LaTeX text editor, you can use the menu commands to run the file. For example, in WinEdt, Accessories>LaTeX, will execute the file and show the output.
  • A program Yap previews and prints your LaTeX output.
21.3 COMPONENTS OF A LATEX DOCUMENT
  • A LaTeX document must contain the following three components:
    1. documentclass{article}
    2. egin{document}
    3. end{document}
  • documentclass{article} tells LaTeX about the kind of document, as there are different style rules for different kinds of documents. We use the article document class. Other classes include report, book, and letter.
  • The default font size for each class is 10 point.
  • To use 11 point write, documentclass [11pt]{article}. To use 12 point write documentclass[12pt] {article}.
  • The documentclass command must appear at the start of the LaTeX document, before any other LaTeX commands.
  • The space between documentclass and egin{document} is called the preamble. The commands for LaTeX that affect the whole document should be included in the preamble.
  • The body of the document, where all text is included, must occur between the egin{document} and end{document} commands.
21.4 LATEX COMMANDS

Here, the common commands in LaTeX are described briefly.

  • Typing LaTeX Commands
    • Surround any text that is to be printed as it is, with a egin{verbatim} and a end{verbatim} command.
  • Page Numbering and Headings—command pagestyle
    • It should always be between documentclass{article} and egin{document}. It can take the following forms:
      • pagestyle{plain} is the default. It puts page number at the center of the bottom of the page and provides no headings.
      • pagestyle{empty} provides neither page numbers nor headings.
      • pagestyle{headings} provides page numbers and headings from any section that you are using.
      • pagestyle{myheadings} provides page numbers and custom headings.
    • It can also be applied to a single page using hispagestyle instead of pagestyle.
  • Creating a Title Page
    • Insert between the documentclass command and egin{document} command. The commands are:
      • itle{your title here}
      • author{your name here}
      • date{current date}
      • maketitle
    • After specifying the arguments of itle, author, and date, use maketitle for this part to be typeset.
    • documentclass can take titlepage option—documentclass[titlepage]{article}.
    • By default, all entries produced by these commands are centered on the lines in which they appear.
    • Choose the break points with the \ command.
    • To have author names side by side, use and command.
  • Sections
    • section{sectiontitle} numbers the sections
    • section*{sectiontitle} does not number the section.
    • Both create separate sections with titles in a larger font size.
  • Cross-References
    • label{name} to label the point in the document with some mnemonic
    • Section ef{name} to refer to that point. ef{name} will be replaced by the number of the section containing the corresponding label command. As with your bibliography citations, run LaTeX twice to generate these references.
  • Abstracts—Place text between egin{abstract} and end{abstract} commands. The abstract should come immediately after maketitle.
  • Double Spacing— Put enewcommand{aselinestretch}{2} in the preamble.
  • Hyphenation
    • - (a single dash) is for hyphenating words.
    • -- (two dashes) is for ranges of numbers.
    • $-$ is a minus sign in math mode.
  • Quotation Marks—Beginning and ending quotation marks differ. In LaTeX, use “(on left side of the keyboard) to begin a quotation and ” (on right side of the keyboard) to end a quotation.
  • Changing the Appearance of Words
    • underline{phrase} to underline a phrase,
    • extbf{phrase} to print a phrase in boldface, and
    • emph{phrase} to italicize a phrase.
  • Spacing Between Words
    • One blank space is the same as thousand blank spaces.
    • Tabs are treated like blank spaces.
    • Blanks at the end of a line are ignored.
    • A single “Enter” is treated like a blank space.
    • More than one “ Enter” marks the beginning of a new paragraph.
  • Indenting—By default LaTeX indents new paragraphs unless the paragraph follows a section heading. To change the indentation, use the indent and oindent commands, at the beginning of the paragraph in question.
    • To choose the amount of indentation, use the command setlength{parindent}{size of indentation with unit}.
    • This command affects the whole document, it should go in the preamble, between the docu-mentclass and egin{document}.
  • Centering Text—By default, LaTeX will start all text at the left margin. To center a title, a table, etc., surround it with the commands egin{center} and end{center}.
  • Line Breaks—Use a ~ for a space that should not be used to break a line.
    • LaTeX inserts more space at the end of a sentence then between its words. For an abbreviation like Dr. in the middle of a sentence, use a ~ (if the line should not be broken there) or a followed by a space (if the line could be broken there).
    • To force a line to break at a given point, use \.
  • Mathematical Formulas—There are two ways to insert mathematical formulas into the document — (1) Formula appears in a paragraph with text — the formula will be compressed vertically, and (2) To have formula appear in a separate paragraph, where there will be more space.
    • For formulas that appear in a paragraph, surround them with $’s. For example, $alpha$ is a Greek alphabet, becomes, α is a Greek alphabet.
    • To have formulas appear in their own paragraph, use matching $$ to surround them. For example,

      $$

      frac{x+y}{x−y}

      $$

      Becomes

  • Greek Letters—α is alpha, β is eta, γ is gamma, δ is delta, ε is epsilon, θ is heta, σ is sigma, П is Pi. There are many more.
  • Exponents and Subscripts—Use the ^ character (shift-6), to create exponents. For example, $x^2$ produces x2
  • Fractions can be written in two ways — with a diagonal fraction bar or a horizontal one. For example, $(x+y)/(x−y)$ becomes (x+y)/(x−y), and

    $$

    frac{x+y}{x−y}

    $$

    Becomes

  • Functions—Use a backslash in front of function names cos, max, sin, an, min
  • Relations—≤ as le, ≥ as ge, ≠ as e, || as parallel, ≠ as ot=. There are many more.
  • Spacing in Math Mode—Use the following to adjust the spacing that LaTeX uses in math mode.
    • , produces a small space
    • : produces a medium space
    • ; produces a large space
  • Constructing Tables—Surround the entries with egin{tabular}{justification} and end{tabular} command. The justification should consist of l for left justification, c for centered justification, or r for right justification. Separate column entries by a &, and end each line with a \. Use hline to construct a horizontal line, and separate the l, c, and r’s by a | wherever you want a vertical line. For example:

    egin{tabular}{|r|c|l|}

    hline

    Right & Center & Left\

    hline

    alpha & beta & gamma\ delta & epsilon & zeta\ eta & theta & iota\

    hline

    end{tabular}

     

  • Bulleted Lists—Surround the information with egin{itemize} and end{itemize}, and begin each item with an item. For example,

    egin{itemize}

    item A bulleted item.

    egin{itemize}

    item A nested bulleted item.

    end{itemize}

    item Another bulleted list.

    end{itemize}

     

  • Numbered Lists—Surround the information with egin{enumerate} and end{enumerate}, and begin each item with a item. For example,

    egin{enumerate}

    item A numbered item.

    egin{enumerate}

    item A nested numbered item.

    end{enumerate}

    item Another numbered item.

    end{enumerate}

     

  • Bibliographies—LaTeX provides a mechanism for automatically linking citations with items in the bibliography. Surround the bibliography with egin{thebibliography} and end{thebibliography}. For each entry in the bibliography, start with ibitem{label}, where label is some mnemonic for the reference.
    • A citation in the body of the document is made with cite{label}, where label is the same as what occurs in the ibitem{label}.
    • To keep track of new references that have been added, run LaTeX twice before previewing when using cite.
  • Graphic File Formats—There are a number of graphics formats out there, such as — bmp, eps, gif, jpg, pdf, ps. LaTeX works best with the postscript formats (eps, ps) which were around when the program was first created. For the other formats, LaTeX may or may not work. Using PDFLaTeX will produce a PDF document.
  • Graphics Package—To include graphics in your document, use usepackage{graphicx} in the preamble.
  • Including Graphics Within Your Document—Use the includegraphics{graphicfile} command to include the graphic file in the document. To control the size of the document, specify the height and width: includegraphics[height=2in, width = 3in]{graphicfile}.
21.5 SOLVED EXAMPLES

Here some examples are given that use the various LaTeX commands.

Example 1: Create a title for your article.

Solution 1:

documentclass [twocolumn, 11 pt] {article}

itle{HUGE extbf{Preparation of Papers for IEEE TRANSACTIONS and JOURNALS (May 2007)}}

author{First A. Author, Second B. Author, Jr., and Third C. Author, extit{Member, IEEE}} egin{document}

maketitle

end{document}

Output

Preparation of Papers for IEEE TRANSACTIONS
and JOURNALS (May 2007)

 

First A. Author, Second B. Author, Jr., and Third C. Author, Member, IEEE
August 19, 2009

Example 2: Create a section.

Solution 1:

documentclass{article}

egin{document}

section{Introduction}

Hello how are you?

I am fine here. end{document}

In the same exercise, if we use line break — documentclass{article}

egin{document}

section{Introduction}

Hello how are you?\

I am fine here.

end{document}

Example 3: Create a bulleted list.

Solution 1:

documentclass [twocolumn, 11 pt] {article}

itle{HUGE extbf{Preparation of Papers for IEEE TRANSACTIONS and JOURNALS(May 2007)}}

author{First A. Author, Second B. Author, Jr., and Third C. Author, extit{Member, IEEE}} egin{document}

maketitle

section{Introduction}

This is a display of bulled list egin{itemize}

item Vegetables.

egin{itemize}

item Potato,

item Tomato,

item Brinjal,

item Onion,

item Spinach end{itemize}

item Fruits.

egin{itemize}

item Apple,

item Mango,

item Banana,

item Plum,

item Peach end{itemize}

end{itemize}

end{document}

Output

Preparation of Papers for IEEE TRANSACTIONS
and JOURNALS (May 2007)

First A. Author, Sccond B. Author, Jr., and Third C. Author, Member, IEEE
August 19, 2009

1 Introduction

This is a display of bulled list,

  • Vegetables.
    • Potato,
    • Tomato,
    • Brinjal,
    • Onion,
    • Spinach
  • Fruits.
    • Apple,
    • Mango,
    • Banana,
    • Plum,
    • Peach

Example 4: Create a numbered list.

Solution 1:

documentclass {article}

egin{document}

section{Introduction}

This is a display of numbered list egin{enumerate}

item Abstract.

item Introduction.

item Section 1.

egin{enumerate}

item Section 1.1.

item Section 1.2 end{enumerate}

item Section 2 end{enumerate}

end{document}

                        Output

Example 5: Write a paragraph, Use emphasize, bold, and bulleted list.

Solution:

documentclass {article}

egin{document}

section{Choose an Internet Connection}

With the growth of technology, the content on the Web has also changed. Now web applications include content like animations, online gaming, database-driven Web sites and e-commerce. Thus, the need for speed as to how fast we can connect to the Internet has changed.

Here, we give the overall connection speeds of the different types of Internet connections, though they can vary between extbf{Internet Service Providers (ISP)}.

egin{itemize}

item emph {Dial-up access} is economical but slow. Dial-up access uses normal telephone lines so the quality of the connection is not always good. Speed is 2400 bps to 56 Kbps.

item emph {Integrated services digital network (ISDN)} is an international communications standard for sending voice, video, and data over telephone lines. Speed is 64 Kbps to 128 Kbps.

item emph {DSL} is an always on connection. ADSL is the most commonly deployed type of DSL. Speed is 128 Kbps to 8 Mbps.

item emph {Cable modem} gives you a broadband Internet connection that is designed to operate over cable TV lines. Speed 512 Kbps to 20 Mbps.

item emph {Wireless Internet Connections} uses radio frequency bands. Wireless Internet provides an always-on connection which can be accessed from anywhere geographically within a network coverage area. Their speed varies.

item emph {T-1 Lines} are a leased line option for businesses connecting. T-1 Lines support speeds of 1.544 Mbps.

item emph {Internet over Satellite (IoS)} allows a user to access the Internet via a satellite that orbits the earth. Speed: 492Kbps to 512 Kbps.

end {document}

Output

Example 5: Display some mathematical formulae.

Solution:

documentclass {article}

egin{document}

section{Some Mathematical Formulae}

Area of Circle is $ pi * r^2$\

Area of Rectangle is $ length * breadth$\

Area of triangle is $1/2*base*height$\

$sin(x) + cos(x) = 1$

$$

frac{2}{10}

= frac{4}{20}

= frac{8}{40}

$$

end {document}

                        Output

EXERCISES

Type in a text and perform the following operations on it.

  1. Put page numbering and headings
  2. Create a Title Page — include title, author name and address (two authors side by side), and date.
  3. Create sections both numbered and without numbers.
  4. Include Abstract.
  5. Double space the article.
  6. Use Hyphenation in text. (Example sister-in-law)
  7. Enclose a sentence in quotes.
  8. Use underline, boldface and italics.
  9. Write ten mathematical formulae.
  10. Construct a table with entries.
  11. Create a bulleted list.
  12. Create a numbered list.
  13. Add bibliography.
  14. Include a graphics file in the document.
  15. Print some part of text exactly as you have typed it.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.136.18.141