CSDN公式左对齐,以及遇到的问题及解决方法

CSDN插入公式左对齐方法:

h θ ( x ) = θ 0 + θ 1 x 1 + θ 2 x 2 \begin{aligned} h_{\theta}\left( x \right) =\theta _0+\theta _1x_1+\theta _2x_2 \end{aligned} hθ(x)=θ0+θ1x1+θ2x2
正常情况下,如上面所示已经实现了左对齐,源码为:

$\begin{aligned}
h_{\theta}\left( x \right) =\theta _0+\theta _1x_1+\theta _2x_2
\end{aligned}$

h θ ( x ) = θ 0 + θ 1 x 1 + θ 2 x 2 \begin{aligned} h_{\theta}\left( x \right) =\theta _0+\theta _1x_1+\theta _2x_2 \end{aligned} hθ(x)=θ0+θ1x1+θ2x2
正常情况下,如上面所示已经实现了中心对齐,源码为:

$$\begin{aligned}
h_{\theta}\left( x \right) =\theta _0+\theta _1x_1+\theta _2x_2
\end{aligned}$$

区别为左对齐为$ 中心对齐为 $$

但是理想很丰满,现实很骨感

实际使用中遇到的问题:

问题描述:我从Axmath直接复制文本代码,也是LaTeX格式的,但是按照上面操作时,会出现右对齐的现象,如下面所示:
p ( ε ( i ) ) = 1 2 π σ exp ⁡ ( − ( ε ( i ) ) 2 2 σ 2 ) ∵ y ( i ) = θ T x ( i ) + ε ( i ) p ( y ( i ) ∣ x ( i ) ; θ ) = 1 2 π σ exp ⁡ ( − ( y ( i ) − θ T x ( i ) ) 2 2 σ 2 ) \begin{aligned}p\left( \varepsilon ^{\left( i \right)} \right) =\frac{1}{\sqrt{2\pi \sigma}}\exp \left( -\frac{\left( \varepsilon ^{\left( i \right)} \right) ^2}{2\sigma ^2} \right) \\\\\because y^{\left( i \right)}=\theta ^Tx^{\left( i \right)}+\varepsilon ^{\left( i \right)}\\\\p\left( y^{\left( i \right)}|x^{\left( i \right)};\theta \right) =\frac{1}{\sqrt{2\pi \sigma}}\exp \left( -\frac{\left( y^{\left( i \right)}-\theta ^Tx^{\left( i \right)} \right) ^2}{2\sigma ^2} \right) \\\\ \end{aligned} p(ε(i))=2πσ 1exp(2σ2(ε(i))2)y(i)=θTx(i)+ε(i)p(y(i)x(i);θ)=2πσ 1exp(2σ2(y(i)θTx(i))2)
源码为:

$\begin{aligned}
p\left( \varepsilon ^{\left( i \right)} \right) =\frac{1}{\sqrt{2\pi \sigma}}\exp \left( -\frac{\left( \varepsilon ^{\left( i \right)} \right) ^2}{2\sigma ^2} \right) \\\\
\because y^{\left( i \right)}=\theta ^Tx^{\left( i \right)}+\varepsilon ^{\left( i \right)}\\\\
p\left( y^{\left( i \right)}|x^{\left( i \right)};\theta \right) =\frac{1}{\sqrt{2\pi \sigma}}\exp \left( -\frac{\left( y^{\left( i \right)}-\theta ^Tx^{\left( i \right)} \right) ^2}{2\sigma ^2} \right) \\\\
\end{aligned}$

