--- title: "$\\KaTeX$" path: "KaTeX" --- {%hackmd @RintarouTW/About %} # KaTeX https://katex.org/ https://katex.org/docs/supported.html https://katex.org/docs/support_table.html https://katex.org/docs/options.html 與 MathJax 不同之處 ## Pros * Server Side Rendering (SSR) * Self Contained : No dependency * Fast (確實比 MathJax 快) * Extension and Component * [Auto Render](https://katex.org/docs/autorender.html) * [Copy Tex](https://github.com/Khan/KaTeX/tree/master/contrib/copy-tex) 可以直接用 <kbd>CMD</kbd>+<kbd>C</kbd> copy paste 回 $\LaTeX$ 表達式,對於傳遞流通很重要。MathJax 則要用右鍵 Save As Math,好幾步有點麻煩。 * [react-latex](https://github.com/zzish/react-latex) * [Handling Errors](https://katex.org/docs/error.html) * [Options](https://katex.org/docs/options.html) * [Font](https://katex.org/docs/font.html) * URL Support * `\includegraphics[width=30,height=30]{https://katex.org/img/khan-academy.png}` 需 option.trust = true * `\href{https://katex.org/}{\KaTeX}` * `\url{https://katex.org/}` * 所有 package 預設內建,沒有也不用 `\require`,有就有沒有就沒有。(MathJax 需另指定 tex-full) ## Cons * Not all support * no `\DeclareMathOperation` * no `{equation}` environment * Security 待驗正 * 在換行 Layout 的行高自動判定上沒有 MathJax 好,容易兩行連在一起,可能也和字型有關。 ## Differences 文件開頭必需指定 ``` <!DOCTYPE html> ``` 置中需換行 ``` $$ *commands* $$ displaystyle 要置中則必要在 $$ 後換行, 否則視為 inline displaystyle。 ``` 沒有 `\style` `\cal` `\hfil` `\hbox` `\mathstrut` `\matrix` 可 `\tag` 但沒 `\label` 不支援 {equation} 相關指令 - `begin/end{equation}` - `begin/end{equation*}` - `eqalign{}` - `eqref{}` `{gather}` 需換成 `{gathered}` evnironment $$ \lim\limits_{n\to 0} $$ ``` \lim\limits_{n\to 0} (OK) \lim_\limits{n\to 0} (KaTeX 不支援, MathJax 兩者都可以) ``` Custom Definition ``` \gdef 才可跨 $ \def 僅在 $ 結束前適用。 ``` Layout 語法差異 ``` \begin{}\end{} 的標準寫法 都 OK \being{pmatrix} \end{pamatrix} 但不支援 \pmatrix{ ... } 只有 Math Operation 才能寫成 \binom{n}{k} 或 \binom n k ``` $$ \begin{aligned} a & b &= e\\ c & d &= f \end{aligned} $$ ``` \begin{aligned} a & b &= e\\ c & d &= f \end{aligned} 不支援 \begin{align} ... \end{align} 也沒有 \eqalign{ ... } ``` $$ \begin{alignedat}{} a & b\\ c & d \end{alignedat} $$ ``` \begin{alignedat}{} a & b\\ c & d \end{alignedat} ``` --- ###### tags: `LaTeX` `KaTeX` `MathJax`
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up