LATEX, beamer tikz und Co.thw/vl-latex-co/k-05-math-folien.pdfI Dokumenation: amsldoc.pdf I TEXLive:...

51
L A T E X, beamer, tikz und Co. L A T E X, beamer, tikz und Co. 5. Mathematischer Formelsatz Thomas Worsch Fakultät für Informatik Karlsruher Institut für Technologie Wintersemester 2017/2018 1 / 51

Transcript of LATEX, beamer tikz und Co.thw/vl-latex-co/k-05-math-folien.pdfI Dokumenation: amsldoc.pdf I TEXLive:...

Page 1: LATEX, beamer tikz und Co.thw/vl-latex-co/k-05-math-folien.pdfI Dokumenation: amsldoc.pdf I TEXLive: texdoc amsmath oder texdoc amsldoc I \usepackage{mathtools} I Dokumentation: mathtools.pdf

LATEX, beamer, tikz und Co.

LATEX, beamer, tikz und Co.5. Mathematischer Formelsatz

Thomas Worsch

Fakultät für InformatikKarlsruher Institut für Technologie

Wintersemester 2017/2018

1 / 51

Page 2: LATEX, beamer tikz und Co.thw/vl-latex-co/k-05-math-folien.pdfI Dokumenation: amsldoc.pdf I TEXLive: texdoc amsmath oder texdoc amsldoc I \usepackage{mathtools} I Dokumentation: mathtools.pdf

Mathematischer Formelsatz

Formeln

Überblick

Formeln

Normaler Text in Formeln

Klammern

Matrizen

Umgebungen für Gleichungen

Umgebungen für Formelbausteine

Typografisches Finetuning2 / 51

Page 3: LATEX, beamer tikz und Co.thw/vl-latex-co/k-05-math-folien.pdfI Dokumenation: amsldoc.pdf I TEXLive: texdoc amsmath oder texdoc amsldoc I \usepackage{mathtools} I Dokumentation: mathtools.pdf

Mathematischer Formelsatz

Formeln

Zwei Sorten von Formeln (1)

I inline: Formeln im laufenden TextI für eher kurze FormelnI $ 〈Formel〉 $I \( 〈Formel〉 \)

I displayed: freigestellte FormelnI für eher lange Formeln, Gleichungssysteme, etc.I \[ 〈Formel〉 \]I \begin{displaymath}〈Formeln〉

\end{displaymath}I (die dri�e Möglichkeit verrate ich nicht)

3 / 51

Page 4: LATEX, beamer tikz und Co.thw/vl-latex-co/k-05-math-folien.pdfI Dokumenation: amsldoc.pdf I TEXLive: texdoc amsmath oder texdoc amsldoc I \usepackage{mathtools} I Dokumentation: mathtools.pdf

Mathematischer Formelsatz

Formeln

Zwei Sorten von Formeln (2)UnterschiedeI Größe von SymbolenI Position von Summationsgrenzen, . . .I inline:

$\sum_{i=0}^n i = \frac{n(n+1)}{2}$∑ni=0 i =

n(n+1)2

I displayed:

\[ \sum_{i=0}^n i = \frac{n(n+1)}{2} \]

n∑i=0

i =n(n + 1)

2

4 / 51

Page 5: LATEX, beamer tikz und Co.thw/vl-latex-co/k-05-math-folien.pdfI Dokumenation: amsldoc.pdf I TEXLive: texdoc amsmath oder texdoc amsldoc I \usepackage{mathtools} I Dokumentation: mathtools.pdf

Mathematischer Formelsatz

Formeln

Unbekannte

I Leerzeichen in Formeln irrelevant:

$ a b = b a $ ab = ba

$ab=ba$ ab = ba

I „Variablennamen“ sind nicht so einfach

$Var(X)$ ist $falsch$ Var (X ) ist f alsch

$\mathit{Var nix falsch}$ Varnixfalsch

I Funktionsnamen, Operatoren, Relationssymbole: demnächst

5 / 51

Page 6: LATEX, beamer tikz und Co.thw/vl-latex-co/k-05-math-folien.pdfI Dokumenation: amsldoc.pdf I TEXLive: texdoc amsmath oder texdoc amsldoc I \usepackage{mathtools} I Dokumentation: mathtools.pdf

Mathematischer Formelsatz

Formeln

Exponenten und Indizes

I Exponenten: ^{〈exponent〉}I bei „ganz kleinen“ Exponenten können die {} fehlenI Achtung: $x^12$ liefert x12I im Zweifelsfall immer mit Klammern

I Indizes: _{〈index〉}I bei „ganz kleinen“ Indizes können die {} fehlenI Achtung: $x_12$ liefert x12I im Zweifelsfall immer mit Klammern

6 / 51

