LaTeX 数学模式错误

LaTeX 数学模式错误

我必须遵循代码:

\begin{align*}
r^2  = \left[\frac  {23604,7 - \frac{1}{22} \cdot 253 \cdot 1942.5}  {\sqrt{[3795 - \frac{1}{22} \cdot 253^2]  [173348.4 - \frac{1}{22} \cdot 1942.5^2]  }} \right]^2 \\ \\

r^2  = \left[\frac{1265.95}{\sqrt{885.5 \cdot 1834.51}} \right]^2 \\ \\

r^2  = \left[\frac{1265.95}{\sqrt{1624458.2}} \right]^2 \\ \\

r^2  = \left[\frac{1265.95}{1274.54} \right]^2 \\ \\

r^2  = [0.99356]^2 = 0.9866
\end{align*}

并收到错误:

! 段落在 \align* 完成之前结束。

! 缺少插入 $。

还有一些...有人能发现错误吗?:<

答案1

一些代码改进:

\documentclass{article}

\usepackage{amsmath}
\usepackage[
  locale=DE  % comma as decimal separator
%  locale=UK  % full stop as decimal separator
]{siunitx}

\begin{document}

\begin{align*}
  r^{2}
  &= \left[\frac{\num{23604.7} - \frac{1}{22} \cdot 253 \cdot \num{1942.5}}{\sqrt{[3795 - \frac{1}{22} \cdot 253^2] [\num{173348.4} - \frac{1}{22} \cdot \num{1942.5}^{2}]}}\right]^{2}\\
  &= \left[\frac{\num{1265.95}}{\sqrt{\num{885.5} \cdot \num{1834.51}}}\right]^{2}\\
  &= \left[\frac{\num{1265.95}}{\sqrt{\num{1624458.2}}}\right]^{2}\\
  &= \left[\frac{\num{1265.95}}{\num{1274.54}}\right]^{2}\\
  &= \num{0.99356}^{2}\\
  &= \num{0.9866}
\end{align*}

\end{document}

输出

答案2

推荐一个解决方案,只是为了好玩!

\documentclass[preview,border=12pt,varwidth]{standalone}% change this line back to your own document class (article)
\usepackage{amsmath}
\begin{document}
\abovedisplayskip=0pt\relax% remove this line in  your production
\begin{align*}
r^2  
&= \left(\frac{23604.7 -\frac{1}{22} \cdot 253 \cdot 1942.5}{\sqrt{(3795 -\frac{1}{22} \cdot 253^2)(173348.4 -\frac{1}{22} \cdot 1942.5^2)}}\right)^2 \\
&= \left(\frac{1265.95}{\sqrt{885.5 \cdot 1834.51}} \right)^2 \\
&= \left(\frac{1265.95}{\sqrt{1624458.2}} \right)^2 \\
&= \left(\frac{1265.95}{1274.54} \right)^2\\
&= 0.99356^2 \\
&= 0.9866
\end{align*}
\end{document}

在此处输入图片描述

相关内容