我一直收到编译错误 >file ends while scaning use of \frac。我看不到任何缺失的 {},所以我不知道该怎么办。
\documentclass[]{scrreprt}
\usepackage{geometry}
\begin{document}
Molar Mass of Nitrogen
\begin{math}
\\ Bulb Volume: 213.7 cm^{3} = .2317 L
\\ Internal bulb pressure: 20 inHg = 508 mmHg = .508 bar
\\ Temperature: 294.2 K
\\ M = \frac{\rho}{P}RT
\\ \rho = \frac{.158 g}{.2137 L} = .739\frac{g}{L}
\\ M = \frac{.739 \frac{g}{L}}{.508 bar} * .083144 \frac{L*bar}{mol*K} * 294.2 K = 35.6 \frac{g}{mol}
\\ Calculation of Volume by van der Waals Equation with Successive Approximations
\\ V = \frac{nRT}{P + \frac{n^{2}a}{V^{2}}} + nb
\\ a = 1.408 \frac{L^{2}*bar}{mol^{2}}
b = .03913 L
\\ V \approx \frac{nRT}{P} + nb \approx \frac{nRT}{P}
\\ n = \frac{m}{M} = \frac{.158 g}{21.35 \frac{g}{mol}} = 7.4*10^{-3} mol
\\ V = \frac{7.4*10^{-3} mol * .083144 \frac{L*bar}{mol*K} * 294.2 K}{.508 bar} = .2138 L
\\ V = \frac{7.4*10^{-3} mol * .083144 \frac{L*bar}{mol*K} * 294.2 K}{.508 bar
+ \frac{(7.4*10^{-3} mol)^{2}*1.408 \frac{L^{2}*bar}{mol^{2}}} {(.2138 L)^{2}}
+ 7.4*10^{-3} mol * .03913 L = .2137 L
\end{math}
\end{document}
这是本科化学实验室的计算附录。我认为花时间学习 LaTeX 是值得的。如果我能解决这些编译错误,用 LaTeX 进行计算的速度已经比用 Word 快得多了。
相关日志文本:
失控参数?{.508 bar + \frac {(7.4*10^{-3} mol)^{2}*1.408 \frac {L^{2}*bar}{mol^\ETC。!扫描 \frac 的使用时文件结束。
答案1
您不需要一个大型数学环境。此外,使用siunitx
包来排版您的单位也是一个好主意。以下是示例:
\documentclass[]{scrreprt}
\usepackage{amsmath}
\usepackage[per-mode=symbol,detect-weight]{siunitx}
\DeclareSIUnit{\inHg}{inHg}
\DeclareSIUnit{\mmHg}{mmHg}
\begin{document}
\noindent
Molar Mass of Nitrogen\\
Bulb Volume: $\SI{13.7}{\centi\meter^{3}} = \SI{0.2317}{\litre}$\\
Internal bulb pressure: $\SI{0}{\inHg} = \SI{508}{\mmHg} = \SI{0.508}{\bar}$\\
Temperature: \SI{294.2}{\kelvin}\\[0.5\baselineskip]
$M = \dfrac{\rho}{P}RT$ \\[0.5\baselineskip]
$\rho = \dfrac{\SI{0.158}{\gram}}{\SI{0.2137}{\litre}} = \SI{0.739}{\gram\per\litre}$ \\[0.5\baselineskip]
$M = \dfrac{\SI{0.739}{\gram\per\litre}}{\SI{0.508}{\bar}} * \SI{0.083144}{\litre\bar\per\mole\per\kelvin} * \SI{294.2}{\kelvin} = \SI{35.6}{\gram\per\mol}$\\[0.5\baselineskip]
Calculation of Volume by van der Waals Equation with Successive Approximations \\[0.5\baselineskip]
$V = \dfrac{nRT}{P + \dfrac{n^{2}a}{V^{2}}} + nb$\\[0.5\baselineskip]
$a = \SI{1.408}{\square\litre\bar\per\mol^{2}}$\\[0.5\baselineskip]
$b = \SI{0.03913}{\litre}$\\[0.5\baselineskip]
$V \approx \dfrac{nRT}{P} + nb \approx \dfrac{nRT}{P}$\\[0.5\baselineskip]
$n = \dfrac{m}{M} = \dfrac{\SI{0.158}{\gram}}{\SI{21.35}{\gram\per\mol}} = 7.4*10^{-3}\si{\mol}$\\[0.5\baselineskip]
$V = \dfrac{7.4*10^{-3}\si{\mol} * \SI{0.083144}{\litre\bar\per\mol\per\kelvin} * \SI{0294.2}{\kelvin}}{\SI{0.508}{\bar}} = \SI{0.2138}{\litre}$\\[0.5\baselineskip]
\begin{flalign*}
V &= \dfrac{7.4*10^{-3}\si{\mol} * \SI{0.083144}{\litre\bar\per\mol\per\kelvin} * \SI{294.2}{\kelvin}}{\SI{0.508}{\bar}}&& \\
& \quad + \dfrac{(7.4*10^{-3}\si{\mol})^{2}* \SI{1.408}{\square\litre\bar\per\square\mol}} {(\SI{0.2138}{\litre})^{2} + 7.4*10^{-3}\si{\mol} * \SI{0.03913}{litre}} &&\\
&= \SI{0.2137}{\litre}
\end{flalign*}
\end{document}
有关详细信息,您可以从终端texdoc mathmode
texdoc amsldoc
查看。texdoc siunitx
顺便说一句,我也会使用\cdot
或\times
来表示乘法,但不会*
。这一点,在上面的例子中我没有改变。
答案2
.508 bar
(正如已经指出的那样,编译失败的直接原因是在最终计算中第一个后面缺少一个右花括号V
。)
除了使用siunitx
包的功能来处理单位格式之外,我还将使用align*
环境来排版计算序列。使用这样的环境将使您不必通过诸如 之类的指令来微调连续行之间的距离\\[2ex]
。(如果您需要在计算序列中的某处插入分页符,请在\allowdisplaybreaks
之前插入指令\begin{align*}
。)
\documentclass[]{scrreprt}
\usepackage{amsmath}
\usepackage[per-mode=symbol,
detect-weight,
group-digits=false]
{siunitx}
\DeclareSIUnit{\inHg}{inHg} % borrowed from Harish's answer...
\DeclareSIUnit{\mmHg}{mmHg}
\begin{document}
\noindent
$\begin{array}{@{}l}
\text{Molar Mass of Nitrogen}\\
\text{Bulb Volume: } \SI{13.7}{\centi\meter^{3}} = \SI{0.2317}{\liter}\\
\text{Internal bulb pressure: } \SI{0}{\inHg} = \SI{508}{\mmHg} = \SI{0.508}{\bar}\\
\text{Temperature: } \SI{294.2}{\kelvin}
\end{array}$
\begin{align*}
M &= \frac{\rho}{P}RT \\
\rho &= \frac{\SI{0.158}{\gram}}{\SI{0.2137}{\liter}} = \SI{0.739}{\gram\per\liter} \\
M &= \frac{\SI{0.739}{\gram\per\liter}}{\SI{0.508}{\bar}} * \SI{0.083144}{\liter\bar\per\mole\per\kelvin} * \SI{294.2}{\kelvin} = \SI{35.6}{\gram\per\mol}\\
\intertext{Calculation of volume by van der Waals equation with successive approximations}
V &= \frac{nRT}{P + \frac{n^{2}a}{V^{2}}} + nb\\
a &= \SI{1.408}{\square\liter\bar\per\mol^{2}}\\
b &= \SI{0.03913}{\liter}\\
V &\approx \frac{nRT}{P} + nb \approx \frac{nRT}{P}\\
n &= \frac{m}{M} = \frac{\SI{0.158}{\gram}}{\SI{21.35}{\gram\per\mol}} = 7.4*10^{-3}\si{\mol}\\
V &= \frac{7.4*10^{-3}\si{\mol} * \SI{0.083144}{\liter\bar\per\mol\per\kelvin} * \SI{0294.2}{\kelvin}}{\SI{0.508}{\bar}} = \SI{0.2138}{\liter}\\
V &= \frac{7.4*10^{-3}\si{\mol} * \SI{0.083144}{\liter\bar\per\mol\per\kelvin} * \SI{294.2}{\kelvin}}{\SI{0.508}{\bar}} \\
&\quad + \frac{(7.4*10^{-3}\si{\mol})^{2}* \SI{1.408}{\square\liter\bar\per\square\mol}} {(\SI{0.2138}{\liter})^{2} + 7.4*10^{-3}\si{\mol} * \SI{0.03913}{\liter}} \\
&= \SI{0.2137}{\liter}
\end{align*}
\end{document}