owned this note
owned this note
Published
Linked with GitHub
# LaTeX
###### tags: `LaTeX`
[TOC]
<style>
.blue {
color: #2196F3;
}
.teal {
color: #009688;
}
.pink {
color: #e91e63;
}
.indigo {
color: #3f51b5;
}
.red {
color: #f44336;
}
.green {
color: #4CAF50;
}
.center {
text-align: center;
}
</style>
## 既有/預定/設計 - 問題
- widget heigh/width setting
- 單元素: SingleChildCharWidget,所有`最低層級的元素`必須繼承,讓所有擁有多子元素使用
- 字型可以用 `Cambria Math`? (License?) 目前先暫時用預設的字型
- <b class="red">未讀章節</b>:
- Aligned equations 及之後章節
- <b class="red">需讀章節</b>:
- Aligned equations
- Additional decorations
- $$
## 根據MathJax列出語法 & 界定層級
語法參考自 [MathJax](https://math.meta.stackexchange.com/questions/5020/mathjax-basic-tutorial-and-quick-reference)
### First Level (最高)
- Group: `{}` 用作分組的大括弧 ${1234}$
- 反斜線: `\`
### Second Level
- `\frac{...}{...}`
$\frac{1}{2}$
- 其他寫法:
- $\frac ab$ $\frac abc$ -> 不採用
- ${a+1 \over a+2}$ -> 不採用
- $\cfrac{a}{b}$ -> 看不懂不採用
(useful for continued fractions)
- Matrices __暫時__ 不實現
$$
\begin{matrix}
1 & x & x^2 \\
1 & y & y^2 \\
1 & z & z^2 \\
\end{matrix}
$$
$$
\begin{pmatrix}
1 & x \\
1 & y \\
\end{pmatrix}
$$
$$
\begin{bmatrix}
1 & x \\
1 & y \\
\end{bmatrix}
$$
$$
\begin{Bmatrix}
1 & x \\
1 & y \\
\end{Bmatrix}
$$
$$
\begin{vmatrix}
1 & x \\
1 & y \\
\end{vmatrix}
$$
$$
\begin{Vmatrix}
1 & x \\
1 & y \\
\end{Vmatrix}
$$
$\cdots \ddots \vdots$
$$ \left[
\begin{array}{cc|c}
1&2&3\\
4&5&6
\end{array}
\right]
$$
$$
\begin{pmatrix}
a & b\\
c & d\\
\hline
1 & 0\\
0 & 1
\end{pmatrix}
$$
`\bigl(\begin{smallmatrix} ... \end{smallmatrix}\bigr)`
$\bigl( \begin{smallmatrix} a & b \\ c & d \end{smallmatrix} \bigr)$
- 上標、下標 superscripts and subscripts
$_{i=0}^n$
- 固定使用 __大括弧__ `{...}`
- 前後可調換 `^{...}_{...}`、`_{...}^{...}`
- 二選一、或同時使用
- Example:
- $10^10$、$10^{10}$
- ${x^y}^z$、$x^{y^z}$
- $x_i^2$、$x_{i^2}$
- Radical signs(根號): $\sqrt[3]{\frac xy}$、$\sqrt{x^3}$、${x}^{1/2}$
- Some special functions
- $lim$ $\lim_{x\to 0}$
lim 的下標要在 lim底下,而不是右下-> 需實作
- $\sin、sin、\cos、tan、ln$
有斜線 使用一般字體、沒斜線 使用math風格的字體 -> 暫時不實作
- $max$
- Accents and diacritical marks:
- $\hat{x}、\hat{xxxxx}、\widehat{x}、\widehat{xxxxxx}$
- $\bar{xxxxxx}、\overline{xxx}、\vec{xxxxxxxxx}、\overrightarrow{xxxxxx}、\underline{xxxxx}$
- $\dot{x} \ddot{x}$
- Plain text: $\text{ssss}sss$ -> 不實現
==應用、或不特別實現之語法==
- 自適應括弧(大中小括弧),括弧會隨表達式改變大小 (adjust automatically to the formula)
$(\frac{\sqrt x}{y^3})$ => $\left(\frac{\sqrt x}{y^3}\right)$
`\left( \right)` apply to all the following sorts of parentheses
$\left(a+b\right)$
> `() [] \{\} || \vert \Vert \langle \rangle \lceil \rceil \lfloor \rfloor`
$\langleㄌㄌㄎ\rangle$
$\lceil{x}\rceil$
$\lfloor x \rfloor$
$\middle$ => HackMD 不能用
----
If manual size adjustments are required: $\Biggl(\biggl(\Bigl(\bigl((x)\bigr)\Bigr)\biggr)\Biggr)$
- `\log` $\log_2$、$log_2$
### Third level (最低)
標準: 單純符號/字元
- Greek letters:
- $\alpha, \beta, …, \omega$
- flutter 顯示方式 - ref1: [charcode-library](https://api.flutter.dev/flutter/charcode/charcode-library.html)
- 直接複製貼上 Α, α, Ω, ω, ... [wiki](https://en.wikipedia.org/wiki/Greek_alphabet)
- curly braces: 因為大括弧被用作語法,使用反斜線接大括弧`\{`、`\}`
- Sums and integrals:
- 顯示結果跟直接複製貼上符號一樣: $\prod \int \bigcup \bigcap \iint \iiint \idotsint$
- $sigma\ \sum$
如果是兩個`$`字號,上下標會在sigma上下出現(__暫時不實現__),出現在旁邊即可。
$\sum_{i=0}^n$、$\sum_{i=0}^\infty i^2$
$$\sum_{i=0}^n i^2 = \frac{(n^2+n)(2n+1)}{6}$$
- 垂直線: | (直接用鍵盤打的)、$\vert$、$\Vert$ (__這是一個符號、雙槓__)
- 看作字元、不隨表達式變長
- $\vert{\frac{1}{\frac{2}{3}}}\vert$
- Fonts
- blackboard bold
- `\mathbb \Bbb` -> HackMD 不支援
- [數學意義](https://oeis.org/wiki/Blackboard_bold)
- 還有很多其他字型,暫時不新增
- 語法
- `\Bbb` -> Bb 代表字型 b 代表顯示字母
- `\Bb{...}` -> 可將字串用同一種字型
- $\frac{ss}{ss}$
- Special symbols and notations
- ${n+1 \choose 2k}$ -> 不實現
- 還有很多符號,大部分屬於最低level
- Special characters used for MathJax interpreting can be escaped using the `\` character:
- `\$` (HackMD 不支援), `\{` {, `\_` _, etc. If you want `\` itself, you should use `\backslash` ∖, because `\\` is for a new line.
==應用、或不特別實現之語法==
- Degree symbol 溫度/角度符號: $45^\text{o}、x^\circ$
## 解析語法
解析時,依此表解析
|層級|語法|例子|解釋|備註|
|:----|:----|:----|:----|:----|:----|:----|
|1|`{}`|-|分組用||
|2|`\frac{ }{ }`|$\frac{1}{2}$|分數||
||`\begin{}`<br/>`1 & 2 \\`<br/>`\end{}`|$\begin{matrix} 2 & 3 \\ 4 & 5\\ \end{matrix}$|矩陣|暫時不實現|
||`_{}^{}`<br/>`^{}_{}`|$x^{1}_{2}$|上標、下標|1. 上下標屬於通一個 widget<br/>2. 二選一、或同時使用 <br/>3. 固定使用大括號|
||`\sqrt[n]{...}`|$\sqrt[3]{2}$|開 n 次方根|可以不給次方
||`\lim{...}`|$\lim_{x\to 0}$|極限|需更新,把lim的下標移至底部|
||`\hat{x}`<br/>`\widehat{x}`|$\hat{xx}$<br/>$\widehat{xx}$||不實做`\hat`|
||`\overline{xxx}`|$\overline{xxx}$|上劃線|不實做`\bar`|
||`\underline{x}`|$\underline{xx}$|底線||
||`\overrightarrow{x}`|$\overrightarrow{xx}$|向量|不實做`\vec`|
|3|`\` + symbol name|-|符號|
解析一些注意事項
- 因在矩陣`\begin ~ \end` 會用到 `&`, 在矩陣中,
如果要在矩陣區塊內顯示 `&` ,須加上反斜線 `\&`,
如果不是在矩陣區塊(begin~end)內,沒有反斜線即可正常顯示`&`
- 如果是空白,僅用作分隔語法,如要顯示空白,使用`\ `(反斜線 + 空白)
- `\lim_{...}` 原本是長這樣,改成這樣`\lim{...}`
暫時不實現
- $\dot{x} \ddot{x}$
- 上限、下限,⌈x⌉、⌊x⌋,如果直接是字元不解析,其他依照規則(與原本MathJax不一樣,請注意): `\ceil{...}` `\floor{...}`
最低level,`\keyword → 單一符號`清單:
-
## Grammar
`{ }` | `\K` | `_{ }^{ }` | `^{ }_{ }` | `^{ }` | `_{ }` |
## 解析程式
## 問題
- 不處理換行字元`\n`
## Flutter Widgets 設計
最上層 TexView
- 參數
- textStyle: 傳給子widgets,共用style,也用 fontSize 做各種計算 (每一層皆要有)
-
## 附錄: 希臘字母對應字母
|大寫|小寫|拉丁字母|
|:--|:---|:-----|
|Α| α| Alpha|
|Β| β| Beta|
|Γ| γ| Gamma|
|Δ| δ| Delta|
|Ε| ε| Epsilon|
|Ζ| ζ| Zeta|
|Η| η| Eta|
|Θ| θ| Theta|
|Ι| ι| Iota|
|Κ| κ| Kappa|
|Λ| λ| Lambda|
|Μ| μ| Mu|
|Ν| ν| Nu|
|Ξ| ξ| Xi|
|Ο| ο| Omicron|
|Π| π| Pi|
|Ρ| ρ| Rho|
|Σ| σ| Sigma|
|Τ| τ| Tau|
|Υ| υ| Upsilon|
|Φ| φ| Phi|
|Χ| χ| Chi|
|Ψ| ψ| Psi|
|Ω| ω| Omega|
複製用
Α α Alpha
Β β Beta
Γ γ Gamma
Δ δ Delta
Ε ε Epsilon
Ζ ζ Zeta
Η η Eta
Θ θ Theta
Ι ι Iota
Κ κ Kappa
Λ λ Lambda
Μ μ Mu
Ν ν Nu
Ξ ξ Xi
Ο ο Omicron
Π π Pi
Ρ ρ Rho
Σ σ Sigma
Τ τ Tau
Υ υ Upsilon
Φ φ Phi
Χ χ Chi
Ψ ψ Psi
Ω ω Omega
Map specialCharMap = {
'Alpha':'Α',
'alpha':'α',
'Beta':'Β',
'beta':'β',
'Gamma':'Γ',
'gamma':'γ',
'Delta':'Δ',
'delta':'δ',
'Epsilon':'Ε',
'epsilon':'ε',
'Zeta':'Ζ',
'zeta':'ζ',
'Eta':'Η',
'eta':'η',
'Theta':'Θ',
'theta':'θ',
'Iota':'Ι',
'iota':'ι',
'Kappa':'Κ',
'kappa':'κ',
'Lambda':'Λ',
'lambda':'λ',
'Mu':'Μ',
'mu':'μ',
'Nu':'Ν',
'nu':'ν',
'Xi':'Ξ',
'xi':'ξ',
'Omicron':'Ο',
'omicron':'ο',
'Pi':'Π',
'pi':'π',
'Rho':'Ρ',
'rho':'ρ',
'Sigma':'Σ', // Σ∑
'sigma':'σ',
'Tau':'Τ',
'tau':'τ',
'Upsilon':'Υ',
'upsilon':'υ',
'Phi':'Φ',
'phi':'φ',
'Chi':'Χ',
'chi':'χ',
'Psi':'Ψ',
'psi':'ψ',
'Omega':'Ω',
'omega':'ω',
};