MATLAB for the Sciences - A Preliminary Discussion in LaTeX, Part 2

16 downloads 206 Views 200KB Size Report
MATLAB for the Sciences. A Preliminary Discussion in LATEX, Part 2. Jon M. Ernstberger. January 6, 2008. Jon M. Ernstberger. MATLAB for the Sciences ...
MATLAB for the Sciences A Preliminary Discussion in LATEX, Part 2 Jon M. Ernstberger

January 6, 2008

Jon M. Ernstberger

MATLAB for the Sciences

Multiple Lines of Equations Just as there was an environment for writing equations, there is an environment for multi-line equations. \begin{eqnarray} f(x)&=&(x+2)^2\\ &=&x^2+4x+4 \end{eqnarray} which is LATEX’d as f (x) = (x + 2)2 2

= x + 4x + 4

(1) (2)

Note: The two &s wrapped around the “=” denote where alignment of the two lines will take place. The \\ is the same as in the tabular environment. Jon M. Ernstberger

MATLAB for the Sciences

In-Line Math

Sometimes you want to include math directly in a sentence. An example might be The graph of f (x + 3) is the translation of the graph of f (x) by three units to the left.

Jon M. Ernstberger

MATLAB for the Sciences

In-Line Math

Sometimes you want to include math directly in a sentence. An example might be The graph of f (x + 3) is the translation of the graph of f (x) by three units to the left. You could do this inline with LATEXby wrapping your math syntax with $ signs. The above LATEXsyntax is The graph of $f(x+3)$ is the translation of the graph of $f(x)$ by three units to the left.

Jon M. Ernstberger

MATLAB for the Sciences

The Enumerate Environment Sometimes, in a document, you might want to make a numbered list. \begin{enumerate} \item First item. \item Second item. \end{enumerate} which is LATEX’d as 1 2

First item. Second item.

Each \item tag denotes a new item in the list. If you include \usepackage{enumerate} in the preamble, you can change the numbering by \begin{enumerate}[a.)]

Jon M. Ernstberger

MATLAB for the Sciences

The Itemize Environment

Sometimes, in a document, you might want to make a bulleted list. You can do this with \begin{itemize} \item First item. \item Second item. \end{itemize} which is LATEX’d as First item. Second item.

Each \item tag denotes a new item in the list.

Jon M. Ernstberger

MATLAB for the Sciences

Incorporating Graphics

In the preamble add \usepackage{graphicx}. In the body you use \includegraphics{filename}. The graphics file must be an encapsulated postscript (.eps) file. You can scale the image using \includegraphics[scale=.5]{filename} which would scale the image by 1/2. You don’t have to include the .eps extension.

Jon M. Ernstberger

MATLAB for the Sciences

Putting Those Graphics in a Figure Environment Often, we want to make that image look nice in a clearly defined format in the body of the document. For this we use the figure environment. For example: \begin{figure} \begin{center} %we’re centering the image \includegraphics[scale=.2]{splash} \end{center} \end{figure} which is LATEX’d as

Jon M. Ernstberger

MATLAB for the Sciences

The Figure Environment You can include captions in the figure environment by using the \caption{text} tag. For example. \begin{figure} \begin{center} %we’re centering the image \includegraphics[scale=.2]{splash} \end{center} \caption{The MATLAB splash screen.} \end{figure} is LATEX’d as

Figure: The MATLAB splash screen. Jon M. Ernstberger

MATLAB for the Sciences

Putting Those Tables in a Table Environment We often need the same picturesque settings for tables created with the tabular environment. Consequently, we use the table environment. This can be used as \begin{table} \begin{center} \begin{tabular}{|c|c|c|} \hline & & & \\ \hline & & & \\ \hline \end{tabular} \end{center} \caption{Table description.} \end{table} Jon M. Ernstberger

MATLAB for the Sciences

