18.2.2020:
Thêm một số dạng Công thức Toán học.
Thêm dạng Công thức Hóa học.
3.2.2020: Upload lên RPubs.
30.1.2020: Khởi tạo trang và upload lên GitHub.
Tại sao không bao giờ nên sử dụng utf8 trong MySQL?
Wikipedia: List of XML and HTML character entity references
JavaScript String Escape / Unescape
Overleaf: Mathematical expressions
W3C: Mathematical Markup Language (MathML) Version 3.0 2nd Edition
html_entitiesPathFile = "G:/R/Projects/ddRMarkdown/_datasets/html_entities.csv"
html_entities = read.csv(html_entitiesPathFile, encoding = "UTF-8")
escapePathFile = "G:/R/Projects/ddRMarkdown/_datasets/escape.csv"
escape = read.csv(escapePathFile, encoding = "UTF-8")
tex_mmlPathFile = "G:/R/Projects/ddRMarkdown/_datasets/tex_mml.csv"
tex_mml = read.csv(tex_mmlPathFile, encoding = "UTF-8")
library(kableExtra)# head(html_entities)
kable(html_entities[2:ncol(html_entities)]) %>%
kable_styling(bootstrap_options = c("striped", "hover")) %>%
scroll_box(width = "auto")| Name | Character | EntityName | HexDec | HTMLExample | HTMLDescription |
|---|---|---|---|---|---|
| Quotation mark | " | quot | U+0022 (34) | ||
| Ampersand | & | amp | U+0026 (38) | ||
| Apostrophe | ’ | apos | U+0027 (39) | ||
| Less-than | < | lt | U+003C (60) | ||
| Greater-than | > | gt | U+003E (62) | ||
| Number sign | # | num | U+0023 (35) | ||
| Solidus | / | sol | U+002F (47) | ||
| Reverse solidus (backward solidus) | \ | bsol | U+005C (92) | ||
| Semicolon | ; | semi | U+003B (59) | ||
| Colon | : | colon | U+003A (58) | ||
| Full stop (period) | . | period | U+002E (46) |
# head(escape)
kable(escape[2:ncol(escape)]) %>%
kable_styling(bootstrap_options = c("striped", "hover")) %>%
scroll_box(width = "auto")| Name | Escape | HTMLExample | HTMLDescription |
|---|---|---|---|
| Horizontal Tab | \t | ||
| Vertical Tab | \v | ||
| Nul char | \0 | ||
| Backspace | \b | ||
| Form feed | \f | ||
| Newline | \n | ||
| Carriage return | \r | ||
| Single quote | \’ | ||
| Double quote | \" | ||
| Backslash | \\ |
#head(tex_mml)
kable(tex_mml[tex_mml$Group == 1, 3:ncol(tex_mml)], row.names = F) %>%
kable_styling(bootstrap_options = c("striped", "hover"), full_width = T) %>%
scroll_box(width = "auto")| Name | LaTeX | MathML | HTMLExample | Output | HTMLDescription |
|---|---|---|---|---|---|
| Equation Inline |
\(...\), $...$
|
<math> hay <math xmlns=“http://www.w3.org/1998/Math/MathML” > |
$xyz$
|
Công – \(xyz\) – thức. | Hiển thị Công thức toán học trong đoạn văn. |
| Equation Display |
\[...\], $$...$$
|
<math xmlns=“http://www.w3.org/1998/Math/MathML” display=“block”> |
$$xyz$$
|
Công – \[xyz\] – thức. | Hiển thị Công thức toán học thành một khối riêng biệt. |
kable(tex_mml[tex_mml$Group == 2, 3:ncol(tex_mml)], row.names = F) %>%
kable_styling(bootstrap_options = c("striped", "hover"), full_width = T) %>%
scroll_box(width = "auto")| Name | LaTeX | MathML | HTMLExample | Output | HTMLDescription |
|---|---|---|---|---|---|
| Nomal Style |
\mathrm{…}
|
<math mathvariant=“normal”> |
$\mathrm{xyz}$
|
\(\mathrm{xyz}\) | Hiển thị Công thức toán học ở dạng bình thường (không in nghiêng). |
| Spacing |
\, \: \; \ (space) \quad \qquad
|
$f(x)=x\ +3$
|
\(f(x)=x\ +3\) | Xem thêm: https://www.overleaf.com/learn/latex/Spacing_in_math_mode | |
| Multilines |
\\
|
$f(x)=x\,+y\\ f(x)=x\quad+y$
|
\(f(x)=x\,+y\\f(x)=x\quad+y\) | ||
| Group multilines |
\begin{cases} … \end{cases}
|
$\begin{cases} x=a\\x-y=b \end{cases}$
|
\(\begin{cases}x=a\\x-y=b\end{cases}\) | ||
\left.\begin{split} … \end{split}\right
|
$\left.\begin{split} x=a\\x-y=b \end{split}\right\}$
|
\(\left.\begin{split}x=a\\x-y=b\end{split}\right\}\) | |||
| Text markup |
\text
|
$x+y=z\quad \text{(Phương trình 1)}$
|
\(x+y=z\quad\text{(Phương trình 1)}\) | ||
| Bold text |
\textbf
|
$\textbf{x}+y$
|
\(\textbf{x}+y\) |
Xem thêm mục 11.1. Formatted text và 12. Formatting mathematics symbols: https://en.wikibooks.org/wiki/LaTeX/Mathematics#Formatted_text
|
|
| Color |
\color
|
${\color{red}x} \mathbin{\color{#00ff00}-} 2$
|
\({\color{red}x}\mathbin{\color{#00ff00}-} 2\) |
Xem thêm mục 13. Color: https://en.wikibooks.org/wiki/LaTeX/Mathematics#Color
|
|
| Boxed Equations |
\boxed
|
$\boxed{x+y=z}$
|
\(\boxed{x+y=z}\) |
kable(tex_mml[tex_mml$Group == 3, 3:ncol(tex_mml)], row.names = F) %>%
kable_styling(bootstrap_options = c("striped", "hover"), full_width = T) %>%
scroll_box(width = "auto")| Name | LaTeX | MathML | HTMLExample | Output | HTMLDescription |
|---|---|---|---|---|---|
| Identifiers | <mi> | ||||
| Greek letters |
\alpha \beta
|
$\alpha$ $\beta$
|
\(\alpha\) \(\beta\) | ||
\delta \Delta
|
$\delta$ $\Delta$
|
\(\delta\) \(\Delta\) | |||
\epsilon \varepsilon
|
$\epsilon$ $\varepsilon$
|
\(\epsilon\) \(\varepsilon\) | |||
\eta \lambda
|
$\eta$ $\lambda$
|
\(\eta\) \(\lambda\) | |||
\gamma \Gamma
|
$\gamma$ $\Gamma$
|
\(\gamma\) \(\Gamma\) | |||
\pi \Pi
|
$\pi$ $\Pi$
|
\(\pi\) \(\Pi\) | |||
\phi \varphi \Phi
|
$\phi$ $\varphi$ $\Phi$
|
\(\phi\) \(\varphi\) \(\Phi\) | |||
\sigma \Sigma
|
$\sigma$ $\Sigma$
|
\(\sigma\) \(\Sigma\) | |||
\mu \theta \chi
|
$\mu$ $\theta$ $\chi$
|
\(\mu\) \(\theta\) \(\chi\) | |||
| Numbers | <mn> |
kable(tex_mml[tex_mml$Group == 4, 3:ncol(tex_mml)], row.names = F) %>%
kable_styling(bootstrap_options = c("striped", "hover"), full_width = T) %>%
scroll_box(width = "auto")| Name | LaTeX | MathML | HTMLExample | Output | HTMLDescription |
|---|---|---|---|---|---|
| Superscript |
^
|
<msup> |
Z^k
|
\(Z^k\) | Dấu mũ; lũy thừa. |
| Subscript |
_
|
<msub> |
Z_n
|
\(Z_n\) | |
| Block, Group |
{...}
|
<mrow> |
$Z_{2.n}$ $Z^{2.k}$ $Z_{2_n}^{k^k}$
|
\(Z_{2.n}\) \(Z^{2.k}\) \(Z_{2_n}^{k^k}\) |
LaTeX không phân biệt trước sau. MathML thì phân biệt và phải đặt trong tag <msubsup>.
|
$_{4}^{12}{C} ^{5+}_{2}$
|
\(_{4}^{12}{C}^{5+}_{2}\) | Thiết nghĩ, cách nhớ chung là dưới trước trên sau. | |||
| Brackets and Parentheses |
(...) [...] \{…\} |...|, \left(...\right)
|
$(\frac{x}{y})$ $[X]$ $\{Y\}$ $|Z|$
|
\((\frac{x}{y})\) \([X]\) \(\{Y\}\) \(|Z|\) | ||
$\left( \frac{x}{y} \right)$
|
\(\left(\frac{x}{y}\right)\) | ||||
| Arrows |
\to \gets
|
$\to$ $\gets$
|
\(\to\) \(\gets\) | ||
\Rightarrow \Leftarrow
|
$\Rightarrow$ $\Leftarrow$
|
\(\Rightarrow\) \(\Leftarrow\) | |||
\Leftrightarrow \rightleftharpoons
|
$\Leftrightarrow$ $\rightleftharpoons$
|
\(\Leftrightarrow\) \(\rightleftharpoons\) | |||
\uparrow \downarrow
|
$\uparrow$ $\downarrow$
|
\(\uparrow\) \(\downarrow\) | |||
\overrightarrow \overleftarrow
|
$\overrightarrow{Z}$ $\overleftarrow{Z}$
|
\(\overrightarrow{Z}\) \(\overleftarrow{Z}\) | |||
\xrightarrow \xleftarrow
|
$\xrightarrow[T]{t^0}$ $\xleftarrow[T]{t^0}$
|
\(\xrightarrow[T]{t^0}\) \(\xleftarrow[T]{t^0}\) | |||
\widehat
|
$\widehat{Z}$
|
\(\widehat{Z}\) |
kable(tex_mml[tex_mml$Group == 5, 3:ncol(tex_mml)], row.names = F) %>%
kable_styling(bootstrap_options = c("striped", "hover"), full_width = T) %>%
scroll_box(width = "auto")| Name | LaTeX | MathML | HTMLExample | Output | HTMLDescription |
|---|---|---|---|---|---|
| Operators | <mo> | ||||
| Addition |
+
|
<mo>+</mo> | |||
| Subtraction |
-
|
<mo>-</mo> | |||
| Multiplication |
\times
|
<mo>×</mo> |
$a \times b$
|
\(a \times b\) | |
| Division |
\frac{n}{d}
|
<mfrac> |
$\frac{num}{den}$
|
\(\frac{num}{den}\) |
MathML: <mfrac><mrow><mi>numerator</mi></mrow><mrow><mi>denominator</mi></mrow></mfrac>
|
| Binary operators |
\pm \mp \otimes \oplus \cup \cap
|
$\pm$ $\mp$ $\otimes$ $\oplus$ $\cup$ $\cap$
|
\(\pm\) \(\mp\) \(\otimes\) \(\oplus\) \(\cup\) \(\cap\) | ||
| Relation operators |
\equiv \sim \simeq \neq \leq \geq
|
$\equiv$ $\sim$ $\simeq$ $\neq$ $\leq$ $\geq$
|
\(\equiv\) \(\sim\) \(\simeq\) \(\neq\) \(\leq\) \(\geq\) | ||
| Symbols |
\infty \dots \cdots \vdots
|
$\infty$ $\dots$ $\cdots$ $\vdots$
|
\(\infty\) \(\dots\) \(\cdots\) \(\vdots\) | ||
| Set symbols |
\exists \nexists \forall \subset \subseteq \supset \supseteq \in \notin
|
$\exists$ $\nexists$ $\forall$ $\subset$ $\subseteq$ $\supset$ $\supseteq$ $\in$ $\notin$
|
\(\exists\) \(\nexists\) \(\forall\) \(\subset\) \(\subseteq\) \(\supset\) \(\supseteq\) \(\in\) \(\notin\) |
kable(tex_mml[tex_mml$Group == 6, 3:ncol(tex_mml)], row.names = F) %>%
kable_styling(bootstrap_options = c("striped", "hover"), full_width = T) %>%
scroll_box(width = "auto")| Name | LaTeX | MathML | HTMLExample | Output | HTMLDescription |
|---|---|---|---|---|---|
| Square root |
\sqrt
|
<msqrt> |
$\sqrt Z$ $\sqrt{\frac{n}{d}}$
|
\(\sqrt Z\) \(\sqrt{\frac{n}{d}}\) | Căn bậc 2. |
| nth root |
\sqrt[n]
|
<mroot> |
$\sqrt[3] Z$ $\sqrt[4]{\frac{n}{d}}$
|
\(\sqrt[3] Z\) \(\sqrt[4]{\frac{n}{d}}\) | Căn bậc n. |
| Limits |
\lim\limits_{...}
|
<munder> |
$\lim\limits _{x\to\infty} {f(x)}$
|
\(\lim\limits_{x\to\infty}{f(x)}\) |
MathML:<math><mrow><munder><mo>lim</mo><mrow><mi>x</mi><mo>→</mo><mi>∞</mi></mrow></munder><mrow><mi>f</mi><mo>(</mo><mi>x</mi><mo>)</mo></mrow></mrow></math>
|
| Sums, Products |
\sum \prod
|
$\sum$ $\prod$
|
\(\sum\) \(\prod\) | ||
$\displaystyle\sum _{n=1}^{\infty} 2^{-n}$
|
\(\displaystyle\sum_{n=1}^{\infty}2^{-n}\) | ||||
| Integrals |
\int \oint
|
$\int$ $\oint$
|
\(\int\) \(\oint\) | ||
kable(tex_mml[tex_mml$Group == 7, 3:ncol(tex_mml)], row.names = F) %>%
kable_styling(bootstrap_options = c("striped", "hover"), full_width = T) %>%
scroll_box(width = "auto")| Name | LaTeX | MathML | HTMLExample | Output | HTMLDescription |
|---|---|---|---|---|---|
| Matrix |
pmatrix bmatrix vmatrix
|
$\begin{pmatrix}0 & 1 \\ 2 & 3\end{pmatrix}$ \(\begin{pmatrix}0 & 1 \\ 2 & 3\end{pmatrix}\)
kable(tex_mml[tex_mml$Group == 8, 3:ncol(tex_mml)], row.names = F) %>%
kable_styling(bootstrap_options = c("striped", "hover"), full_width = T) %>%
scroll_box(width = "auto")| Name | LaTeX | MathML | HTMLExample | Output | HTMLDescription |
|---|---|---|---|---|---|
| Chemistry formulae |
\ce
|
$\ce{SO4^2- +Ba^2+ ->BaSO4 v}$
|
\(\ce{SO4^2-+Ba^2+->BaSO4 v}\) | ||
$\ce{SO}_4^{2-} \ce{+Ba^2+ ->BaSO4 v}$
|
\(\ce{SO}_4^{2-}\ce{+Ba^2+->BaSO4 v}\) | Kết hợp Công thức dạng Hóa học và dạng Toán học để biểu diễn đẹp hơn. |
$\ce{SO4^2-+Ba^2+->BaSO4 v}$ \(\ce{SO4^2-+Ba^2+->BaSO4 v}\)
$\ce{SO}_4^{2-}\ce{+Ba^2+->BaSO4 v}$ \(\ce{SO}_4^{2-}\ce{+Ba^2+->BaSO4 v}\)