markdown多行公式對齊
阿新 • • 發佈:2019-01-03
http://sparkandshine.net/latex-use-notes-mathematical-formula/
1. 公式多行多列對齊
當討論一個函式因自定義變數取值不同而表達不同時,通常是寫一個大括號,用cases完成,原始碼如下:
- \begin{equation}
- \begin{cases}
- f(x)=\frac{1}{12} \cdot x \quad g(x)= \frac{1}{24} \cdot x,& x<12 \\
- f(x)=1 \quad g(x)= \frac{1}{8} \cdot x -1,&12 \le x <16 \\
- f(x)=
- \end{cases}
- \end{equation}
結果如下:
你也看到了,上面的等式不夠美觀,g(x)不對齊。期待的結果是這樣的:
原始碼如下:
- \begin{equation}
- \left\{\begin{aligned}
- f(x)&=\tfrac{1}{12} \cdot r,& g(x)&= \tfrac{1}{24} \cdot x,& x&<12 \\
- f(x)&=1,&g(x)&= \tfrac{1}{8} \cdot x
- f(x)&=1,&g(x)&=1,& x &\ge 16
- \end{aligned}
- \right.
- \end{equation}