๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
IT-Engineering

ํ‹ฐ์Šคํ† ๋ฆฌ์—์„œ MathJax๋กœ ์‰ฝ๊ฒŒ ์ˆ˜์‹ ์ž…๋ ฅํ•˜๊ธฐ(feat.LaTeX)

by ๐Ÿงž‍โ™‚๏ธ 2020. 5. 27.
๋ฐ˜์‘ํ˜•

๋ชจ๋“  ๋ธŒ๋ผ์šฐ์ €์—์„œ ์ž˜ ์ž‘๋™ํ•˜๋Š” ์›น ์ˆ˜์‹ ํŽธ์ง‘ ๋„๊ตฌ 'MathJax'๋ฅผ ์ด์šฉํ•ด์„œ

LaTeX ์ˆ˜์‹์„ ํ‹ฐ์Šคํ† ๋ฆฌ(Tistory)์—์„œ ์‰ฝ๊ฒŒ ์ž…๋ ฅํ•ด๋ณด์ž!!

 

๊ณตํ•™์ด ์ „๊ณต์ธ์ง€๋ผ ์•„๋ฌด๋ž˜๋„ ํฌ์ŠคํŒ…์— ์ˆ˜์‹์„ ์ข…์ข… ์ž…๋ ฅํ•  ์ผ์ด ์ƒ๊ธฐ๋Š”๋ฐ,

์•„์‰ฝ๊ฒŒ๋„ ํ‹ฐ์Šคํ† ๋ฆฌ์—์„œ๋Š” ์ ์ ˆํ•œ ์ˆ˜์‹ ์ž…๋ ฅ๊ธฐ๋ฅผ ์ œ๊ณตํ•ด์ฃผ์ง€ ์•Š๊ณ  ์žˆ๋‹ค.

 

๋…ผ๋ฌธ์„ ์ž‘์„ฑํ•  ๋•Œ ์•„๋ž˜ํ•œ๊ธ€(.hwp)์ด๋‚˜ MS์›Œ๋“œ(.doc, .docx)๋ฅผ ๋งŽ์ด ์‚ฌ์šฉํ•˜๊ธฐ๋„ ํ•˜์ง€๋งŒ

์ƒ๊ฐ ์ด์ƒ์œผ๋กœ ์–‘์‹์„ ๋งž์ถ”๋Š” ๊ฒƒ์ด ์–ด๋ ค์›Œ(๊ท€์ฐฎ...) ์˜คํžˆ๋ ค ์Šคํฌ๋ฆฝํŠธ ๊ธฐ๋ฐ˜์ธ LaTeX๋„ ๋งŽ์ด ์‚ฌ์šฉ๋œ๋‹ค.

 

์„ธ์ƒ์—๋Š” ํ›Œ๋ฅญํ•œ ๋ถ„๋“ค์ด ๋งŽ์ด ๊ณ„์…”์„œ LaTeX์˜ ์ˆ˜์‹ ๋ฌธ๋ฒ•์„ ์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ ํŒŒ์ผ(.js)๋งŒ ๊ฐ€์ ธ๋‹ค ์“ฐ๋ฉด

์‰ฝ๊ฒŒ ์“ธ ์ˆ˜ ์žˆ๋Š” ํˆด์„ ์ œ๊ณตํ•˜๊ณ  ์žˆ์œผ๋‹ˆ ์ด๋ฆ„ํ•˜์—ฌ MathJax๋‹ค.

https://www.mathjax.org/

 

MathJax

Beautiful math in all browsers.

www.mathjax.org

๋ชจ๋“  ๋ธŒ๋ผ์šฐ์ €์—์„œ ์ž˜ ์ž‘๋™ํ•˜๋Š” ์›น ์ˆ˜์‹ ํŽธ์ง‘ ๋„๊ตฌ MathJax

 

ํ˜„์žฌ๋Š” ๋ฒ„์ „์ด 3์ ๋Œ€๊นŒ์ง€ ๋‚˜์™”๋‹ค. ๊ธฐ์กด์— ํ•„์ž๋„ 2์ ๋Œ€ ๋ฒ„์ „์„ ์‚ฌ์šฉํ–ˆ๋Š”๋ฐ ์ด๋ฒˆ ํฌ์ŠคํŒ…์„ ๊ณ„๊ธฐ๋กœ 3์ ๋Œ€๋กœ ๋„˜์–ด์™”๋‹ค.

MathJax๋Š” TeX, LaTeX, MathML ๋ฌธ๋ฒ•์„ ์ง€์›ํ•œ๋‹ค.

3์ ๋Œ€๋ฅผ ์‚ฌ์šฉํ•˜๊ธฐ ์œ„ํ•ด์„œ๋Š” ๊ฐ„๋‹จํ•˜๊ฒŒ ์ž‘์„ฑํ•˜๋ ค๋Š” ํฌ์ŠคํŒ… ํ˜น์€ HTML์—

๊ฐ„๋‹จํ•˜๊ฒŒ ์•„๋ž˜์˜ ์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ ์ฝ”๋“œ๋ฅผ ํฌํ•จ์‹œํ‚ค๋ฉด ๋œ๋‹ค.