Page 7: LATEX, beamer tikz und Co.thw/vl-latex-co/k-05-math-folien.pdfI Dokumenation: amsldoc.pdf I TEXLive: texdoc amsmath oder texdoc amsldoc I \usepackage{mathtools} I Dokumentation: mathtools.pdf

Mathematischer Formelsatz

Formeln

Wichtige Pakete und Dokumentation

I \usepackage{amsmath}I Dokumenation: amsldoc.pdf

I TEXLive: texdoc amsmath oder texdoc amsldoc

I \usepackage{mathtools}I Dokumentation: mathtools.pdf

I TEXLive: texdoc mathtoolsI lädt amsmath und korrigiert zwei FehlerI weitere Umgebungen für Gleichungen und Gl.-SystemeI weitere Umgebungen für MatrizenI typografisches Finetuning mathematischer Formeln

I siehe auch https://www.tug.org/~hvoss/

7 / 51

Page 8: LATEX, beamer tikz und Co.thw/vl-latex-co/k-05-math-folien.pdfI Dokumenation: amsldoc.pdf I TEXLive: texdoc amsmath oder texdoc amsldoc I \usepackage{mathtools} I Dokumentation: mathtools.pdf

Mathematischer Formelsatz

Normaler Text in Formeln

Überblick

Formeln

Normaler Text in Formeln

Klammern

Matrizen

Umgebungen für Gleichungen

Umgebungen für Formelbausteine

Typografisches Finetuning8 / 51

Page 9: LATEX, beamer tikz und Co.thw/vl-latex-co/k-05-math-folien.pdfI Dokumenation: amsldoc.pdf I TEXLive: texdoc amsmath oder texdoc amsldoc I \usepackage{mathtools} I Dokumentation: mathtools.pdf

Mathematischer Formelsatz

Normaler Text in Formeln

Normaler Text in Formeln

I \usepackage{amsmath}I \text{〈text〉}

Beispiel:

$b^2 falls b prim $ \\$b^2 \text{falls} b \text{prim} $ \\$b^2 \text{ falls } b \text{ prim}$

b2 f allsbprimb2fallsbprimb2 falls b prim

9 / 51

Page 10: LATEX, beamer tikz und Co.thw/vl-latex-co/k-05-math-folien.pdfI Dokumenation: amsldoc.pdf I TEXLive: texdoc amsmath oder texdoc amsldoc I \usepackage{mathtools} I Dokumentation: mathtools.pdf

Mathematischer Formelsatz

Normaler Text in Formeln

Normaler Text in Formeln (2)\text{〈text〉}I tut auch in Exponenten und Indizes „das Richtige“:

$b^{2\cdot \text{Größe von $X$}}$

b2·Größe von X

I funktioniert auch außerhalb von Formeln

Die \text{Größe von $X$} ist unbekannt.

Die Größe von X ist unbekannt.

I aber dann kein Zeilenumbruch innerhalb von 〈text〉

10 / 51

Page 11: LATEX, beamer tikz und Co.thw/vl-latex-co/k-05-math-folien.pdfI Dokumenation: amsldoc.pdf I TEXLive: texdoc amsmath oder texdoc amsldoc I \usepackage{mathtools} I Dokumentation: mathtools.pdf

Mathematischer Formelsatz

Klammern

Überblick

Formeln

Normaler Text in Formeln

Klammern

Matrizen

Umgebungen für Gleichungen

Umgebungen für Formelbausteine

Typografisches Finetuning11 / 51

Page 12: LATEX, beamer tikz und Co.thw/vl-latex-co/k-05-math-folien.pdfI Dokumenation: amsldoc.pdf I TEXLive: texdoc amsmath oder texdoc amsldoc I \usepackage{mathtools} I Dokumentation: mathtools.pdf

Mathematischer Formelsatz

Klammern

Klammern: mehrere Arten

vier „übliche“ Klammerarten:parentheses $(x+y)$ ergibt (x + y)brackets $[x+y]$ ergibt [x + y]braces $\{x+y\}$ ergibt {x + y}angles $\langle x+y\rangle$ ergibt 〈x + y〉

zwei „unübliche“ „Klammer“arten:$\lvert x+y\rvert$ ergibt |x + y |$\lVert x+y\rVert$ ergibt ‖x + y‖

12 / 51

Page 13: LATEX, beamer tikz und Co.thw/vl-latex-co/k-05-math-folien.pdfI Dokumenation: amsldoc.pdf I TEXLive: texdoc amsmath oder texdoc amsldoc I \usepackage{mathtools} I Dokumentation: mathtools.pdf

Mathematischer Formelsatz

Klammern

Wachsende Klammern (1)

I Klammern können mit dem Eingeklammerten mitwachsenI ohne automatisches Mitwachsen der Klammern:$(x+(y+z)^{n^2})^2$ ergibt (x + (y + z)n

2)2

