그래서 TISTORY에 수식을 입력할 방법이 있을까 찾아보다가 LaTeX 문법으로 수식을 입력할 수 있는 JavaScript가 존재!
집에서 블로그에 추가하고, 간단한 수식 입력으로 테스트 까지만 해 봤다.
<script language="javascript" type="text/javascript">
// Last Modified by EunbitNaetmul(http://serna.tistory.com)
document.createElement("tex");
document.createElement("texeq");
var mathtex_server = "http://latex.codecogs.com/gif.latex";
function generateLink(code)
{
return "<img class=\"equation\" src=\""+ mathtex_server + "?" + code +"\" />";
}
function generateTeX(tag)
{
var eqn = window.document.getElementsByTagName(tag);
for (var i = 0; i < eqn.length; i++) {
if (tag == "tex")
eqn[i].innerHTML = generateLink("\\inline " + eqn[i].innerHTML);
else if (tag == "texeq")
eqn[i].innerHTML = generateLink(eqn[i].innerHTML);
}
}
</script>
<script language="javascript" type="text/javascript">
generateTeX("tex");
generateTeX("texeq");
</script>
수식의 입력은, HTML 모드로 전환하여 <tex></tex> 또는 <texeq></texeq> tag 사이에 LaTeX 수식 입력 문법으로 입력하면 된다.
<tex>\sum_{k=1}^{n}k=\frac{n(n+1)}{2}</tex><br />
<texeq>\sum_{k=1}^{n}k=\frac{n(n+1)}{2}</texeq><br />
위와 같이 입력하면, 아래와 같이 표시된다.
안타깝게도(?) 본인은 망각의 동물인지라, 대학원에서 논문 쓸 때 사용 했던 LaTeX 문법을 다 잊어 버렸다.
그래서 다시 찾아서 블로그에 정리 해 두어야 겠다고 결심.
우선 URL만... 정리는 나중에 :-)
http://www.math.uiuc.edu/~hildebr/tex/course/intro2.html
Basic math
Elementary arithmetic operations: The plus (+), minus (-), division (/) symbols have the usual meaning. To denote multiplication explicitly (this is rarely necessary), use \cdot (producing a centered dot) or \times (producing an "x"). The "equal", "less than", and "greater than" symbols on the keyboard work as expected; to get "less than or equal", use "\le"; similarly, "\ge" gives "greater than or equal".Square roots: Square roots are generated with the command \sqrt{...}. For example, $z=\sqrt{x^2+y^2}$.
Subscripts and superscripts: These are indicated by carets (^) and underscores (_), as in $2^n$ or $a_1$. If the sub/superscript contains more than one character, it must be enclosed in curly braces, as in $2^{x+y}$.
Fractions and binomial coefficients: Fractions are typeset with $\frac{x}{y}$, where x stands for the numerator and y for the denominator. There is a similar construct $\binom{x}{y}$ for binomial coefficients. (The latter is part of the amsmath enhancements which you get when using "amsart" as documentclass.)
Sums and integrals: The symbols for sums and integrals are \sum and \int, respectively. These are examples of "large" operators, and their sizes are adjusted by TeX automatically, depending on the context (e.g., inline vs. display math). Note that the symbol generated by \sum is very different from the "cap-Sigma" symbol, \Sigma; the latter should never be used to denote sums. TeX uses a simple, but effective scheme to typeset summation and integration limits: Namely, lower and upper limits are specified as sub- and superscripts to \sum and \int. For example, $\sum_{k=1}^n k = \frac{n(n+1)}{2}$. (Note that the "lower limit" "k=1" here must be enclosed in braces.)
Limits: The "subscript" trick works also for limits; "\lim" produces the "lim" symbol, and the expression underneath this symbol (for example, "x tends to infinity") is typeset as a subscript to \lim: $\lim_{x\to\infty}f(x)=0$. Here "\to" produces the arrow, and "\infty" (note the abbreviation - \infinity does not work!) produces the "infinity" symbol. "\limsup" and "\liminf" work similarly, as do "\sup" and "\inf" (for supremum and infinimum), and "\max" and "\min" (for maximum and minimum). For example, $\max_{0\le x\le 1}x(1-x)=1/4$.
Exercise 2.1: Continuity of a function f(x) at a point x=c can be defined in terms of a limit: "f(x) is continuous at x=c if lim .....". Fill in the blanks and typeset the statement first inline, and then with the "lim ..." formula displayed on a single line. Observe how TeX typesets the limit differently, depending on the context.
Exercise 2.2: Typeset the binomial theorem (giving an expansion for (x+y)^n) in TeX, first as an "inline" formula (enclosed in a pair of single dollar signs), then as a displayed formula (enclosed in a pair \[, \]). Compile the TeX file, and observe the differences in the appearance of the output of the inline and the displayed formulas.
Operators: TeX has commands for common mathematical "operators" or "functions", such as \sin, \cos, \log, \ln, \exp, \arctan, etc. You should always use these commands instead of simply typing "sin", "cos", etc., without the backslash. Using the TeX commands ensures that the operators get typeset in the proper font and takes care of the spacing surrounding these operators.
Exercise 2.3: Typeset the addition formula for the sine: sin(x+y) = sin x cos y + cos x sin y, first using the proper TeX commands \sin and \cos and then by just typing sin and cos without the backslash. Observe the difference.
More math
Greek letters and other special characters: The commands for Greek letters are easy and intuitive: Just type $\epsilon$, $\delta$, $\nu$, $\phi$, etc. To get upper case versions of these letters, capitalize the appropriate command; e.g., $\Delta$ gives a "cap-Delta" (which looks like a triangle). The most common notation for the reals, rationals, and integers involves the so-called "blackboard bold" font; to get these symbols use \mathbb{...} (in math mode): $\mathbb{R}$, $\mathbb{Q}$, $\mathbb{Z}$. Similarly \mathcal{...} produces a symbol in "script" or "caligraph" font, often used to denote sets: For example, $\mathcal{A}$ generates "script A".Parentheses: The symbol pairs (), [], and \{ \} (note the backslash!) generate round, square, and curly parentheses in normal size. They work fine in math mode, but mathematical expressions often look better if the parentheses are enlarged to match the size of the expression. There are ways to manually enlarge these parentheses (by preceding the symbol with a command like \big, \bigg, \Big, etc.), but one rarely has to use these, since TeX can (in most cases) automatically size parentheses. To let TeX do the sizing, precede the left brace by \left, and the right brace by \right. This also works for other parentheses-like constructs, such as the absolute value symbol "|". Here is an example:
\[ \left|\sum_{i=1}^n a_ib_i\right| \le \left(\sum_{i=1}^n a_i^2\right)^{1/2} \left(\sum_{i=1}^n b_i^2\right)^{1/2} \]
Exercise 2.4: Typeset the above expression and look at the output. (It's a famous mathematical theorem!). Then remove, or comment out, one of the bracket expressions (say, one instance of "\left("), and see what error messages you get. All bracket expressions generated by \left.. or \right.. must occur in pairs, and TeX gives an error message if this is not the case. (The left and right brackets don't have to be of the same type; for example, $\left\[\frac{3}{4}, \frac{4}{5}\right[$ to denote the half-open interval [3/4, 4/5[ is perfectly legal.)
Displayed equations
Single line displays: To get a single line, displayed equation (without equation number), just use the pair "\[", "\]". If you want TeX to automatically number the equation, use instead the \begin{equation} ... \end{equation} environment. (The asterisk variant, \begin{equation*} ... \end{equation*}, turns off the equation numbering, and is equivalent to typing \[ ... \].)Multi-line equation environments: Things get more complicated if you have multiline equations that need to be lined up at suitable places. For most situations, the \begin{align} ... \end{align} environment, and its variant \begin{align*} ... \end{align*}, are sufficient. As with the equation environment, the asterisk version does not automatically number equations.
The use of align is best illustrated with an example:
\begin{align} (a+b)^3 &= (a+b)^2(a+b)\\ &=(a^2+2ab+b^2)(a+b)\\ &=(a^3+2a^2b+ab^2) + (a^2b+2ab^2+b^3)\\ &=a^3+3a^2b+3ab^2+b^3 \end{align}Here a double backslash (\\) is used to separate the lines, and an ampersand symbol (&) is used to indicate the place at which the formulas should be aligned. You can include more than one ampersand symbol per line to specify alignment at multiple columns, but the number of alignment symbols must be the same for each line of the display. Multiple alignments are rarely needed; in almost all cases a single alignment symbol, usually placed right before an equality (or inequality) sign, is enough.
Exercise 2.5: Typeset the above multiline equation, compile it, and look at the output on the screen. Also, make some intentional mistakes (like leaving out the ampersand symbol, or leaving out one of the \\'s), and see what kind of error messages you get. Errors in multiline displays are among the most difficult to track down and diagnose.
Spacing in math mode
In math mode (both ordinary and display math), TeX decides on spacings between symbols in math mode, using rather sophisticated algorithms; in particular, any blank spaces inside math mode are ignored, For example, the formula "$a^2 + b^2 = c^2$ could have been typed as "$a^2+b^2=c^2$", or even placed on two different lines, without any difference in the output. Letting TeX figure out the spacings almost always results in very good looking output, and you should avoid putting explicit spaces into mathematical formulas. However, there are a few situations where one does need appropriate spacing instructions. For those cases, there is a standard spacing command, "\quad" which generates the right amount of horizontal spacing to separate two equations on the same line, or a formula from an associated range or condition (such as "n=2,3,...") that is given on the same line, usually in parentheses.Exercise 2.6: Typeset the recurrence defining the Fibbonacci numbers, along with appropriate initial conditions. Use a single line display, with appropriate spacing commands (\quad's) separating the parts.
[2011/09/02 추가] 웹페이지에서 LaTeX 수식을 편집할 수 있는 사이트 발견. 여기서 입력해서 복사하면 편할 듯.
Online LaTex Equation Editor
'잡담' 카테고리의 다른 글
독산동 박차보네 불족발 (0) | 2011.09.17 |
---|---|
C++11 ISO Standard? (0) | 2011.08.17 |
정신을 차려보니 신용카드 명세서가 수북하니 쌓여 있었다. (1) | 2011.08.04 |
어쿠스틱 라이프 by 난다 (0) | 2011.08.03 |
고객의 기대를 뛰어넘는 가치를 제공하는 Google Chrome Browser (0) | 2011.07.27 |