Become a L A T EX Guru Jason Gross 13 1 Many thanks to Michele, who - - PowerPoint PPT Presentation

become a l a t ex guru
SMART_READER_LITE
LIVE PREVIEW

Become a L A T EX Guru Jason Gross 13 1 Many thanks to Michele, who - - PowerPoint PPT Presentation

Getting Started L A T EX and Math Miscellaneous Exercises Become a L A T EX Guru Jason Gross 13 1 Many thanks to Michele, who was my coteacher for this class for Splash 2009 Jason Gross 13 Become a L A T EX Guru Getting Started


slide-1
SLIDE 1

Getting Started L

A

T EX and Math Miscellaneous Exercises

Become a L

AT

EX Guru

Jason Gross ’13

1Many thanks to Michele, who was my coteacher for this class for Splash

2009

Jason Gross ’13 Become a L

A

T EX Guru

slide-2
SLIDE 2

Getting Started L

A

T EX and Math Miscellaneous Exercises

  • 1. Log in using the username sipb2 and the password

hsspMONSTER

  • 2. Once you are logged on, type sudo apt-get install kile
  • kular in the terminal and press enter.
  • 3. When prompted for a password, type the password you used

to log on (in this case, hsspMONSTER) and press enter. Do not worry if the password does not show up as you type it.

  • 4. When it asks you if you want to continue, type y and press

enter.

  • 5. When it is finished installing, type kile in the terminal, and

press enter.

  • 6. Happy L

AT

EXing!

Jason Gross ’13 Become a L

A

T EX Guru

slide-3
SLIDE 3

Getting Started L

A

T EX and Math Miscellaneous Exercises How to set up a document Help files Good L

A

T EX practices Optional (but useful) packages

How to set up a document

\documentclass{article} \usepackage{amsmath} \begin{document} Your stuff goes here! \end{document}

Jason Gross ’13 Become a L

A

T EX Guru

slide-4
SLIDE 4

Getting Started L

A

T EX and Math Miscellaneous Exercises How to set up a document Help files Good L

A

T EX practices Optional (but useful) packages

The default we have given is the article document type, but there are others available: report, book, letter, slides. You can also set options for your document: \documentclass[11pt, letterpaper, landscape, twoside] {article}. Refer to the help files for more details.

Jason Gross ’13 Become a L

A

T EX Guru

slide-5
SLIDE 5

Getting Started L

A

T EX and Math Miscellaneous Exercises How to set up a document Help files Good L

A

T EX practices Optional (but useful) packages

Help files

◮ lshort: This is the biggest beginner help file available on the

web for L

AT

  • EX. Go to http:

//mirror.ctan.org/info/lshort/english/lshort.pdf. Alternatively, Google lshort and it will come up.

◮ Google: One of the best help files out there. Google anything

you want to accomplish along with L

AT

EX and you will get

  • something. Unless of course you type

"Build a time machine" latex.

◮ http://www.ctan.org: Gives the full documentation for any

package, the source code, etc.

◮ http://detexify.kirelabs.org/classify.html. Slightly

more useful for tablets, but useful nonetheless. If you need help finding a specific symbol, we can help you.

Jason Gross ’13 Become a L

A

T EX Guru

slide-6
SLIDE 6

Getting Started L

A

T EX and Math Miscellaneous Exercises How to set up a document Help files Good L

A

T EX practices Optional (but useful) packages

Good L

AT

EX practices

◮ The default margins are small for a reason. It is easier to read

papers if there are no more than 80 characters on a line; this is why newspapers have multiple columns. Don’t change the defaults unless you have good reason to and you know what you are doing.

◮ In general, don’t change the defaults unless you have good

reason to. This applies to font size as well.

◮ L AT

EX (mostly) ignores duplicated white space. If you have two

  • r more returns in a row, this makes a new line. Don’t tell

L

AT

EX to make multiple blank lines because it knows how to make things more readable. The one major exception to this rule is math mode.

Jason Gross ’13 Become a L

A

T EX Guru

slide-7
SLIDE 7

