MATLAB for the Sciences. A Preliminary Discussion in LATEX. Jon M.
Ernstberger. January 6, 2008. Jon M. Ernstberger. MATLAB for the Sciences ...
MATLAB for the Sciences A Preliminary Discussion in LATEX Jon M. Ernstberger
January 6, 2008
Jon M. Ernstberger
MATLAB for the Sciences
What Is LATEX?
LaTeX is a document preparation system for high-quality typesetting. It is most often used for medium-to-large technical or scientific documents but it can be used for almost any form of publishing....LaTeX is not a word processor! This isn’t MS-Word on steroids. You supply the content, and LATEXcontrols the format. You know the “markup” and LATEXinterprets your code. A LATEXfile ends with the extension “.tex”.
Jon M. Ernstberger
MATLAB for the Sciences
Getting Started... There are some things we’ve got to download to use LaTeX. First, make sure you have the command prompt: Windows Vista: Start → Accessories → Command Prompt. Windows XP: Start → Run →. Type ”cmd”. Press Enter.
Download MikTeX from http://miktex.org. Download the Basic Installation This should be about 83 MB. Pick a “fairly” local mirror.
Download GhostScript http://mirror.cs.wisc.edu/.../gs863w32.exe. Install it. The DL is about 10.1 MB.
Download GSView http://mirror.cs.wisc.edu/.../gsv49w32.exe. Install it. The DL is less than 2 MB.
Jon M. Ernstberger
MATLAB for the Sciences
Getting Started, Part Deux
The only other thing left is the choice of an editor. WinEdt 30 days free, buy it after that. Easy to use. Includes built-in GUI commands
LEd Free Seems easy to use. Maybe similar to WinEdt.
Crimson Editor Editor only. Provides syntax highlighting. Must manually LATEXthe files.
Jon M. Ernstberger
MATLAB for the Sciences
Hello, World!
Type the following in a new file \documentclass{article} \begin{document} Hello, world! \end{document} Save it as helloworld.tex. LATEXthe file. What do you get?
Jon M. Ernstberger
MATLAB for the Sciences
Important Parts
\documentclass{article} The “documentclass” command is necessary for all documents. It takes as input the type of document. “Article” is the typical documentclass used for books, letters, and articles in scholarly journals.
\begin{document}...\end{document} These mark the beginning and end of the body of the document. Your content goes in here. Everything before this is called the preamble.
Jon M. Ernstberger
MATLAB for the Sciences
Things to Know!
Paragraphs: you don’t have to type the indent. All you have to do is put a double-space between the paragraphs. Create two paragraphs about anything. Put a double-space between them. LATEXthe document.
You don’t make the title happen. LATEXdoes it for you! In the preamble type: \author{Your Name} \title{Sample Document}
In the body, type \maketitle LATEXthe document.
Pagenumbering? You don’t even have to try. It’s automagic!
Jon M. Ernstberger
MATLAB for the Sciences
Document Organization
You organize your document using sections, subsections, and subsubsections. Section Example \section{The Name of My First Section} blah blah blah blah blah blah blah blah blah blah.......... Subsection Example \section{The Name of My First Section} blah blah blah blah blah blah \subsection{Subsection Title} blah blah blah blah.......... I think you get the idea for subsubsections.
Jon M. Ernstberger
MATLAB for the Sciences
In-Class Exercise
Take 20 minutes and write an autobiography. The title should be “Your name: An Autobiography” You should (obviously) be the author. There should be two sections: the first ten years, and then eleven years and after. Paragraphs must have at least two sentences.
Jon M. Ernstberger
MATLAB for the Sciences
The Tabular Environment This is how we do tables in LATEX. To begin a table, type \begin{tabular} \end{tabular} At this stage, compilation will not occur. The \begin{tabular} command takes as argument the number of columns and their alignments. Example \begin{tabular}{ccc} implies that the table has 3 columns, each of which are centered (c). The other options are left-aligned (l) and right-aligned(r). Jon M. Ernstberger
MATLAB for the Sciences
The Tabular Environment, cont.
A simple example: \begin{tabular}{lll} 1 & 2 & 3\\ 4 & 5 & 6\\ 7 & 8 & 9 \end{tabular} The & separates the columns in the row. The \\ ends the row. 1 Here’s how that code looks when compiled. 4 7
Jon M. Ernstberger
MATLAB for the Sciences
2 5 8
3 6 9
The Tabular Environment, cont. Now we want grids in our table. By defining the tabular environment with |l|l|l| we’ve added the vertical bars to the columns. \begin{tabular}{|l|l|l|} 1 & 2 & 3\\ 4 & 5 & 6\\ 7 & 8 & 9 \end{tabular} 1 That code, when compiled, generates 4 7 What about horizontal lines?
Jon M. Ernstberger
2 5 8
MATLAB for the Sciences
3 6 9
The Tabular Environment, cont. Now we want horizontal grids in our table. We use the command \hline Now \begin{tabular}{|l|l|l|} \hline 1 & 2 & 3\\ \hline 4 & 5 & 6\\ \hline 7 & 8 & 9\\ \hline \end{tabular} 1 2 3 That code generates 4 5 6 7 8 9 Jon M. Ernstberger
MATLAB for the Sciences
In-Class Exercise Start a new document, with documentclass “article”. Title the document “Special Environments in LATEX”. You’ll be the author, obviously. In the preamble, add the new field \date{yourbirthday} Create a new section entitled “A Table Example”. Create a new table with four columns: mammals, reptiles, birds, and insects. List five items for each column. Center this item horizontally on the page by wrapping your tabular environment in \begin{center} \begin{tabular}{...} ..... \end{tabular} \end{center} Jon M. Ernstberger
MATLAB for the Sciences
The Equation Environment
To type equations we use the equation environment. It begins with \begin{equation} type your equation here... \end{equation} This environment will automatically number the equation. The equation environment will automatically position your equation in display mode. How do you type the equations?
Jon M. Ernstberger
MATLAB for the Sciences
How to Type Equations
Examine the link http://www.artofproblemsolving.com/ Wiki/index.php/LaTeX:Commands. In the “Special Environments in LATEX” document, add a new section for “Equation Examples”. In separate equation environments type the following: f (x) = 3x 4 + 2x 3 + x 2 + 5x + 6 d sin x 2 . Then equate that to the proper answer of that dx derivative. Rb a
f (x)dx =
R 100 R π 1
−π
Pn
i=1
f (xi )h.
sin(x)ydxdy .
Jon M. Ernstberger
MATLAB for the Sciences