<script src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script>
<script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>

๊ฐ„๋‹จํ•œ ์˜ˆ์ œ๋„ ์•„๋ž˜์™€ ๊ฐ™์ด ์นœ์ ˆํ•˜๊ฒŒ ์ œ๊ณตํ•˜๊ณ  ์žˆ๋‹ค.(example on jsbin)

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>MathJax example</title>
  <script src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script>
  <script id="MathJax-script" async
          src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js">
  </script>
</head>
<body>
<p>
  When \(a \ne 0\), there are two solutions to \(ax^2 + bx + c = 0\) and they are
  \[x = {-b \pm \sqrt{b^2-4ac} \over 2a}.\]
</p>
</body>
</html>

์œ„์˜ HTML ํŒŒ์ผ์ด ์ถœ๋ ฅ๋˜๋Š” ๋ชจ์Šต์€ ์•„๋ž˜์™€ ๊ฐ™๋‹ค.

mathjax๋ฅผ ํ†ตํ•ด ์ถœ๋ ฅ๋œ HTML์˜ ๋ชจ์Šต

 

ํ•˜์ง€๋งŒ ํ‹ฐ์Šคํ† ๋ฆฌ์—์„œ ์ž‘์—…์„ ํ•˜๊ฒŒ๋˜๋ฉด ์œ„์˜ ์„ค๋ช…์œผ๋กœ๋Š” ๋ถ€์กฑํ•˜๋‹ค.

๋ณธ ํฌ์ŠคํŒ…์—์„œ๋Š” MathML์€ ์™„์ „ํžˆ ์ƒ๋žตํ•˜๊ณ , LaTeX๋ฌธ๋ฒ•๋งŒ์„ ์‚ฌ์šฉํ•˜๊ธฐ ์œ„ํ•ด MathJX๋ฅผ ์‚ฌ์šฉํ•˜๊ฒ ๋‹ค.

์ด ๊ฒฝ์šฐ๋Š” ํŠน๋ณ„ํ•œ ์„ค์ •์—†์ด ์•„๋ž˜์˜ ๋ฐฉ์‹์œผ๋กœ ๋ฐ”๋กœ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋‹ค๋Š” ์žฅ์ ์ด ์žˆ๋‹ค.

๋ฐ”๋กœ ์‚ฌ์šฉํ•˜๊ธฐ ์œ„ํ•ด์„œ๋Š” ์—ฌ๊ธฐ๋ถ€ํ„ฐ ์•„๋ž˜๋งŒ ๋ด๋„ ์ถฉ๋ถ„ํ•˜๋‹ค.

(1) ๊ธฐ๋ณธ๋ชจ๋“œ์—์„œ HTML๋ชจ๋“œ๋กœ ๋ณ€๊ฒฝ ํ›„ ๋งจ ์œ„์— ์•„๋ž˜์˜ ์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ ์ฝ”๋“œ๋ฅผ ํฌํ•จ์‹œํ‚จ๋‹ค. 

<script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml.js"></script>

(2) LaTeX ๋ฌธ๋ฒ•์„ ์‚ฌ์šฉํ•œ ์ฝ”๋“œ๋ฅผ ์ž‘์„ฑํ•˜๊ณ , ์—ญ์Šฌ๋ž˜์‰ฌ ๊ด„ํ˜ธ ํ˜•ํƒœ(์•„๋ž˜ ์ฐธ์กฐ;์ค‘๊ด„ํ˜ธ๋Š” ์•ˆ๋จ) ๋˜๋Š” ์ด์ค‘๋‹ฌ๋Ÿฌ๋กœ ์ฝ”๋“œ๋ฅผ ๋ฌถ์–ด์ค€๋‹ค.

\[    x=\frac{-b+\sqrt{b^{2}-4ac}}{2a}    \]
\(    x=\frac{-b+\sqrt{b^{2}-4ac}}{2a}    \)
$$    x=\frac{-b+\sqrt{b^{2}-4ac}}{2a}    $$

์œ„์˜ HTML ์ฝ”๋“œ์— ์žˆ๋Š” LaTeX ์ˆ˜์‹์„ ๊ทธ๋Œ€๋กœ ์ ์–ด๋ณด์•˜๋‹ค. ์งœ์ž”!

\[    x=\frac{-b+\sqrt{b^{2}-4ac}}{2a}    \]
\(    x=\frac{-b+\sqrt{b^{2}-4ac}}{2a}    \)
$$    x=\frac{-b+\sqrt{b^{2}-4ac}}{2a}    $$

์œ„ ํ‘œ๊ธฐ ๋ฐฉ์‹์˜ ์šฉ๋„๊ฐ€ ๋‹ค๋ฅธ ๊ฒƒ๋„ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค. (inline์ž…๋ ฅ๊ณผ, block๋ฐฉ์‹์˜ ์ž…๋ ฅ์ด๋‹ค.)

LaTeX ์ฝ”๋“œ๋Š” https://www.codecogs.com/latex/eqneditor.php ์ด๊ณณ์—์„œ ์ž‘์„ฑํ•˜๋ฉด ํŽธํ•˜๋‹ค.

 

