brief a brief introduction to l a t e x for physics graduate students prof. l. s. pinsky physics...

21
A BRIEF BRIEF Introduction to L A T E X For Physics Graduate Students Prof. L. S. Pinsky Physics Department University of Houston

Upload: oscar-thomas

Post on 02-Jan-2016

216 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: BRIEF A BRIEF Introduction to L A T E X For Physics Graduate Students Prof. L. S. Pinsky Physics Department University of Houston

A BRIEFBRIEF Introduction to LATEX

For Physics Graduate Students

Prof. L. S. PinskyPhysics DepartmentUniversity of Houston

Page 2: BRIEF A BRIEF Introduction to L A T E X For Physics Graduate Students Prof. L. S. Pinsky Physics Department University of Houston

This Talk Will…

Give you a VERY BRIEF Introduction to LATEX.

Point you to the resources you can consult to learn more and to answer specific questions…Explain the broadest concepts of LATEX.

This Talk will NOT make you a LATEX Expert…

This Talk will NOT teach you how to run LATEX on any arbitrary platform (or OS).

2© 2009 L. Pinsky

LATEX for Physics Graduate Students

Summer 2009 PHYS 6340

Page 3: BRIEF A BRIEF Introduction to L A T E X For Physics Graduate Students Prof. L. S. Pinsky Physics Department University of Houston

TeX

TeX is a TYPESETTINGTYPESETTING Language… TeX is actually used by typesetting machines

to set type to print everything from textbooks to newspapers…

TeX is to a typesetting machine basically like machine language is to a Computer CPU.

Ultimately, you should keep in mind that what TeX does is to position each character or graphic like an individual piece of printer’s type at a precise location on the page…

3© 2005 L. Pinsky

LATEX for Physics Graduate Students

Summer 2009 PHYS 6340

Page 4: BRIEF A BRIEF Introduction to L A T E X For Physics Graduate Students Prof. L. S. Pinsky Physics Department University of Houston

…and LATEX

LATEX is a compiler language like C or

Fortran is to a computer.It allows the programmer to use a higher order, more user-friendly language format to set up the instructions for TeX.…AND, like Fortran or C, LATEX must be

COMPILEDCOMPILED into a TeX file…TeX outputs a special “machine language” like file called a “Device Independent” or “.dvi” file.

4© 2005 L. Pinsky

LATEX for Physics Graduate Students

Summer 2009 PHYS 6340

Page 5: BRIEF A BRIEF Introduction to L A T E X For Physics Graduate Students Prof. L. S. Pinsky Physics Department University of Houston

What Good is a “.dvi” FILE?

Well, if you have a typesetting machine, you can submit the “.dvi” file directly to it to print the pages you set up.More to the point and for our applications, there are translator routines available to convert “.dvi” files into “.pdf” and “.ps” files, as well as print drivers for most printers to allow you to print a “.dvi” file directly without having to view it on the screen…

5© 2005 L. Pinsky

LATEX for Physics Graduate Students

Summer 2009 PHYS 6340

Page 6: BRIEF A BRIEF Introduction to L A T E X For Physics Graduate Students Prof. L. S. Pinsky Physics Department University of Houston

Real Men Do It Right…You need 5 things to use LATEX to make a viewable document:1. A Text Editor to create the and LATEX file.

This is a Text File, typically with a “.txt” extension

A LATEX Program to COMPILECOMPILE the Text File.1. The LATEX program outputs a “.tex” file.

1. A TeX Program to execute the “.tex” File. The TeX program outputs a “.dvi” file.

2. A Converter Program to make a viewable File1. Linux comes with “dvi2ps” to make “.ps” files

An appropriate Viewer Program… (e.g. Gimp)

6© 2005 L. Pinsky

LATEX for Physics Graduate Students

Summer 2009 PHYS 6340

Page 7: BRIEF A BRIEF Introduction to L A T E X For Physics Graduate Students Prof. L. S. Pinsky Physics Department University of Houston

Smart Men Use Modern Tools…

Composite LATEX Tools exist for virtually all platforms (e.g. LATEXIT), and ancillary tools (e.g. Excalibur) which provides a spell checker…

These “tools” typically combine the 5 items in one complete package with multiple windows.

Some, have automatic simultaneous compliers to show you what your “code” produces as you type, and others require you to click a button to update the viewer window…

7© 2005 L. Pinsky

LATEX for Physics Graduate Students

Summer 2009 PHYS 6340