Getting Started L

A

T EX and Math Miscellaneous Exercises How to set up a document Help files Good L

A

T EX practices Optional (but useful) packages

◮ Every so often in the source code press enter (to make it

readable - about every 80 characters). This won’t affect your

  • utput because L

AT

EX doesn’t render single line breaks.

◮ Use logical structure in your documents. Don’t hardcode (too

much) formatting into your document; use predefined L

AT

EX commands (like \section{}, etc.).

◮ (For advanced L AT

EX users) Don’t define too many macros, use obscure packages not on CTAN, and do other weird things like that. If you do, publishers won’t like you very much.

Jason Gross ’13 Become a L

A

T EX Guru

slide-8
SLIDE 8

Getting Started L

A

T EX and Math Miscellaneous Exercises How to set up a document Help files Good L

A

T EX practices Optional (but useful) packages

Optional (but useful) packages

Packages provided added functionality for your L

AT

EX code. To include a package use the command \usepackage[(optional) Options]{Package name}. Package name Description amsmath Gives an environment for typsetting math formulas. Namely \begin{equation} \end{equation}, among

  • ther

things. amssymb Gives mathematical symbols that may not be built into L

AT

EX amsthm Gives an environment for typing the-

  • rems in a standard format

Jason Gross ’13 Become a L

A

T EX Guru

slide-9
SLIDE 9

Getting Started L

A

T EX and Math Miscellaneous Exercises How to set up a document Help files Good L

A

T EX practices Optional (but useful) packages

Package name Description graphicx Can insert pictures from .jpg, .pdf, .png, .eps, among others using the \includegraphics[(optional) Op- tions]{filename} hyperref Lets you make hyperlinks geometry Lets you change the margins enumerate Lets you control the enumerate envi- ronment for lists and outlines You’ll want to load amsmath and amssymb for any sort of math typsetting.

Jason Gross ’13 Become a L

A

T EX Guru

slide-10
SLIDE 10

Getting Started L

A

T EX and Math Miscellaneous Exercises Basic math typsetting

Ways to get into math mode

◮ As you are typing regular text, put any math mode commands

(or math) between $$ like so: $\frac{3}{4}$ (this will look like 3

4). This can be inserted right in the middle of text:

The answer is $x = 3$.

◮ Use the package amsmath and then use

\begin{equation}\end{equation} (numbers your lines between the two commands) or \begin{equation*}\end{equation*} (does not number your lines).

◮ Place math between \[insert math here\] or $$insert math

here$$ to get it centered on a new line.

Jason Gross ’13 Become a L

A

T EX Guru

slide-11
SLIDE 11

Getting Started L

A

T EX and Math Miscellaneous Exercises Basic math typsetting

A few common math things

A more exhaustive list can be found through the lshort reference.

◮ Fractions: $\frac{1}{4}$ ( 1 4),

$\frac{1 + \frac{1}{3}}{2x + \frac{1}{5}}$ (

1+ 1

3

2x+ 1

5 )

◮ Exponents and subscripts:

$x_1^2 + x_2^2 + \cdots + x_{11}^2$ (x2

1 + x2 2 + · · · + x2 11), $(3x + 7)^{100}$ ((3x + 7)100) ◮ Trig functions: $\cos(\sin x)$ (cos(sin x)) ◮ Summations: $\sum_{i = 0}^5 (ar^n)$ (5 i=0(arn)) ◮ Integrals: $\int_0^{\pi/2}e^x \ln x\,dx$

( π/2 ex ln x dx)

◮ Square roots and nth roots: $\sqrt{x^2 + 1}$ (

√ x2 + 1), $\sqrt[3]{8} = 2$ (

3

√ 8 = 2)

◮ Greek letters: $\pi$ (π), $\Omega$ (Ω), $\omega$ (ω)

Jason Gross ’13 Become a L

A

T EX Guru

slide-12
SLIDE 12

Getting Started L

A

T EX and Math Miscellaneous Exercises Basic math typsetting

