Facebook
From Subtle Macaque, 3 Months ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 67
  1. documentclass[20pt,a4paper]{extarticle}
  2. usepackage[a4paper,margin=6mm]{geometry}
  3. usepackage{amsmath}
  4. usepackage{hyperref}
  5.  
  6. title{LaTeX Mathematics Examples}
  7. author{Prof Tony Roberts}
  8.  
  9. begin{document}
  10.  
  11. maketitle
  12.  
  13. tableofcontents
  14.  
  15.  
  16.  
  17. section{Delimiters}
  18.  
  19. See how the delimiters are of reasonable size in these examples
  20. [
  21.         left(a+bright)left[1-frac{b}{a+b}right]=a,,
  22. ]
  23. [
  24.         sqrt{|xy|}leqleft|frac{x+y}{2}right|,
  25. ]
  26. even when there is no matching delimiter
  27. [
  28.         int_a^bufrac{d^2v}{dx^2},dx
  29.         =left.ufrac{dv}{dx}right|_a^b
  30.         -int_a^bfrac{du}{dx}frac{dv}{dx},dx.
  31. ]
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38. section{Spacing}
  39.  
  40. Differentials often need a bit of help with their spacing as in
  41. [
  42.         iint xy^2,dx,dy
  43.         =frac{1}{6}x^2y^3,
  44. ]
  45. whereas vector problems often lead to statements such as
  46. [
  47.         u=frac{-y}{x^2+y^2},,quad
  48.         v=frac{x}{x^2+y^2},,quadtext{and}quad
  49.         w=0,.
  50. ]
  51. Occasionally one gets horrible line breaks when using a list in mathematics such as listing the first twelve primes  (2,3,5,7,11,13,17,19,23,29,31,37),.
  52. In such cases, perhaps include verb|mathcode`,="213B| inside the inline maths environment so that the list breaks: (mathcode`,="213B 2,3,5,7,11,13,17,19,23,29,31,37),.
  53. Be discerning about when to do this as the spacing is different.
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60. section{Arrays}
  61.  
  62. Arrays of mathematics are typeset using one of the matrix environments as
  63. in
  64. [
  65.         begin{bmatrix}
  66.                 1 & x & 0 \
  67.                 0 & 1 & -1
  68.         end{bmatrix}begin{bmatrix}
  69.                 1  \
  70.                 y  \
  71.                 1
  72.         end{bmatrix}
  73.         =begin{bmatrix}
  74.                 1+xy  \
  75.                 y-1
  76.         end{bmatrix}.
  77. ]
  78. Case statements use cases:
  79. [
  80.         |x|=begin{cases}
  81.                 x, & text{if }xgeq 0,,  \
  82.                 -x, & text{if }x< 0,.
  83.         end{cases}
  84. ]
  85. Many arrays have lots of dots all over the place as in
  86. [
  87.         begin{matrix}
  88.                 -2 & 1 & 0 & 0 & cdots & 0  \
  89.                 1 & -2 & 1 & 0 & cdots & 0  \
  90.                 0 & 1 & -2 & 1 & cdots & 0  \
  91.                 0 & 0 & 1 & -2 & ddots & vdots \
  92.                 vdots & vdots & vdots & ddots & ddots & 1  \
  93.                 0 & 0 & 0 & cdots & 1 & -2
  94.         end{matrix}
  95. ]
  96.  
  97.  
  98.  
  99.  
  100.  
  101.  
  102. section{Equation arrays}
  103.  
  104. In the flow of a fluid film we may report
  105. begin{eqnarray}
  106.         u_alpha & = & epsilon^2 kappa_{xxx}
  107.         left( y-frac{1}{2}y^2 right),
  108.         label{equ}  \
  109.         v & = & epsilon^3 kappa_{xxx} y,,
  110.         label{eqv}  \
  111.         p & = & epsilon kappa_{xx},.
  112.         label{eqp}
  113. end{eqnarray}
  114. Alternatively, the curl of a vector field $(u,v,w)$ may be written
  115. with only one equation number:
  116. begin{eqnarray}
  117.         omega_1 & = &
  118.         frac{partial w}{partial y}-frac{partial v}{partial z},,
  119.         nonumber  \
  120.         omega_2 & = &
  121.         frac{partial u}{partial z}-frac{partial w}{partial x},,
  122.         label{eqcurl}  \
  123.         omega_3 & = &
  124.         frac{partial v}{partial x}-frac{partial u}{partial y},.
  125.         nonumber
  126. end{eqnarray}
  127. Whereas a derivation may look like
  128. begin{eqnarray*}
  129.         (pwedge q)vee(pwedgeneg q) & = & pwedge(qveeneg q)
  130.         quadtext{by distributive law}  \
  131.          & = & pwedge T quadtext{by excluded middle}  \
  132.          & = & p quadtext{by identity}
  133. end{eqnarray*}
  134.  
  135.  
  136.  
  137.  
  138.  
  139.  
  140. section{Functions}
  141.  
  142. Observe that trigonometric and other elementary functions are typeset
  143. properly, even to the extent of providing a thin space if followed by
  144. a single letter argument:
  145. [
  146.         exp(itheta)=costheta +isintheta,,quad
  147.         sinh(log x)=frac{1}{2}left( x-frac{1}{x} right).
  148. ]
  149. With sub- and super-scripts placed properly on more complicated
  150. functions,
  151. [
  152.         lim_{qtoinfty}|f(x)|_q
  153.         =max_{x}|f(x)|,
  154. ]
  155. and large operators, such as integrals and
  156. begin{eqnarray*}
  157.         e^x & = & sum_{n=0}^infty frac{x^n}{n!}
  158.         quadtext{where }n!=prod_{i=1}^n i,,  \
  159.         overline{U_alpha} & = & bigcap_alpha U_alpha,.
  160. end{eqnarray*}
  161. In inline mathematics the scripts are correctly placed to the side in
  162. order to conserve vertical space, as in
  163. (
  164.         1/(1-x)=sum_{n=0}^infty x^n.
  165. )
  166.  
  167.  
  168.  
  169.  
  170.  
  171.  
  172. section{Accents}
  173.  
  174. Mathematical accents are performed by a short command with one
  175. argument, such as
  176. [
  177.         tilde f(omega)=frac{1}{2pi}
  178.         int_{-infty}^infty f(x)e^{-iomega x},dx,,
  179. ]
  180. or
  181. [
  182.         dot{vec omega}=vec rtimesvec I,.
  183. ]
  184.  
  185.  
  186.  
  187.  
  188.  
  189. section{Command definition}
  190.  
  191. newcommand{Ai}{operatorname{Ai}}
  192. The Airy function, $Ai(x)$, may be incorrectly defined as this
  193. integral
  194. [
  195.         Ai(x)=intexp(s^3+isx),ds,.
  196. ]
  197.  
  198. newcommand{D}[2]{frac{partial #2}{partial #1}}
  199. newcommand{DD}[2]{frac{partial^2 #2}{partial #1^2}}
  200. renewcommand{vec}[1]{boldsymbol{#1}}
  201.  
  202. This vector identity serves nicely to illustrate two of the new
  203. commands:
  204. [
  205.         vecnablatimesvec q
  206.         =vec ileft(D yw-D zvright)
  207.         +vec jleft(D zu-D xwright)
  208.         +vec kleft(D xv-D yuright).
  209. ]
  210.  
  211. Recall that typesetting multi-line mathematics is an art normally too hard for computer recipes.  Nonetheless, if you need to be automatically flexible about multi-line mathematics, and you do not mind some rough typesetting, then perhaps invoke verb|parbox| to help as follows:
  212. % The verb|breqn| package is not yet reliable enough for general use.
  213. newcommand{parmath}[2][0.8linewidth]{parbox[t]{#1}%
  214.     {raggedrightlinespread{1.2}selectfont(#2)}}
  215. [
  216. u_1=parmath{ -2 gamma  epsilon^{2} s_{2}+mu  epsilon^{3} big( frac{3}{8} s_{2}+frac{1}{8} s_{1} ibig)+epsilon^{3} big( -frac{81}{32} s_{4} s_{2}^{2}-frac{27}{16} s_{4} s_{2} s_{1} i+frac{9}{32} s_{4} s_{1}^{2}+frac{27}{32} s_{3} s_{2}^{2} i-frac{9}{16} s_{3} s_{2} s_{1}-frac{3}{32} s_{3} s_{1}^{2} ibig) +int_a^b 1-2x+3x^2-4x^3,dx }
  217. ]
  218. Also, sometimes use verb|parbox| to typeset multiline entries in tables.
  219.  
  220.  
  221. section{Theorems et al.}
  222.  
  223. newtheorem{theorem}{Theorem}
  224. newtheorem{corollary}[theorem]{Corollary}
  225. newtheorem{lemma}[theorem]{Lemma}
  226. newtheorem{definition}[theorem]{Definition}
  227.  
  228. begin{definition}[right-angled triangles] label{def:tri}
  229. A emph{right-angled triangle} is a triangle whose sides of length~(a), (b) and~(c), in some permutation of order, satisfies (a^2+b^2=c^2).
  230. end{definition}
  231.  
  232. begin{lemma}
  233. The triangle with sides of length~(3), (4) and~(5) is right-angled.
  234. end{lemma}
  235.  
  236. This lemma follows from the Definition~ref{def:tri} as (3^2+4^2=9+16=25=5^2).
  237.  
  238. begin{theorem}[Pythagorean triplets] label{thm:py}
  239. Triangles with sides of length (a=p^2-q^2), (b=2pq) and (c=p^2+q^2) are right-angled triangles.
  240. end{theorem}
  241.  
  242. Prove this Theorem~ref{thm:py} by the algebra (a^2+b^2 =(p^2-q^2)^2+(2pq)^2
  243. =p^4-2p^2q^2+q^4+4p^2q^2
  244. =p^4+2p^2q^2+q^4
  245. =(p^2+q^2)^2 =c^2).
  246.  
  247.  
  248. end{document}