Page 8: BRIEF A BRIEF Introduction to L A T E X For Physics Graduate Students Prof. L. S. Pinsky Physics Department University of Houston

Document ClassesLATEX includes several standard “Document Classes.” These are organized with a preset list of constituent “sub-sections” appropriate to the type of Document.Other “Style-Files” can be created externally to specify a new document class with its own unique structure.You can create your own such document classes with their associated “Style-Files,” but the typical situation is that, as noted on the next slide, a publisher or conference organizer will provide the “Style-File” to be used.

8© 2005 L. Pinsky

LATEX for Physics Graduate Students

Summer 2009 PHYS 6340

Page 9: BRIEF A BRIEF Introduction to L A T E X For Physics Graduate Students Prof. L. S. Pinsky Physics Department University of Houston

Moving on to the LATEX Text File

The LATEX input file has 2 major parts:1. A Header, which contains general formatting

information (e.g. fonts, spacing, alignment) and like C, a list of packages to be included.

The Header information can be automatically read-in from an external file, called a “Style-File”…

Most technical publishers (Journals) provide style-files that you can download.

NS&M has a style file for Ph.D. theses in this college!!!

2. The Body of the document, which contains the actual content of the document to be rendered.

This is what we will focus on now…

9© 2005 L. Pinsky

LATEX for Physics Graduate Students

Summer 2009 PHYS 6340

Page 10: BRIEF A BRIEF Introduction to L A T E X For Physics Graduate Students Prof. L. S. Pinsky Physics Department University of Houston

Entering the Actual Content:Some Basics…

The format for LATEX is similar in philosophy to HTML in that there are “Escape” characters to signal commands within the normal content text. The general “Escape” character is the “\”.

Also similar to HTML, the ”Escape” sequence can be used to change the “Environment”… e.g. \begin{textbf} Text to be in bold font. \

end{textbf} , or \textbf{Text to be in bold font.} produces the same thing, namely:

Text to be in bold font.10

© 2005 L. PinskyLATEX for Physics Graduate

StudentsSummer 2009 PHYS 6340

Page 11: BRIEF A BRIEF Introduction to L A T E X For Physics Graduate Students Prof. L. S. Pinsky Physics Department University of Houston

The Basics, Continued…

There are 10 special characters that are used as part of LATEX commands:# $ % & ~ _ ^ \ { }

When you need to use these as actual characters, 7 are easy to reproduce:

just type: \# \$ \% \& \_ \{ \}

The other three have to be reproduced with the “verbatim” environment command”:\verbatim{\}, \verbatim{^} and \verbatim{~}

11© 2005 L. Pinsky

LATEX for Physics Graduate Students

Summer 2009 PHYS 6340

Page 12: BRIEF A BRIEF Introduction to L A T E X For Physics Graduate Students Prof. L. S. Pinsky Physics Department University of Houston

CommandsAll commands are preceded by the Escape character “\”.The following Commands are considered to be “Fragile”: \ \begin \end \footnote

Fragile Commands cannot be placed within other commands.

e.g. \begin{textbf /end}

12© 2005 L. Pinsky

LATEX for Physics Graduate Students

Summer 2009 PHYS 6340

Page 13: BRIEF A BRIEF Introduction to L A T E X For Physics Graduate Students Prof. L. S. Pinsky Physics Department University of Houston

Comments

The “%” symbol indicates a Comment that will not be included in the final text or interpreted as a command.Everything on a line after the “%” symbol is ignored by LATEX.

Note that placing the “%” symbol on a line, makes the next line continuous with any text prior to the “%” symbol… That is the <RETURN> is ignored as well…

13© 2005 L. Pinsky

LATEX for Physics Graduate Students

Summer 2009 PHYS 6340

Page 14: BRIEF A BRIEF Introduction to L A T E X For Physics Graduate Students Prof. L. S. Pinsky Physics Department University of Houston

Sectioning Commands

The following “Sectioning” commands can be used to indicate internal divisions within a Document: \part{Any Title Information} \chapter{Any Title Information} \section{Any Title Information} \subsection{Any Title Information} \subsubsection{Any Title Information} \paragraph{Any Title Information} \subparagraph{Any Title Information}

14© 2005 L. Pinsky

LATEX for Physics Graduate Students

Summer 2009 PHYS 6340

Page 15: BRIEF A BRIEF Introduction to L A T E X For Physics Graduate Students Prof. L. S. Pinsky Physics Department University of Houston

Spacing Within ParagraphsWords are separated by spaces, but LATEX will

