
My first LATEX document Timothy Gummer August 12, 2019 Contents Unnumbered section 3 1 Basic document structure3 1.1 Spacing.............................................3 1.2 Lists...............................................3 1.3 Font Styling...........................................4 1.4 Tabular environments......................................4 2 `Math' Mode 5 2.1 Basic syntax...........................................5 2.2 Common symbols........................................6 2.3 Brackets.............................................6 2.4 Big operators..........................................6 2.5 The American Mathematical Society Packages........................7 2.5.1 Symbols from amssymb .................................7 2.5.2 An example: linear systems of equations.......................7 2.5.3 The commath package..................................8 2.5.4 More on align environments..............................9 2.5.5 Another example: probability distributions......................9 2.6 Theorems and proofs......................................9 2.7 Life-like mathematics...................................... 10 3 User-defined commands/macros 11 4 Colours 11 5 Links and references 11 6 Graphics 11 7 Floats 12 8 Verb and Listings 14 8.1 Verbatim............................................. 14 8.2 Listings............................................. 14 9 Actuarial Notation 15 1 10 References 15 2 Unnumbered section Sections that use the suffix variant (unnumbered) of the section command are not included in the table of contents by default. 1 Basic document structure 1.1 Spacing This is my first LATEX document. In this document, I will be learning all the basics of LATEX. Leave a line of code empty for a new paragraph. Use double backslash for a line break. A line break combined with a new paragraph makes a larger space between the paragraphs. This text appears 3 centimetres below the previous. Some text. This text appears 5 centimetres to the right of the previous. Spaces in the input file do not always correspond to spaces in the output file, they are sometimes used to end commands instead so be careful (e.g. with LATEX). 1.2 Lists The enumerate and itemize environments are for lists of things. • Apple { Pink lady { Fuji • Orange • Banana 1. First (a) Next 2. Second 3. Third 3 1.3 Font Styling There are several ways in which one might emphasise particular groupings of text: bold font, italic font, underlined font, typewriter font, Small Caps, tiny font, small font, large font, huge font. The emph command will emphasise a word by toggling italics. i.e.: The sixth word of this sentence is emphasised. The final word of this sentence is emphasised. There are a few semantics about quotation marks and inverted commas one ought to know. Incorrect: "quote", or 'quote'. Correct: \quote", or `quote' (need to use back ticks on the left) Typewriter font is typically used by convention for the names of packages and functions (sometimes in languages other than LATEX). e.g. \magrittr is a useful R package which contains pipe operators". It is also often used for URLs. Some symbols will not display automatically as they should as they have other uses and need to be `backslashed'. e.g. f & $ % Indeed, backslash itself is displayed using the command textbackslash, n. 1.4 Tabular environments left centre right Text with automatic line break- ing text text text text 4 2 `Math' Mode 2.1 Basic syntax Wrap an expression in $ symbols to enter math mode. Use two $ symbols (i.e. $$) to indicate display math mode. One can alternatively use n(n) for normal maths mode and n[n] for display maths mode (clearer start and end). y = mx + c 5 ∗ 2 = 70=7 = 10 Use the caret symbol (^) for right supercripts: a2 + b2 = c2. Use the underscore symbol for right subscripts: x1. You need to use curly brackets to include more than on symbol in a subscript or supercript (par- ticularly double super- and subscripts as they provide enough ambiguity to cause an error): e2x, e2x, e−x2 46 Left subscripts and superscripts require a few empty curly brackets: x 10A. Greek letters: α; β; γ; θ; δ Some Greek letters have a variant: φ, ' Some Greek letters are rather difficult to write by hand: ξ; ζ For Greek capital letters just capitalise the commands: Γ; Λ; ∆ Fractions: 1 2 1 Appear smaller in normal maths mode: 3 1 Man make bigger with the displaystyle command 2 Mathematical operators should be distinguished from variables by unitalicising them: max f(x), exp x and log x. Use the mathrm or operatorname commands to do this on operators that don't have predefined commands for their names. To display text inside math mode use the text command. e.g. eiθ = cos θ + i sin θ : : : (known as Euler's formula) 5 2.2 Common symbols Inequality symbols: >, <, ≥, ≤ p p Radicals: 2, 3 2 Y Integration and summation operators: R , RR , H and P, (these get bigger when you make them into display maths mode) Arrows: ! (also use to), , $, ), (, ,, also long arrows: −, () Set theory and logic: 8, 9, [, \, _, ^, ; := fg also S etc. Equivalence relations: ≡, ≈, ∼, 6= . Dots: ·, ··· , ::: , .,. .. Maths bold (e.g. for vectors): x, X, b Accented symbols: θ^, X¯, X,a ¨ Others: 1, @, ±, `, > (i.e. for matrix transpose), j (i.e. \given" in for condition probability etc.) 2.3 Brackets (, [ and j are all available in maths mode as is. To produce f, h, i k, you need to use commands. [0; 1) Use left and right to make brackets match the height of their contents. 1 1 ( ); 2 2 If you only need brackets on one side, use a fullstop symbol with the left or right command (\."). 1 3 1 2 2.4 Big operators To make things appear above or below defined operators use the limits command. e.g.: 1 n lim 1 + = e n!1 n 6 1 X 1 rn = 1 − r n=0 This works for R , S etc. as well Use the stackrel command if you just want to stack two symbols. e.g.: =? 2.5 The American Mathematical Society Packages We will learn some of the features of the American Mathematical Society Packages (AMS) packages by virtue of an example. Set of linear equations. 2.5.1 Symbols from amssymb Q.E.D./ proof conclusion: , . Set theory: ? = fg (a better-looking empty set) Mathematical shorthand: ), * Blackboard bold letters (mathbb): R, Z, C Calligraphic letter (mathcal): L, A, B 2.5.2 An example: linear systems of equations Align: x1 + x2 + x3 = 6 (1) 5x1 + 2x2 − 4x3 = −3 (2) 3x1 − x2 + 5x3 = 16 (3) a repeat of this to show some other features x1 + x2 + x3 = 6 (4) 5x1 + 2x2 − 4x3 = −3 (a) 3x1 − x2 + 5x3 = 16 x1+ x2+ x3 = 6 5x1+2x2−4x3 = −3 3x1− x2+5x3 = 16 Cases: We might also like to present these equations as 8 >x + x + x = 6 <> 1 2 3 5x1 + 2x2 − 4x3 = −3 > :>3x1 − x2 + 5x3 = 16 7 Some might also choose to use matrices instead, 8 <> x1 + x2 + x3 = 6 5x1 + 2x2 − 4x3 = −3 :> 3x1 − x2 + 5x3 = 16 however the alignment here is not quite right. Matrices We can rewrite this in the form Ax = b 2 3 2 3 2 3 1 1 1 x1 6 65 2 −47 6x 7 6−37 4 5 4 25 = 4 5 3 −1 5 x3 16 We can then write it as an augmented matrix for Gaussian elimination: 0 1 1 1 1 6 B C B5 2 −4 −3C @ A 3 −1 5 16 This will yield the solution: 2 3 x1 6x 7 x = 4 25 x3 2 3 1 627 = 4 5 3 8 >x = 1 <> 1 i.e. x2 = 2 or in another way x1 = 1; x2 = 2; x3 = 3 > :>x3 = 3 2.5.3 The commath package This package has a number of predefined commands that make certain commonly use mathematical things much easier and more consistent. For example: • The norm command: kxk Z 1 • The dif command: ex dx (unitalicises the d and places a small amount of space between the 0 integrand and the differential). dy • The od command: dx @y • The pd command: @x All of these are rather cumbersome to produce otherwise. 8 2.5.4 More on align environments `align' environments can be uses to create alignments between particular elements of an array of math- ematical expressions. They are commonly used to align equals signs. " #1 Z 1 x3 x2 dx = 0 3 0 1 = − 0 3 1 = 3 You need some extra & symbols to have multiple vertical alignments at once. (Put extra &'s between each object). x1 = 1 x2 = 2 x3 = 3 x4 = 4 x5 = 5 x6 = 6 Environments related to the align environment: eqnarray and equation are redundant environments because everything they do, can be done (bet- ter) by the align environment. Although, equation does have some use if used in combination with the aligned environment discussed below. There are also the aligned environment which allow for an align-like environment within regular maths mode and alignat environment which allows for more control when you wish to have multiple vertical alignments (using multiple & symbols when the above doesn't work). 2.5.5 Another example: probability distributions We missed an important use of the cases environment above. Let X ∼ exp(λ), then it's probability density function is: ( λe−λx; if x ≥ 0 fX (x) = 0; otherwise 2.6 Theorems and proofs Theorem 2.1 (theorem name). Statement of the theorem A ) B. Proof. Proof goes here. Theorem 2.2 (another theorem). Statement of the theorem C () D. Proof. Use the qedhere command to make the Q.E.D. symbol appear in next to the last line correctly if the last line is an equation. D =) C 9 2.7 Life-like mathematics The the package cancel is useful for \cancelling out" fractions etc.. One might combine this with the ams commands for under and over braces to make LATEX expression appear closer to being handwritten.
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages15 Page
-
File Size-