Feel free to start on the exercises if you want, but it may be in your best interests to keep listening for a while.

Jason Gross ’13 Become a L

A

T EX Guru

slide-13
SLIDE 13

Getting Started L

A

T EX and Math Miscellaneous Exercises Basic math typsetting

A few not so common math things

◮ Spaces in math mode are tricky. Here are some ways to fix up

spaces: Symbol Code Example \! x \! y xy \, x \, y x y \: x \: y x y \; x \; y x y \ x \ y x y \quad x \quad y x y \qquad x \qquad y x y

◮ How to box an answer (only in text mode):

\framebox[width][position (l, c, r)]{text} For example, Einstein said, E = mc2 !

Jason Gross ’13 Become a L

A

T EX Guru

slide-14
SLIDE 14

Getting Started L

A

T EX and Math Miscellaneous Exercises Things to watch out for Other environments

Just a few reminders/cautions:

◮ L AT

EX is case-sensitive (for the most part), so if you are getting strange compiler errors, check your capitalization.

◮ Some characters are only available in math mode (e.g. <, >) ◮ Special characters that L AT

EX will get angry about: #, $, %, ^, &, _, {, }, ~, \. To typeset these, use this instead: \#, \$, \%, \^{}, \&, \_, \{, \}, \~{}, \textbackslash

Jason Gross ’13 Become a L

A

T EX Guru

slide-15
SLIDE 15

Getting Started L

A

T EX and Math Miscellaneous Exercises Things to watch out for Other environments

The list environment

◮ Lists: Here are two examples of lists and their output:

\begin{itemize} \item Math \item Chemistry \item Physics \end{itemize}

◮ Math ◮ Chemistry ◮ Physics Jason Gross ’13 Become a L

A

T EX Guru

slide-16
SLIDE 16

Getting Started L

A

T EX and Math Miscellaneous Exercises Things to watch out for Other environments

Another list environment

\begin{enumerate} \item Math \item Chemistry \item Physics \end{enumerate}

  • 1. Math
  • 2. Chemistry
  • 3. Physics

Jason Gross ’13 Become a L

A

T EX Guru

slide-17
SLIDE 17

Getting Started L

A

T EX and Math Miscellaneous Exercises Things to watch out for Other environments

The tabular environment

◮ Tables:

\begin{tabular}{l|cc} Number & Numeral & Roman \\ \hline Five & $5$ & $V$\\ Ten & $10$ & $X$\\ \end{tabular} Number Numeral Roman Five 5 V Ten 10 X

Jason Gross ’13 Become a L

A

T EX Guru

slide-18
SLIDE 18

Getting Started L

A

T EX and Math Miscellaneous Exercises Things to watch out for Other environments

Aligned equations

◮ Aligned equations:

\begin{align} f(x) &= 9y^2 - 6y \nonumber \\ &= (9y^2 - 6y + 1) - 1 \nonumber \\ &= (3y - 1)^2 - 1 \end{align} f (x) = 9y 2 − 6y = (9y 2 − 6y + 1) − 1 = (3y − 1)2 − 1 (1)

Jason Gross ’13 Become a L

A

T EX Guru

slide-19
SLIDE 19

Getting Started L

A

T EX and Math Miscellaneous Exercises Things to watch out for Other environments

The section command

◮ Sections:

\section{Scientists} \subsection{Euler} He knew everything. \subsection{Newton} He knew gravity. \section{MIT Students} \subsection*{Class of 2013} \subsubsection*{Jason} He knows \LaTeX. \subsubsection*{Michele} She likes to teach. 1 Scientists

1.1 Euler

He knew everything.

1.2 Newton

He knew gravity.

2 MIT Students

Class of 2013

Jason

He knows L

A

T EX.

Michele

She likes to teach.

Jason Gross ’13 Become a L

A

T EX Guru

slide-20
SLIDE 20

Getting Started L

A

T EX and Math Miscellaneous Exercises

Exercises

See handout. You should save whatever file you use as yourname.tex, where yourname is your name.

Jason Gross ’13 Become a L

A

T EX Guru