choose the actual spacing, so multiple spaces in the input text are the same as one space.A period followed by a space (or spaces) and a capital letter, is presumed to be the end of a sentence. To add space in other situations, type “.\☐” (☐ means “space”).The exception to this rule is when a period follows an upper case letter. In rare cases where a sentence Does end that way, type “.\@” to indicate the end of a sentence.

15© 2005 L. Pinsky

LATEX for Physics Graduate Students

Summer 2009 PHYS 6340

Page 16: BRIEF A BRIEF Introduction to L A T E X For Physics Graduate Students Prof. L. S. Pinsky Physics Department University of Houston

Spacing of ParagraphsOne or more BLANK lines indicates the end of a paragraph. (The style commands in the header determine how that will be dealt with in general within each type of sub-component of the document).You can add additional vertical space between paragraphs by using the \vspace{distance} command, where “distance” can be in mm or in.

e.g. \vspace{7mm} or \vspace{.25in}. You can use this command in the midst of a

paragraph as well, but this is very unusual.

16© 2005 L. Pinsky

LATEX for Physics Graduate Students

Summer 2009 PHYS 6340

Page 17: BRIEF A BRIEF Introduction to L A T E X For Physics Graduate Students Prof. L. S. Pinsky Physics Department University of Houston

Special Characters and Symbols

LATEX has a virtually complete collection of all

symbols and characters. It is not possible (or desirable) to try and list them here, but many references that do list them are available among the various LATEX tools…

\copyright © \Psi Ψ \psi ψ \”{o} ö \oe œ \pounds £ …etc.

17© 2005 L. Pinsky

LATEX for Physics Graduate Students

Summer 2009 PHYS 6340

Page 18: BRIEF A BRIEF Introduction to L A T E X For Physics Graduate Students Prof. L. S. Pinsky Physics Department University of Houston

Bibliographies and CitationsTypically, one has a list of sources at the end of a document that are numbered, then those are “cited” by reference in the text to their Bibliography Number.

The \cite{Pinsky:2008} command would insert a reference in the text to the corresponding Bibliography item with the “Citation Key” = “Pinsky:2008”. The “Citation Key” may be any sequence of letters, digits and punctuation, except that it may not contain a comma.

To set up the Bibliography itself, one uses a separate program called BIBTEXBIBTEX…

Bibliographies are imported from BIBTEXBIBTEX with the command: \bibliography{alpha,beta}, which will cause LATEX to import the files: alpha.bib and beta.bib during compilation.

To use BIBEXBIBEX, the following command must appear anywhere after the \begin{document} command: \bibliographystyle{plain}. There are many different styles available besides “plain.”

18© 2005 L. Pinsky

LATEX for Physics Graduate Students

Summer 2009 PHYS 6340

Page 19: BRIEF A BRIEF Introduction to L A T E X For Physics Graduate Students Prof. L. S. Pinsky Physics Department University of Houston

Mathematical ExpressionsThere are 2 types of Mathematical Expressions: Inline and Separate.

The command for an INLINE Mathematical Expression is: \(expression) The command for a SEPARATE Mathematical Expression is: \

[expression]

Fractions are set up with the \fract{numerator}{denominator} command…Exponents are set up with the base^{exponent} command…Subscripts with the base_{subscript} commndIntegrals and Sums are set up with the \int{} and \sum{} commands:

e.g. \[\sum_{i=1}^{n} x_{i} = \int_{0}^{\infinity} f(x) dx.]

Overlines are created with the \overline command…Similar commands exist to create matrices and arrays…

19© 2005 L. Pinsky

LATEX for Physics Graduate Students

Summer 2009 PHYS 6340

Page 20: BRIEF A BRIEF Introduction to L A T E X For Physics Graduate Students Prof. L. S. Pinsky Physics Department University of Houston

Embedding Graphics

There are several ways to embed graphics in a document, (including the Graphics Package), but the most common is to use the \begin{figurename} command: \begin{figure} \includegraphics{mygraphics.jpg} \caption{caption text} \end{figure}

20© 2005 L. Pinsky

LATEX for Physics Graduate Students

Summer 2009 PHYS 6340

Page 21: BRIEF A BRIEF Introduction to L A T E X For Physics Graduate Students Prof. L. S. Pinsky Physics Department University of Houston

Some Tools to Consider…

Latexit…

21© 2005 L. Pinsky

LATEX for Physics Graduate Students

Summer 2009 PHYS 6340