找遍全网,最后在我的误操作下勉强解决了这个问题,只不过最后会多个字符.:
p ( ε ( i ) ) = 1 2 π σ exp ⁡ ( − ( ε ( i ) ) 2 2 σ 2 ) ∵ y ( i ) = θ T x ( i ) + ε ( i ) p ( y ( i ) ∣ x ( i ) ; θ ) = 1 2 π σ exp ⁡ ( − ( y ( i ) − θ T x ( i ) ) 2 2 σ 2 ) . \\ p\left( \varepsilon ^{\left( i \right)} \right) =\frac{1}{\sqrt{2\pi \sigma}}\exp \left( -\frac{\left( \varepsilon ^{\left( i \right)} \right) ^2}{2\sigma ^2} \right) \\\\\because y^{\left( i \right)}=\theta ^Tx^{\left( i \right)}+\varepsilon ^{\left( i \right)}\\\\p\left( y^{\left( i \right)}|x^{\left( i \right)};\theta \right) =\frac{1}{\sqrt{2\pi \sigma}}\exp \left( -\frac{\left( y^{\left( i \right)}-\theta ^Tx^{\left( i \right)} \right) ^2}{2\sigma ^2} \right) \\\\ \\. p(ε(i))=2πσ 1exp(2σ2(ε(i))2)y(i)=θTx(i)+ε(i)p(y(i)x(i);θ)=2πσ 1exp(2σ2(y(i)θTx(i))2).
源码为:

$\\
p\left( \varepsilon ^{\left( i \right)} \right) =\frac{1}{\sqrt{2\pi \sigma}}\exp \left( -\frac{\left( \varepsilon ^{\left( i \right)} \right) ^2}{2\sigma ^2} \right) \\\\
\because y^{\left( i \right)}=\theta ^Tx^{\left( i \right)}+\varepsilon ^{\left( i \right)}\\\\
p\left( y^{\left( i \right)}|x^{\left( i \right)};\theta \right) =\frac{1}{\sqrt{2\pi \sigma}}\exp \left( -\frac{\left( y^{\left( i \right)}-\theta ^Tx^{\left( i \right)} \right) ^2}{2\sigma ^2} \right) \\\\
\\.$

最后为了公式看起来更加清晰,在行与行之间加一行空白行,效果如下:
p ( ε ( i ) ) = 1 2 π σ exp ⁡ ( − ( ε ( i ) ) 2 2 σ 2 )   ∵ y ( i ) = θ T x ( i ) + ε ( i )   p ( y ( i ) ∣ x ( i ) ; θ ) = 1 2 π σ exp ⁡ ( − ( y ( i ) − θ T x ( i ) ) 2 2 σ 2 ) . \\ p\left( \varepsilon ^{\left( i \right)} \right) =\frac{1}{\sqrt{2\pi \sigma}}\exp \left( -\frac{\left( \varepsilon ^{\left( i \right)} \right) ^2}{2\sigma ^2} \right) \\\\ ~\\ \because y^{\left( i \right)}=\theta ^Tx^{\left( i \right)}+\varepsilon ^{\left( i \right)}\\\\ ~\\ p\left( y^{\left( i \right)}|x^{\left( i \right)};\theta \right) =\frac{1}{\sqrt{2\pi \sigma}}\exp \left( -\frac{\left( y^{\left( i \right)}-\theta ^Tx^{\left( i \right)} \right) ^2}{2\sigma ^2} \right) \\\\ \\. p(ε(i))=2πσ 1exp(2σ2(ε(i))2) y(i)=θTx(i)+ε(i) p(y(i)x(i);θ)=2πσ 1exp(2σ2(y(i)θTx(i))2).
源码为:

$\\
p\left( \varepsilon ^{\left( i \right)} \right) =\frac{1}{\sqrt{2\pi \sigma}}\exp \left( -\frac{\left( \varepsilon ^{\left( i \right)} \right) ^2}{2\sigma ^2} \right) 
\\\\
~\\
\because y^{\left( i \right)}=\theta ^Tx^{\left( i \right)}+\varepsilon ^{\left( i \right)}\\\\
~\\
p\left( y^{\left( i \right)}|x^{\left( i \right)};\theta \right) =\frac{1}{\sqrt{2\pi \sigma}}\exp \left( -\frac{\left( y^{\left( i \right)}-\theta ^Tx^{\left( i \right)} \right) ^2}{2\sigma ^2} \right) \\\\
\\.$

~\为显示空白行

你可能感兴趣的:(其他)