问题描述
我是 Katex/Latex 的新手,我尝试过不同的方法,但我无法获得正确的输出。我曾尝试使用 katex.org 的自动渲染功能和以下分隔符,但未正确渲染换行符和符号。
{ left: '$$',right: '$$',display: true },{ left: '$',right: '$',display: true }
我想要的输出:https://prnt.sc/yxfanc 当前输出:https://prnt.sc/yxfdzg
我无法修改字符串,因为字符串来自 db。
$$0.01$$ mol of $$AgNO_3$$ is added to $$1$$ L of a solution which is $$0.1\\ M$$ $$Na_2CrO_4$$ and $$0.005\\ M$$ in $$NaIO_3$$. Calculate  $$[Ag^{\\oplus}],[IO_3^{\\circleddash}]$$ and $$[CrO_4^{2-}]$$. <div>$$K_{sp}\\,Ag_2CrO_4$$ and $$AgIO_3$$ are $$10^{-8}$$ and $$10^{-13}$$ respectively.</div>
知道哪里出了问题吗?
解决方法
首先,欢迎使用 LaTeX!最初的时刻很复杂,但一旦你理解了逻辑,一切都会好起来的。
在您的示例中,\
和 \\
之间存在混淆。在第一种情况下,它表示一个命令跟在反斜杠后面,在另一种情况下它是一个换行符(我们可以看到 \\
的第二个反斜杠是换行命令)。
所以我们会有 $$IO_3^{\circleddash}$$
而不是 $$IO_3^{\circleddash}$$
。
此外,还有一些库可以让您以正确的形式编写国际系统的单位。事实上,在文档中有时会在别处写成“mol”和“M”。
这是一个最小的例子:
\documentclass{article}
\usepackage{amsmath}
\usepackage{SIunits}
\begin{document}
\noindent
$0.01 \mole$ of $AgNO_3$ is added to $1 \liter$ of a solution which is $0.1 \mole$
in $Na_2CrO_4$ and $0.005 \mole$ in $NaIO_3$.
\\
Calculate $[Ag^{\oplus}],[IO_3^{\ominus}]$ and $[CrO_4^{2-}]$.
\\
$K_{sp} Ag_2CrO_4$ and $AgIO_3$ are $10^{-8}$ and $10^{-13}$ respectively.
\end{document}