2
$\begingroup$

Created the rather nasty markup below. Why are there two different print styles for the x's?

$$\ce{[H+]^4 + (K_{a1} + xC_T)[H^+]^3 +(K_{a1}K_{a2} + (x - 1 )C_TK_{a1}-K_w)[H+]^2 + K_{a1}((x - 2)C_T-K_w)[H+] - K_{a1}K_{a2}K_w }\tag{C4}$$

renders as

$$\ce{[H+]^4 + (K_{a1} + xC_T)[H^+]^3 +(K_{a1}K_{a2} + ( x - 1 ) C_T K_{a1}-K_w)[H+]^2 + K_{a1}((x - 2)C_T-K_w)[H+] - K_{a1}K_{a2}K_w }\tag{C4}$$

$\endgroup$
1

1 Answer 1

8
$\begingroup$

You are mixing chemistry typeset with maths typeset; I don't think that the mhchem module is set up for this. There is probably much more wrong than what you consider a bug. Assuming $K$ is an equilibrium constant, it should be in italics (it is not with \ce) and the subscript should be in upright font (but get interpreted as variables within \ce). A similar thing happens to the interpretation of the $x$.
The macro \ce{ ... } will always try to interpret its contents as a chemistry or reaction equation; it is not designed to handle anything else. So in your equation, actually only the protons should be wrapped within this macro:

$$\begin{multline} [\ce{H+}]^4 + (K_\mathrm{a1} + xC_T)[\ce{H+}]^3 + (K_\mathrm{a1} K_\mathrm{a2} + (x - 1) C_T K_\mathrm{a1} - K_\mathrm{w})[\ce{H+}]^2\\ + K_\mathrm{a1} ((x - 2)C_T - K_\mathrm{w})[\ce{H+}] - K_\mathrm{a1} K_\mathrm{a2} K_\mathrm{w} \tag{C4} \end{multline}$$

$$\begin{multline}
  [\ce{H+}]^4 
  + (K_\mathrm{a1} + xC_T)[\ce{H+}]^3 
  + (K_\mathrm{a1} K_\mathrm{a2} + (x - 1) C_T K_\mathrm{a1} 
    - K_\mathrm{w})[\ce{H+}]^2\\ 
  + K_\mathrm{a1} ((x - 2)C_T - K_\mathrm{w})[\ce{H+}] 
  - K_\mathrm{a1} K_\mathrm{a2} K_\mathrm{w}
  \tag{C4}
\end{multline}$$
$\endgroup$
2
  • $\begingroup$ Thanks for the formatting lesson. $\endgroup$
    – MaxW
    Commented Jul 27, 2018 at 15:20
  • 2
    $\begingroup$ @Max The shortcut script from Gaurang (Introducing: Markdown Shortcuts for StackExchange) makes those things easier to type out. It doesn't make the way mhchem treats it's content more easier understood though ;) $\endgroup$ Commented Jul 27, 2018 at 15:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .