化学式の分数が機能しない

化学式の分数が機能しない

私はボイルズ方程式を LaTeX レポートに入力しようとしていますが、すべて正常に見えます。これは私が通常方程式をコード化する方法です。

\begin{gather}

n_{CH_4}=\frac{COD}{64\frac{g}{mol}}

\intertext{Where:}

\begin{tabular}

    $n_{CH_4}$ is the amount of molecular methane in $mol$\\

    $COD$ is experimentally obtained value 
of chemical oxygen demand

\end{tabular}\nonumber

\label{eq: n}

\end{gather}

これはこんな感じです

ここに画像の説明を入力してください

ボイル方程式についても、コマンドと一緒に同じことを試してみました\chが、長くなりすぎてページからはみ出てしまいました。\splitや などの他の多くのオプションを試しましたが\\、何も機能しませんでした。そこで、次のコードに頼りました。

$C_nH_aO_bN_c$+$(n-\frac{a}{4}-\frac{b}{2}+\frac{3c}{4})$ $H_2O$ \longrightarrow 
    ($\frac{n}{2}$+$\frac{a}{8}$-$\frac{b}{4}$-$\frac{3c}{8})$ $CH_4+(\frac{n}{2}-\frac{a}{8}+\frac{b}{4}+\frac{3c}{8})CO_2+cNH_3$

分数はまだ間違っていますし、方程式の横に番号ラベルもありません。次のようになります:

ここに画像の説明を入力してください

答え1

化学物質や方程式を入力してタイプセットするには、 などの化学パッケージを使用することを強くお勧めします。また、科学的な単位や量を表現するには、 siunitx パッケージのおよびマクロmhchemを使用することをお勧めします。\unit\qty

ここに画像の説明を入力してください

\documentclass{article} % or some other suitable document class
\usepackage{array}             % for '\newcolumntype' macro
\usepackage[version=4]{mhchem} % for '\ce' macro
\usepackage{amsmath}           % for 'multline*' environment
\usepackage{siunitx}           % for '\unit' and '\qty' macros

\newcolumntype{P}[1]{%  % 'p' col. type, w/ automatic hanging indentation
   >{\raggedright\arraybackslash\hangafter=1\hangindent=1em}p{#1}}
\sisetup{per-mode=symbol}

\begin{document}

\noindent
(bla bla bla \dots)
\[
 n_{\ce{CH4}}=\frac{\mathrm{COD}}{\qty{64}{\gram\per\mol}}
\]
where
\begin{center}
\begin{tabular}{ l P{3in} }
$n_{\ce{CH4}}$ & amount of molecular methane, in \unit{\mol} \\
$\mathrm{COD}$ & experimentally obtained value of chemical oxygen demand
\end{tabular}
\end{center}
Using a \texttt{multline*} environment and six instances of \texttt{\string\ce}:
\begin{multline*}
\ce{C_nH_aO_bN_c} 
+ \Bigl(n-\frac{a}{4}-\frac{b}{2}+\frac{3c}{4}\Bigr) \ce{H2O} \\ 
\ce{->}
\Bigl(\frac{n}{2}+\frac{a}{8}-\frac{b}{4}-\frac{3c}{8}\Bigr) \ce{CH4}
+\Bigl(\frac{n}{2}-\frac{a}{8}+\frac{b}{4}+\frac{3c}{8}\Bigr)\ce{CO2}+c\ce{NH3}
\end{multline*}

\end{document}

答え2

番号付きの反応を持つことは確かに可能です。例えば、chemmacrosパッケージ。1 行では長すぎる場合は、複数行を使用することをお勧めします。

化学式に数式モードを使用するのはよくありません。化学式は数学的な変数ではないので、縦書きで書く必要があります。chemformula(のデフォルトchemmacros)またはmhchem彼らのために。

このような構造

($\frac{n}{2}$+$\frac{a}{8}$-$\frac{b}{4}$-$\frac{3c}{8})$

は本当に間違っています。プラス記号とマイナス記号のために数式モードを終了しないでください。間違ったスペースは、誤った結果の 1 つにすぎません。

ここで簡単な提案をします。siunitx単位と数量のパッケージ:

\documentclass{article}

\usepackage{chemmacros}
\chemsetup{
  reactions/own-counter = false % equations and reactions share counter
}
\NewChemReaction{multreaction}{multline}% new reaction type based on multline by amsmath

% setup siunitx (loaded by chemmacros)
\sisetup{
  per-mode = fraction
}

\usepackage{lipsum}% for sample text

\begin{document}

\begin{equation}
  n_{\ch{CH4}}=\frac{COD}{\qty{64}{\gram\per\mole}}
\end{equation}
Where:
\begin{itemize}
  \item $n_{\ch{CH4}}$ is the amount of molecular methane in \unit{\mole}
  \item $COD$ is experimentally obtained value of chemical oxygen demand
\end{itemize}
\lipsum[1]
\begin{multreaction}
C_{$n$}H_{$a$}O_{$b$}N_{$c$} + $\Bigl(n-\frac{a}{4}-\frac{b}{2}+\frac{3c}{4}\Bigr)$ H2O -> \\
    $\Bigl(\frac{n}{2}+\frac{a}{8}-\frac{b}{4}-\frac{3c}{8}\Bigr)$ CH4 +
    $\Bigl(\frac{n}{2}-\frac{a}{8}+\frac{b}{4}+\frac{3c}{8}\Bigr)$ CO2 + $c$ NH3
\end{multreaction}
\lipsum[2]

\end{document}

ここに画像の説明を入力してください

関連情報