References and Labels in Equations I don’t always want to retype equations over and over. I can use labels like this: \begin{equation} f(x)=2x+3\label{eqnnum1} \end{equation} Which renders (after running LATEXtwice) as f (x) = 2x + 3 I can reference this equation using \eqref{eqnnum1}. For instance: In Equation (3), ........ This works for the eqnarray environment as well.

Jon M. Ernstberger

MATLAB for the Sciences

(3)

References and Labels for Figures and Tables

Does this mean I can reference Figures and Tables too?

Jon M. Ernstberger

MATLAB for the Sciences

References and Labels for Figures and Tables

Does this mean I can reference Figures and Tables too? Yes! In the figure or table environments, after the necessary caption, you need a \label{labelname} tag. For example: \begin{figure} \begin{center} %we’re centering the image \includegraphics[scale=.2]{splash} \end{center} \caption{The MATLAB splash screen.} \label{fig:splash_screen} \end{figure}

Jon M. Ernstberger

MATLAB for the Sciences

Referencing Figures and Tables, cont. This is rendered as

Figure: The MATLAB splash screen.

I can reference this figure with the \ref{fig:splash screen} command. For example: In Figure 2, we see the MATLAB 2008b splash screen. In an article, the figure would have the number in the caption. Same idea entirely for tables. Jon M. Ernstberger

MATLAB for the Sciences

Placement of Tables and Figures LATEXis a typesetting language. But we do have some preferential control built into LATEX. In both the figure and table environments, we can specify “here”, “top”, or “bottom” using h,t,or b. For example: \begin{figure}[!h] specifies that LATEXshould try to place the image in that location in the text (presuming sizes are OK). \begin{figure}[!bt] will try to place the image at the bottom of the page first and then at the top, otherwise. The “!” means do it!

Jon M. Ernstberger

MATLAB for the Sciences

Bibliographies There are several ways to do this, but the simplest way is with the thebibliography environment. This can be done at the end of the document with \begin{thebibliography}{widest-label} \bibitem{cite_key} literature citation ... \end{thebibliography} The widest label is typically set to 99. cite key like the labels used in figure and table environments and will be used to reference the entry. The bibliography entry is cited using \cite{cite key}. A Really Great Example is given at http://cs.guc.edu.eg/research/latex_online_ tutorial/LaTeX/LaTeX_05/latex_bibtex_01.html. Jon M. Ernstberger

MATLAB for the Sciences

Online References

http://www.maths.tcd.ie/~dwilkins/LaTeXPrimer/ http://www.artofproblemsolving.com/Wiki/index. php/LaTeX http://www.latex-project.org/ http://en.wikibooks.org/w/index.php?title=LaTeX/ Print_version&printable=yes http: //en.wikibooks.org/wiki/LaTeX/Importing_Graphics http://www.google.com/scholar

Jon M. Ernstberger

MATLAB for the Sciences

Project #1 You must submit a paper of sufficient length containing the following: An appropriate introductory section. You should write the introduction after you see the other sections. A section that contains multiplication table of the numbers 1-10, nested in a table environment with appropriate caption. This table will be referenced in the paper. The table should be fully gridded. A section including a very detailed discussion of the product and quotient rules (recall Calculus!), and then the relation of the derivatives    d  d sin(x) and arctan(x) sin 2x 2 . 2 dx 2x dx Your final equation for each of those should be referencable elsewhere in the paper.

Jon M. Ernstberger

MATLAB for the Sciences

Project #1, cont. A third section containing a discussion of MATLAB (obviously, this can’t be much!). You can use anything we’ve already talked about in class. In this section you must have insert a figure at the top of the page (use [!t]) of the MATLAB splash screen (splash.eps) posted on the course website. You should also reference two sources (electronic or hard) on MATLAB. These should be contained in a citable bibliography at the end of your document. A final concluding section which references your multiplication table, the final version of your derivatives, and the MATLAB image. Obviously, you should have a citable bibliography. You may use whatever citation format you like. These must be full and complete citations.

The due date for this project is Monday, January 12th at 8:00 AM. Send only the .tex file labeled first last project1.tex to [email protected]. Jon M. Ernstberger

MATLAB for the Sciences