I MitwachsenI schreibe vor die linke Klammer \leftI schreibe vor die rechte Klammer \right

I mit Mitwachsen:$\left(x+\left(y+z\right)^{n^2}\right)^2$ ergibt(x + (y + z)n

2)2

13 / 51

Page 14: LATEX, beamer tikz und Co.thw/vl-latex-co/k-05-math-folien.pdfI Dokumenation: amsldoc.pdf I TEXLive: texdoc amsmath oder texdoc amsldoc I \usepackage{mathtools} I Dokumentation: mathtools.pdf

Mathematischer Formelsatz

Klammern

Wachsende Klammern (2)

I \left und \right müssen immer paarweise auftretenI es muss aber nicht der gleiche Klammertyp sein:

$\left( x^{y^2} \right]$ ergibt(xy

2]

I wenn man nur eine Seite braucht: für die andere die „leerePseudoklammer“ . benutzen

\[\left\{\begin{aligned} x &= y \\ a &= b+c \end{aligned}\right. \] {

x = y

a = b + c

14 / 51

Page 15: LATEX, beamer tikz und Co.thw/vl-latex-co/k-05-math-folien.pdfI Dokumenation: amsldoc.pdf I TEXLive: texdoc amsmath oder texdoc amsldoc I \usepackage{mathtools} I Dokumentation: mathtools.pdf

Mathematischer Formelsatz

Klammern

Klammern (3): explizite GrößenangabeI sta� \left und \rightI nehme man

\bigl und \bigr\Bigl und \Bigr\biggl und \biggr\Biggl und \Biggr

I Beispiele\bigl( x+y \bigr)

(x + y

)\Bigl( x+y \Bigr)

(x + y

)\biggl( x+y \biggr)

(x + y

)\Biggl( x+y \Biggr)

(x + y

)15 / 51

Page 16: LATEX, beamer tikz und Co.thw/vl-latex-co/k-05-math-folien.pdfI Dokumenation: amsldoc.pdf I TEXLive: texdoc amsmath oder texdoc amsldoc I \usepackage{mathtools} I Dokumentation: mathtools.pdf

Mathematischer Formelsatz

Klammern

Klammern (4): horizontalI amsmath:

I \underbrace{〈Hauptformel〉}_{〈Subformel〉}I analog \overbrace

I in mathtools auch noch \underbracket, \overbracket

\[\frac{1}{1}\underbrace{-\frac{1}{2} + \frac{1}{2}-\frac{1}{3}+ \frac{1}{3}

}_{\text{Teleskopsumme}}-\frac{1}{4}\]

11−12+12−13+13︸ ︷︷ ︸

Teleskopsumme

−14

16 / 51

Page 17: LATEX, beamer tikz und Co.thw/vl-latex-co/k-05-math-folien.pdfI Dokumenation: amsldoc.pdf I TEXLive: texdoc amsmath oder texdoc amsldoc I \usepackage{mathtools} I Dokumentation: mathtools.pdf

Mathematischer Formelsatz

Matrizen

Überblick

Formeln

Normaler Text in Formeln

Klammern

Matrizen

Umgebungen für Gleichungen

Umgebungen für Formelbausteine

Typografisches Finetuning17 / 51

Page 18: LATEX, beamer tikz und Co.thw/vl-latex-co/k-05-math-folien.pdfI Dokumenation: amsldoc.pdf I TEXLive: texdoc amsmath oder texdoc amsldoc I \usepackage{mathtools} I Dokumentation: mathtools.pdf

Mathematischer Formelsatz

Matrizen

Matrizen (1): amsmath

I amsmath bietet die Umgebungenpmatrix umgeben von ( und )bmatrix umgeben von [ und ]Bmatrix umgeben von { und }vmatrix umgeben von | und |Vmatrix umgeben von ‖ und ‖

undmatrix umgeben von nichts

I die Einträge in jeder Spalte jeweils zentriert untereinander

18 / 51

Page 19: LATEX, beamer tikz und Co.thw/vl-latex-co/k-05-math-folien.pdfI Dokumenation: amsldoc.pdf I TEXLive: texdoc amsmath oder texdoc amsldoc I \usepackage{mathtools} I Dokumentation: mathtools.pdf

Mathematischer Formelsatz

Matrizen

Matrizen: Beispiel

\[\begin{pmatrix}1 & 2 & x+y & -4711 \\-4711 & 1 & 2 & x+y \\0 & 0 & & \infty\end{pmatrix}\]

©­«1 2 x + y −4711−4711 1 2 x + y0 0 ∞

ª®¬19 / 51

Page 20: LATEX, beamer tikz und Co.thw/vl-latex-co/k-05-math-folien.pdfI Dokumenation: amsldoc.pdf I TEXLive: texdoc amsmath oder texdoc amsldoc I \usepackage{mathtools} I Dokumentation: mathtools.pdf

Mathematischer Formelsatz

Matrizen

Matrizen (2): mathtools

I mathtools bietet zusätzlich die Umgebungenmatrix* umgeben von nichtspmatrix* umgeben von ( und )bmatrix* umgeben von [ und ]Bmatrix* umgeben von { und }vmatrix* umgeben von | und |Vmatrix* umgeben von ‖ und ‖

I Unterschied zu amsmath:man kann die Ausrichtung der Spalten wählenI \begin{matrix*}[l] linksbündige SpaltenI \begin{matrix*}[r] rechtsbündige SpaltenI \begin{matrix*}[c] zentrierte Spalten

I das ist auch der Default, falls die Angabe fehlt

20 / 51

Page 21: LATEX, beamer tikz und Co.thw/vl-latex-co/k-05-math-folien.pdfI Dokumenation: amsldoc.pdf I TEXLive: texdoc amsmath oder texdoc amsldoc I \usepackage{mathtools} I Dokumentation: mathtools.pdf

Mathematischer Formelsatz

Matrizen

Matrizen: Beispiel

\[\begin{pmatrix*}[r]1 & 2 & x+y & -4711 \\-4711 & 1 & 2 & x+y \\0 & 0 & & \infty\end{pmatrix*}\]

©­«1 2 x + y −4711

−4711 1 2 x + y0 0 ∞

ª®¬21 / 51

Page 22: LATEX, beamer tikz und Co.thw/vl-latex-co/k-05-math-folien.pdfI Dokumenation: amsldoc.pdf I TEXLive: texdoc amsmath oder texdoc amsldoc I \usepackage{mathtools} I Dokumentation: mathtools.pdf

Mathematischer Formelsatz

Umgebungen für Gleichungen

Überblick

Formeln

Normaler Text in Formeln

Klammern

Matrizen

Umgebungen für Gleichungen

Umgebungen für Formelbausteine

Typografisches Finetuning22 / 51

Page 23: LATEX, beamer tikz und Co.thw/vl-latex-co/k-05-math-folien.pdfI Dokumenation: amsldoc.pdf I TEXLive: texdoc amsmath oder texdoc amsldoc I \usepackage{mathtools} I Dokumentation: mathtools.pdf

Mathematischer Formelsatz

Umgebungen für Gleichungen

Formeln, Gleichungen, Gleichungssysteme

I freigestellte Formeln („display math“)I wahlweise mit oder ohne automatisch vergebene Nummer für die

Formeln, zum BeispielI {equation}: mit NummerI {equation*}: ohne Nummer (wie \[ \] )

I einfachster Fall

\begin{equation}e^{i\pi} = -1

\end{equation}

eiπ = −1 (1)

23 / 51

Page 24: LATEX, beamer tikz und Co.thw/vl-latex-co/k-05-math-folien.pdfI Dokumenation: amsldoc.pdf I TEXLive: texdoc amsmath oder texdoc amsldoc I \usepackage{mathtools} I Dokumentation: mathtools.pdf

Mathematischer Formelsatz

Umgebungen für Gleichungen

Umgebung equation: Beispielemit automatischer Nummerierung:

\begin{equation}e^{i\pi} = -1

\end{equation}

eiπ = −1 (2)

ohne automatische Nummerierung:

\begin{equation*}e^{i\pi} = -1

\end{equation*}

eiπ = −124 / 51

Page 25: LATEX, beamer tikz und Co.thw/vl-latex-co/k-05-math-folien.pdfI Dokumenation: amsldoc.pdf I TEXLive: texdoc amsmath oder texdoc amsldoc I \usepackage{mathtools} I Dokumentation: mathtools.pdf

Mathematischer Formelsatz

Umgebungen für Gleichungen

Umgebung multline: für laaaaaaaaange Formeln

I die multline Umgebung istI für eine Formel gedacht,I die in mehrere Teile für jeweils eine Zeile zerlegt istI Trennung der Teile durch \\

I Achtung: nach der letzten Zeile kein \\ mehr

I deswegen gibt es auch nur eine FormelnummerI bei multline* keine Formelnummer

I gesetzt wird dieI die erste Zeile linksbündigI die letzte Zeile rechtsbündigI alle Zeilen dazwischen zentriert

25 / 51

Page 26: LATEX, beamer tikz und Co.thw/vl-latex-co/k-05-math-folien.pdfI Dokumenation: amsldoc.pdf I TEXLive: texdoc amsmath oder texdoc amsldoc I \usepackage{mathtools} I Dokumentation: mathtools.pdf

Mathematischer Formelsatz

Umgebungen für Gleichungen

Umgebung multline: Beispiel

\begin{multline}a^2+b^2+c^2+d^2+e^2+f^2+g^2 \\+a^2+b^2+c^2+d^2+e^2+f^2+g^2 \\+a^2+b^2+c^2+d^2+e^2+f^2+g^2 \\=3a^2+3b^2+3c^2+3d^2+3e^2+3f^2+3g^2

\end{multline}

a2 + b2 + c2 + d2 + e2 + f 2 + д2

+ a2 + b2 + c2 + d2 + e2 + f 2 + д2

+ a2 + b2 + c2 + d2 + e2 + f 2 + д2

= 3a2 + 3b2 + 3c2 + 3d2 + 3e2 + 3f 2 + 3д2 (3)

26 / 51

Page 27: LATEX, beamer tikz und Co.thw/vl-latex-co/k-05-math-folien.pdfI Dokumenation: amsldoc.pdf I TEXLive: texdoc amsmath oder texdoc amsldoc I \usepackage{mathtools} I Dokumentation: mathtools.pdf

Mathematischer Formelsatz

Umgebungen für Gleichungen

Umgebung gather

I die gather Umgebung istI für mehrere Formeln gedacht,I die in jeweils einer Zeile stehenI Trennung der Formeln durch \\

I Achtung: nach der letzten Zeile kein \\ mehr

I für jede Zeile gibt es eine eigene FormelnummerI bei gather* keine Formelnummern

I gesetzt werden alle Zeilen zentriert

27 / 51

Page 28: LATEX, beamer tikz und Co.thw/vl-latex-co/k-05-math-folien.pdfI Dokumenation: amsldoc.pdf I TEXLive: texdoc amsmath oder texdoc amsldoc I \usepackage{mathtools} I Dokumentation: mathtools.pdf

Mathematischer Formelsatz

Umgebungen für Gleichungen

Umgebung gather: Beispiel

\begin{gather}a^2 + b^2 = c^2 \\(a+b)^n = \sum_{i=0}^n \binom{n}{i} a^i b^{n-i} \\

\end{gather}

a2 + b2 = c2 (4)

(a + b)n =n∑i=0

(n

i

)aibn−i (5)

(6)

Problem gesehen?28 / 51

Page 29: LATEX, beamer tikz und Co.thw/vl-latex-co/k-05-math-folien.pdfI Dokumenation: amsldoc.pdf I TEXLive: texdoc amsmath oder texdoc amsldoc I \usepackage{mathtools} I Dokumentation: mathtools.pdf

Mathematischer Formelsatz

Umgebungen für Gleichungen

Umgebung gather: Beispiel

\begin{gather}a^2 + b^2 = c^2 \\(a+b)^n = \sum_{i=0}^n \binom{n}{i} a^i b^{n-i}

\end{gather}

a2 + b2 = c2 (7)

(a + b)n =n∑i=0

(n

i

)aibn−i (8)

Problem beseitigt

29 / 51

Page 30: LATEX, beamer tikz und Co.thw/vl-latex-co/k-05-math-folien.pdfI Dokumenation: amsldoc.pdf I TEXLive: texdoc amsmath oder texdoc amsldoc I \usepackage{mathtools} I Dokumentation: mathtools.pdf

Mathematischer Formelsatz

Umgebungen für Gleichungen

Mehrere Zeilen mit Ausrichtung untereinander

I Lars Madsen: Avoid eqnarray!PracTEX Journal 2006, No. 4 undPracTEX Journal 2012, No. 1http://tug.org/pracjourn/2012-1/madsen.html

I besser: align Umgebung und Verwandte

30 / 51

Page 31: LATEX, beamer tikz und Co.thw/vl-latex-co/k-05-math-folien.pdfI Dokumenation: amsldoc.pdf I TEXLive: texdoc amsmath oder texdoc amsldoc I \usepackage{mathtools} I Dokumentation: mathtools.pdf

Mathematischer Formelsatz

Umgebungen für Gleichungen

Umgebung align: Beispiel

\begin{align}x^2 + 6x + 9 &= x^2+3x + 3x+9 \\

&= x(x+3) + 3(x+3) \\&= (x+3)(x+3) \\&= (x+3)^2

\end{align}

x2 + 6x + 9 = x2 + 3x + 3x + 9 (9)

= x(x + 3) + 3(x + 3) (10)

= (x + 3)(x + 3) (11)

= (x + 3)2 (12)

31 / 51

Page 32: LATEX, beamer tikz und Co.thw/vl-latex-co/k-05-math-folien.pdfI Dokumenation: amsldoc.pdf I TEXLive: texdoc amsmath oder texdoc amsldoc I \usepackage{mathtools} I Dokumentation: mathtools.pdf

Mathematischer Formelsatz

Umgebungen für Gleichungen

Umgebung align: mehrere Zeilen mit Ausrichtung

I Ausrichtung typischerweise an Relationszeichen (=, ≤, etc.)I Markierung der auszurichtenden Stellen durch &I das & gehört vor das Relationssymbol

I Trennung der Teile für verschiedene Zeilen durch \\I nach der letzten Zeile kein \\

I für jede Zeile gibt es eine eigene FormelnummerI bei align* keine Formelnummern

32 / 51

Page 33: LATEX, beamer tikz und Co.thw/vl-latex-co/k-05-math-folien.pdfI Dokumenation: amsldoc.pdf I TEXLive: texdoc amsmath oder texdoc amsldoc I \usepackage{mathtools} I Dokumentation: mathtools.pdf

Mathematischer Formelsatz

Umgebungen für Gleichungen

Umgebung align: mehrere ausgerichtete SpaltenI & wird für zweierlei benutzt:

I Markierung der auszurichtenden StellenI Trennung der ausgerichteten Spalten

I der zu Verfügung stehende horizontale Platz wird „irgendwie“aufgeteilt

Beispiel:

\begin{align*}a+b &= c & d &= e+f\\u &= v+w & x+y &= z

\end{align*}

a + b = c d = e + f

u = v +w x + y = z33 / 51

Page 34: LATEX, beamer tikz und Co.thw/vl-latex-co/k-05-math-folien.pdfI Dokumenation: amsldoc.pdf I TEXLive: texdoc amsmath oder texdoc amsldoc I \usepackage{mathtools} I Dokumentation: mathtools.pdf

Mathematischer Formelsatz

Umgebungen für Gleichungen

Umgebung alignat: gewählte SpaltenabständeI analog der align UmgebungI aber

I Abstand zwischen Spalten mit Ausrichtung ist wählbarI Anzahl der Spalten muss angegeben werden

Beispiel:

\begin{alignat*}{3}a &= c &\hspace*{9mm} d &= e & k &= m \\u &= v & x &= y & z &= w

\end{alignat*}

a = c d = ek =m

u = v x = yz = w34 / 51

Page 35: LATEX, beamer tikz und Co.thw/vl-latex-co/k-05-math-folien.pdfI Dokumenation: amsldoc.pdf I TEXLive: texdoc amsmath oder texdoc amsldoc I \usepackage{mathtools} I Dokumentation: mathtools.pdf

Mathematischer Formelsatz

Umgebungen für Gleichungen

Umgebung alignat: typisches Beispiel

\begin{alignat*}{2}(x+1)^2 &= x^2+2x+1 &\qquad & \text{(Satz von Giuseppe Binomi)} \\

&= y^2+2y+1 & & \text{(nach Induktionsvoraussetung)} \\&= (y+1)^2

\end{alignat*}

(x + 1)2 = x2 + 2x + 1 (Satz von Giuseppe Binomi)

= y2 + 2y + 1 (nach Induktionsvoraussetung)

= (y + 1)2

35 / 51

Page 36: LATEX, beamer tikz und Co.thw/vl-latex-co/k-05-math-folien.pdfI Dokumenation: amsldoc.pdf I TEXLive: texdoc amsmath oder texdoc amsldoc I \usepackage{mathtools} I Dokumentation: mathtools.pdf

Mathematischer Formelsatz

Umgebungen für Gleichungen

Einschub: horizontale Abstände„positive“ Abstände:

\, \thinspace\: \medspace\; \thickspace

\quad\qquad\hspace{2em}

„negative“ Abstände:

\! \negthinspace\negmedspace\negthickspace

36 / 51

Page 37: LATEX, beamer tikz und Co.thw/vl-latex-co/k-05-math-folien.pdfI Dokumenation: amsldoc.pdf I TEXLive: texdoc amsmath oder texdoc amsldoc I \usepackage{mathtools} I Dokumentation: mathtools.pdf

Mathematischer Formelsatz

Umgebungen für Formelbausteine

Überblick

Formeln

Normaler Text in Formeln

Klammern

Matrizen

Umgebungen für Gleichungen

Umgebungen für Formelbausteine

Typografisches Finetuning37 / 51

Page 38: LATEX, beamer tikz und Co.thw/vl-latex-co/k-05-math-folien.pdfI Dokumenation: amsldoc.pdf I TEXLive: texdoc amsmath oder texdoc amsldoc I \usepackage{mathtools} I Dokumentation: mathtools.pdf

Mathematischer Formelsatz

Umgebungen für Formelbausteine

Bausteine für Formeln (1)

I zu gatheralignalignatmultline

gibt es gatheredalignedalignedatmultlined

I die ed-Varianten erzeugen keine freigestellten Formeln,I deswegen werden auch keine Formelnummern vergeben undI es gibt keine * Varianten

I sondern liefern Bausteine für solche,I die „natürliche“ Breite haben

I multlined stammt aus mathtools(Was ist hier die „natürliche“ Breite? Doku lesen)

38 / 51

Page 39: LATEX, beamer tikz und Co.thw/vl-latex-co/k-05-math-folien.pdfI Dokumenation: amsldoc.pdf I TEXLive: texdoc amsmath oder texdoc amsldoc I \usepackage{mathtools} I Dokumentation: mathtools.pdf

Mathematischer Formelsatz

Umgebungen für Formelbausteine

aligned: ein schlechtes Beispiel\begin{equation}f(n) = \left\{

\begin{aligned}3n+1, & \text{ falls $n$ ungerade} \\\frac{n}{2}, & \text{ falls $n$ gerade} \\

\end{aligned}\right.

\end{equation}

f (n) =

3n + 1, falls n ungerade

n

2, falls n gerade

(13)

das machen wir gleich noch besser . . .39 / 51

Page 40: LATEX, beamer tikz und Co.thw/vl-latex-co/k-05-math-folien.pdfI Dokumenation: amsldoc.pdf I TEXLive: texdoc amsmath oder texdoc amsldoc I \usepackage{mathtools} I Dokumentation: mathtools.pdf

Mathematischer Formelsatz

Umgebungen für Formelbausteine

Bausteine für Formeln (2): Fallunterscheidungen

I amsmath bietet die cases UmgebungI mathtools bietet mehr

I kommt gleich

40 / 51

Page 41: LATEX, beamer tikz und Co.thw/vl-latex-co/k-05-math-folien.pdfI Dokumenation: amsldoc.pdf I TEXLive: texdoc amsmath oder texdoc amsldoc I \usepackage{mathtools} I Dokumentation: mathtools.pdf

Mathematischer Formelsatz

Umgebungen für Formelbausteine

Die cases Umgebung für Fallunterscheidungen

\begin{equation}f(n) = \begin{cases}

3n+1, & \text{ falls $n$ ungerade} \\\frac{n}{2}, & \text{ falls $n$ gerade} \\

\end{cases}\end{equation}

f (n) =

{3n + 1, falls n ungeraden2 , falls n gerade

(14)

41 / 51

Page 42: LATEX, beamer tikz und Co.thw/vl-latex-co/k-05-math-folien.pdfI Dokumenation: amsldoc.pdf I TEXLive: texdoc amsmath oder texdoc amsldoc I \usepackage{mathtools} I Dokumentation: mathtools.pdf

Mathematischer Formelsatz

Umgebungen für Formelbausteine

Bausteine für Formeln (2): Fallunterscheidungen

I amsmath bietet die cases UmgebungI mathtools bietet mehr

I cases*: rechte Spalte automatisch im Textmode

42 / 51

Page 43: LATEX, beamer tikz und Co.thw/vl-latex-co/k-05-math-folien.pdfI Dokumenation: amsldoc.pdf I TEXLive: texdoc amsmath oder texdoc amsldoc I \usepackage{mathtools} I Dokumentation: mathtools.pdf

Mathematischer Formelsatz

Umgebungen für Formelbausteine

Bausteine für Formeln (2): Fallunterscheidungen

\begin{equation}f(n) = \begin{cases*}

3n+1, & falls $n$ ungerade \\\frac{n}{2}, & falls $n$ gerade \\

\end{cases*}\end{equation}

f (n) =

{3n + 1, falls n ungeraden2 , falls n gerade

(15)

43 / 51

Page 44: LATEX, beamer tikz und Co.thw/vl-latex-co/k-05-math-folien.pdfI Dokumenation: amsldoc.pdf I TEXLive: texdoc amsmath oder texdoc amsldoc I \usepackage{mathtools} I Dokumentation: mathtools.pdf

Mathematischer Formelsatz

Umgebungen für Formelbausteine

Bausteine für Formeln (2): Fallunterscheidungen

I amsmath bietet die cases UmgebungI mathtools bietet mehr

I cases*: rechte Spalte automatisch im „text mode“I dcases bzw. dcases*: linke Spalte im „display math mode“

44 / 51

Page 45: LATEX, beamer tikz und Co.thw/vl-latex-co/k-05-math-folien.pdfI Dokumenation: amsldoc.pdf I TEXLive: texdoc amsmath oder texdoc amsldoc I \usepackage{mathtools} I Dokumentation: mathtools.pdf

Mathematischer Formelsatz

Umgebungen für Formelbausteine

Bausteine für Formeln (2): Fallunterscheidungen

\begin{equation}f(n) = \begin{dcases*}

3n+1, & falls $n$ ungerade \\\frac{n}{2}, & falls $n$ gerade \\

\end{dcases*}\end{equation}

f (n) =

3n + 1, falls n ungeraden

2, falls n gerade

(16)

45 / 51

Page 46: LATEX, beamer tikz und Co.thw/vl-latex-co/k-05-math-folien.pdfI Dokumenation: amsldoc.pdf I TEXLive: texdoc amsmath oder texdoc amsldoc I \usepackage{mathtools} I Dokumentation: mathtools.pdf

Mathematischer Formelsatz

Umgebungen für Formelbausteine

Bausteine für Formeln (2): Fallunterscheidungen

I amsmath bietet die cases UmgebungI mathtools bietet mehr

I cases*: rechte Spalte automatisch im „text mode“I dcases bzw. dcases*: linke Spalte im „display math mode“I rcases, rcases*, drcases, drcases*:

geschweifte Klammer auf der rechten Seite

46 / 51

Page 47: LATEX, beamer tikz und Co.thw/vl-latex-co/k-05-math-folien.pdfI Dokumenation: amsldoc.pdf I TEXLive: texdoc amsmath oder texdoc amsldoc I \usepackage{mathtools} I Dokumentation: mathtools.pdf

Mathematischer Formelsatz

Typografisches Finetuning

Überblick

Formeln

Normaler Text in Formeln

Klammern

Matrizen

Umgebungen für Gleichungen

Umgebungen für Formelbausteine

Typografisches Finetuning47 / 51

Page 48: LATEX, beamer tikz und Co.thw/vl-latex-co/k-05-math-folien.pdfI Dokumenation: amsldoc.pdf I TEXLive: texdoc amsmath oder texdoc amsldoc I \usepackage{mathtools} I Dokumentation: mathtools.pdf

Mathematischer Formelsatz

Typografisches Finetuning

\smashI Syntaxbeispiele:

\fbox{$y$} \fbox{$\smash{y}$}\fbox{$\smash[b]{y}$} \fbox{$\smash[t]{y}$}

y y y y

I Beispielanwendung

\fbox{$\sqrt{x} \sqrt{y} \sqrt{z}$}\fbox{$\sqrt{x} \sqrt{\smash[b]y} \sqrt{z}$}

√x√y√z√x√y√z

48 / 51

Page 49: LATEX, beamer tikz und Co.thw/vl-latex-co/k-05-math-folien.pdfI Dokumenation: amsldoc.pdf I TEXLive: texdoc amsmath oder texdoc amsldoc I \usepackage{mathtools} I Dokumentation: mathtools.pdf

Mathematischer Formelsatz

Typografisches Finetuning

\mathllap, \mathrlap, \mathclap

Beispiel

\begin{gather*}X = \sum_{1\le i\le j\le n} X_{ij} \\[5mm]X = \sum_{\mathclap{1\le i\le j\le n}} X_{ij}

\end{gather*}

X =∑

1≤i≤j≤nXi j

X =∑

1≤i≤j≤nXi j

49 / 51

Page 50: LATEX, beamer tikz und Co.thw/vl-latex-co/k-05-math-folien.pdfI Dokumenation: amsldoc.pdf I TEXLive: texdoc amsmath oder texdoc amsldoc I \usepackage{mathtools} I Dokumentation: mathtools.pdf

Mathematischer Formelsatz

Typografisches Finetuning

\cramped

I erzwingt sparsameren Umgang Exponenten und IndizesI \cramped{〈Formelteil〉}I Beispiel:

laber blubber text hyperbolisch diabolisch tralala eine Formel im

laufenden Text ohne \cramped (2222) und mehr Text blubber text

hyperbolisch diabolisch tralala erzwingt sparsameren UmgangExponenten und Indizes und mit \cramped (222

2) laber blubber text

hyperbolisch diabolisch tralala eine Formel eine Formel imlaufenden Text (siehe auch Demodatei)

50 / 51

Page 51: LATEX, beamer tikz und Co.thw/vl-latex-co/k-05-math-folien.pdfI Dokumenation: amsldoc.pdf I TEXLive: texdoc amsmath oder texdoc amsldoc I \usepackage{mathtools} I Dokumentation: mathtools.pdf

Mathematischer Formelsatz

Typografisches Finetuning

\phantom, \hphantom, \vphantomI Syntax:

I \phantom{\meta{Formelteil}}I \hphantom{\meta{Formelteil}}I \vphantom{\meta{Formelteil}}

I Effekt:

\fbox{$\sqrt{y}$}\fbox{$\phantom{\sqrt{y}}$}\fbox{$\hphantom{\sqrt{y}}$}\fbox{$\vphantom{\sqrt{y}}$}

√y

I Beispielanwendung: Demodatei zu Über- und Unter-Klammerung51 / 51