5.1 Mathematische Formeln schreiben
Aus Online Mathematik Brückenkurs 1
Theorie | Übungen |
Inhalt:
- Mathematische Ausdrücke in LaTeX
Lernziele
Nach diesem Abschnitt sollten Sie folgendes können:
- Einfache Formeln in LaTeX schreiben.
- Häufige Fehler vermeiden, die beim Erstellen von Dokumenten mit LaTeX auftreten.
Um Mathematik effizient auf einem Computer in Ihrer persönlichen Hausaufgabe und der Gruppenaufgabe zu schreiben, werden Sie den mathematischen Text in Form eines Syntax schreiben, der LaTeX genannt wird. In diesem Abschnitt lernen Sie den grundlegenden LaTeX-Code, um einfache mathematische Formeln schreiben zu können.
Einfache Ausdrücke schreiben
Um mathematische Formatierungen zu beginnen, verwenden Sie das Tag <math> und zum Beenden </math>. Wenn Sie z.B. die Formel \displaystyle a+b in einer Textumgebung eingeben möchten, schreiben Sie <math>a+b</math>.
Einfache mathematische Formeln schreiben sich "straightforward".
Beispiel 1
- \displaystyle 1+2-3\quad wird geschrieben als <math>1+2-3</math>
- \displaystyle 5/2\quad wird geschrieben als <math>5/2</math>
- \displaystyle 4/(2+x)\quad wird geschrieben als <math>4/(2+x)</math>
- \displaystyle 4 < 5\quad wird geschrieben als <math>4 < 5</math>
Benötigen Sie Symbole, die nicht auf der Tastatur verfügbar sind oder Formeln, die nicht so einfach zu schreiben sind, verwenden Sie hierzu spezielle Befehle. Diese beginnen mit einem Backslash (d.h. \setminus). Zum Beispiel ist \le der Befehl, welcher \displaystyle \le erzeugt.
Die folgende Tabelle zeigt Ihnen einige der am häufigsten verwendeten Befehle in LaTeX
Example | LaTeX-code | Comment | ||
Grundrechenarten | a+b | a+b | ||
a-b | a-b | |||
a\pm b | a\pm b | |||
a\times b | a\times b | |||
a/b | a/b | |||
\frac{1}{2} | \frac{1}{2} | Kleiner Bruch | ||
\dfrac{a}{b} | \dfrac{a}{b} | Großer Bruch | ||
(a) | (a) | Skalierende Klammern: \left(...\right) | ||
Vergleichssymbole | a=b | a=b | ||
a\ne b | a\ne b | Alternativ: a\not= b | ||
a< b | a< b | Bem.: Leerzeichen nach "<" | ||
a\le b | a\le b | |||
a> b | a>b | |||
a\ge b | a\ge b | |||
Potenzen und Wurzeln | x^{n} | x^{n} | ||
\sqrt{x} | \sqrt{x} | |||
\sqrt[n]{x} | \sqrt[n]{x} | Schreiben Sie \sqrt[\scriptstyle n]{x} für größeres n | ||
Indizes | x_n | x_{n} | ||
Logarithmen | \lg x | \lg x | ||
\ln x | \ln x | |||
\log x | \log x | |||
\log_{a} x | \log_{a} x | |||
Trigonometrie | 30^{\circ} | 30^{\circ} | ||
\cos x | \cos x | |||
\sin x | \sin x | |||
\tan x | \tan x | |||
\cot x | \cot x | |||
Arrows | \Rightarrow | \Rightarrow | Implies | |
\Leftarrow | \Leftarrow | Is implied by | ||
\Leftrightarrow | \Leftrightarrow | Is equivalent to | ||
Various symbols | \pi | \pi | ||
\alpha, \beta, \theta, \varphi | \alpha, \beta, \theta, \varphi |
Beispiel 2
- \displaystyle 1\pm3\times 5\quad is written <math>1\pm 3\times 5</math>
- \displaystyle \tfrac{1}{2}y\ne x\le z\quad is written <math>\frac{1}{2}y\ne x\le z</math>
- \displaystyle 2^{13}\sqrt{3}+\ln y\quad is written <math>2^{13}\sqrt{3}+\ln y</math>
- \displaystyle \tan 30^{\circ}\quad is written <math>\tan 30^{\circ}</math>
How to write complex expressions
By combining simple expressions, we may form more complex expressions.
Beispiel 3
- \displaystyle \sqrt{x+2}\quad is written <math>\sqrt{x+2}</math>
- \displaystyle (a^2)^3=a^6\quad is written <math>(a^2)^3=a^6</math>
- \displaystyle 2^{(2^2)}\quad is written <math>2^{(2^2)}</math>
- \displaystyle \sin\sqrt{x}\quad is written <math>\sin\sqrt{x}</math>
Beispiel 4
- \displaystyle \sqrt{x+\sqrt{x}}\quad is written <math>\sqrt{x+\sqrt{x}}</math>
- \displaystyle \dfrac{x-x^2}{\sqrt{3}}\quad is written <math>\dfrac{x-x^2}{\sqrt{3}}</math>
- \displaystyle \dfrac{x}{x+\dfrac{1}{x}}\quad is written <math>\dfrac{x}{x+\dfrac{1}{x}}</math>
- \displaystyle x_{1,2}=-\dfrac{p}{2}\pm\sqrt{\left(\dfrac{p}{2}\right)^2-q}\quad is written <math>x_{1,2}=-\dfrac{p}{2}\pm\sqrt{\left(\dfrac{p}{2}\right)^2-q}</math>
How to avoid common mistakes
One of the most common mistakes when editing math in the wiki is to forget the start <math> tag and the end </math> tag.
Remember also to start commands with a backslash (\) and to add a space after the commands (unless they are followed immediately by a new command).
Another frequent mistake is to use an asterisk (*) instead of a proper multiplication sign \displaystyle \times (\times in TeX).
Beispiel 5
LaTeX | Result | |
| sin x | \displaystyle sin x |
| \sinx | Error |
| \sin x | \displaystyle \sin x |
| 4*3 | \displaystyle 4*3 |
| 4\times 3 | \displaystyle 4\times 3 |
| a\times b | \displaystyle a\times b |
| ab | \displaystyle ab |
Superscripts and subscripts
When writing superscripts, such as exponents, you use ^, and to write subscripts you use _. If the super- or subscript consists of more than one symbol it must be enclosed with braces {}.
A special kind of superscript is the degree sign (°) which is written as ^{\circ}.
Beispiel 6
LaTeX | Result | |
| a2 | \displaystyle a2 |
| a^2 | \displaystyle a^2 |
| x1 | \displaystyle x1 |
| x_1 | \displaystyle x_1 |
| a^22 | \displaystyle a^22 |
| a^{22} | \displaystyle a^{22} |
| 30^{o} | \displaystyle 30^{o} |
| 30^{0} | \displaystyle 30^{0} |
| 30^{\circ} | \displaystyle 30^{\circ} |
Delimiters
In more complex expressions you need to make sure to balance each opening parenthesis ( with a closing parenthesis ).
A pair of parenthesis that delimits a tall expression should be as large as the expression. You should therefore prefix the opening parenthesis with \left and the closing parenthesis with \right to get a pair of extensible parentheses that adjust its height to the expression.
Note also that braces, {}, and not parentheses, (), are used to delimit arguments (input values) of commands such as \sqrt and \frac.
Beispiel 7
LaTeX | Result | |
| (1-(1-x) | \displaystyle (1-(1-x) |
| (1-(1-x)) | \displaystyle (1-(1-x)) |
| (\dfrac{a}{b}+c) | \displaystyle (\dfrac{a}{b}+c) |
| \left(\dfrac{a}{b}+c\right) | \displaystyle \left(\dfrac{a}{b}+c\right) |
| \frac(1)(2) | \displaystyle \tfrac(1)(2) |
| \frac{1}{2} | \displaystyle \tfrac{1}{2} |
| \sqrt(a+b) | \displaystyle \sqrt(a+b) |
| \sqrt{(a+b)} | \displaystyle \sqrt{(a+b)} |
| \sqrt{a+b} | \displaystyle \sqrt{a+b} |
Fractions
As a rule of thumb you should write fractions where the numerator and denominator consist only of a few digits as a small fraction (i.e. with \frac), while other fractions should be large (i.e. with \dfrac).
If an exponent or index contains a fraction then that fraction should be written in a slashed form (e.g. \displaystyle 5/2 instead of \displaystyle \tfrac{5}{2}) to enhance the legibility.
Beispiel 8
LaTeX | Result | |
| \dfrac{1}{2} | \displaystyle \dfrac{1}{2} |
| \frac{1}{2} | \displaystyle \tfrac{1}{2} |
| ||
| \frac{a}{b} | \displaystyle \tfrac{a}{b} |
| \dfrac{a}{b} | \displaystyle \dfrac{a}{b} |
| \frac{\sqrt{3}}{2} | \displaystyle \tfrac{\sqrt{3}}{2} |
| \dfrac{\sqrt{3}}{2} | \displaystyle \dfrac{\sqrt{3}}{2} |
| a^{\frac{1}{2}} | \displaystyle a^{\frac{1}{2}} |
| a^{1/2} | \displaystyle a^{1/2} |
Tipps fürs Lernen
A tip is to try out your maths formulas in the forum or in the wiki where you work on your individual assignment.
Nützliche Websites
- A more thorough list of LaTeX maths commands can be found on Wikipedia's help page
- Two more thorough texts on LaTeX maths can be found in a chapter of the book The LaTeX Companion and a text by Herbert Voss.
- If you want to know more about LaTeX you can visit these sites: Wikipedia, The not so Short Introduction to LaTeX and LaTeX Wikibook.
- The actual implementation of LaTeX math that is used in the wiki is jsMath.