Online LaTeX Equation Editor - create, integrate and download

Type your equation in this box

www.codecogs.com

 

์œ„์˜ ๋ฐฉ์‹์ด ๋ถˆํŽธํ•˜๋‹ค๋ฉด ์•„๋ž˜์™€ ๊ฐ™์ด ์„ค์ •์„ ์กฐ์ •ํ•  ์ˆ˜ ์žˆ๋‹ค.

(1) ๊ธฐ๋ณธ๋ชจ๋“œ์—์„œ HTML๋ชจ๋“œ๋กœ ๋ณ€๊ฒฝ ํ›„ ๋งจ ์œ„์— ์•„๋ž˜์˜ ์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ ์ฝ”๋“œ๋ฅผ ํฌํ•จ์‹œํ‚จ๋‹ค. (์„ค์ •์ด ์ถ”๊ฐ€๋œ ๊ฒƒ์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค.)

<script>
  MathJax = {
    tex: {inlineMath: [['$', '$'], ['\\(', '\\)']]}
  };
</script>
<script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml.js"></script>

(2) LaTeX ์ฝ”๋“œ๋ฅผ ์ ์€ ๋’ค ์•ž๋’ค์— ๋‹ฌ๋Ÿฌํ‘œ์‹œ($)๋กœ๋งŒ ๋ฌถ์–ด์ค€๋‹ค.

์œ„์˜ ์ˆ˜์‹ x=\frac{-b+\sqrt{b^{2}-4ac}}{2a}  ์ด ๋ถ€๋ถ„์„ ๋‹ฌ๋Ÿฌ๋กœ ๋ฌถ์–ด๋ณด๊ฒ ๋‹ค.

$x=\frac{-b+\sqrt{b^{2}-4ac}}{2a}$

์งœ์ž”!

์ด๋ ‡๊ฒŒ ์‚ฌ์šฉํ•˜๋ฉด ๋œ๋‹ค.

ํŠน์ • ๋ฒ„์ „์„ ์ง€์ •ํ•˜์ง€ ์•Š๊ณ  ์œ„์˜ ๋ฐฉ์‹์œผ๋กœ ํ•˜๋ฉด ํ•ญ์ƒ ์ตœ์‹  3์ ๋Œ€ ๋ฒ„์ „์„ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์œผ๋‹ˆ ์ฐธ๊ณ ํ•˜๊ธฐ ๋ฐ”๋ž€๋‹ค.

 

์ฐธ๊ณ ์ž๋ฃŒ

1. ์œ„ํ‚ค๋ฐฑ๊ณผ TeX๋ฌธ๋ฒ• ์ฐธ์กฐ: https://ko.wikipedia.org/wiki/%EC%9C%84%ED%82%A4%EB%B0%B1%EA%B3%BC:TeX_%EB%AC%B8%EB%B2%95)

 

์œ„ํ‚ค๋ฐฑ๊ณผ:TeX ๋ฌธ๋ฒ• - ์œ„ํ‚ค๋ฐฑ๊ณผ, ์šฐ๋ฆฌ ๋ชจ๋‘์˜ ๋ฐฑ๊ณผ์‚ฌ์ „

์œ„ํ‚ค๋ฐฑ๊ณผ, ์šฐ๋ฆฌ ๋ชจ๋‘์˜ ๋ฐฑ๊ณผ์‚ฌ์ „. ์œ„ํ‚ค๋ฐฑ๊ณผ์—์„œ๋Š” ์ˆ˜ํ•™ ๊ณต์‹์„ ๊ฐ„ํŽธํ•˜๊ฒŒ ์ž…๋ ฅํ•˜๊ธฐ ์œ„ํ•ด, TeX ๋ฌธ๋ฒ•์„ ์ง€์›ํ•ฉ๋‹ˆ๋‹ค. ์ด๊ฒƒ์€ ์ˆ˜์‹์ด ๊ฐ„๋‹จํ•œ ๊ฒฝ์šฐ HTML๋กœ, ๋ณต์žกํ•œ ๊ฒฝ์šฐ์—๋Š” PNG ๊ทธ๋ฆผ์œผ๋กœ ๋‚˜ํƒ€๋‚ฉ๋‹ˆ๋‹ค. ๋˜๏ฟฝ

ko.wikipedia.org

2. MathJax TeX ๋ฐ๋ชจ ์˜ˆ์ œ https://mathjax.github.io/MathJax-demos-web/tex-chtml.html

 

MathJax v3 with TeX input and HTML output

MathJax v3 beta: TeX input, HTML output test When $a \ne 0$, there are two solutions to \(ax^2 + bx + c = 0\) and they are $$x = {-b \pm \sqrt{b^2-4ac} \over 2a}.$$ The Lorenz Equations \begin{align} \dot{x} & = \sigma(y-x) \\ \dot{y} & = \rho x - y - xz \

mathjax.github.io

 

๋ฐ˜์‘ํ˜•

๋Œ“๊ธ€