5

I'm using mhchem to write a chemical formula, as in the example by clemens (shown below). Is there a way to make the main arrow -> shorter by a fixed value in the second equation?

Here's the code:

\documentclass{article}
\usepackage[version=4]{mhchem}
\begin{document}

\ce{Na2SO4 ->[H2O] Na+ + SO4^2-}

\ce{(2Na+,SO4^2- ) + (Ba^2+, 2Cl- ) -> BaSO4 v + 2NaCl}

\end{document}

enter image description here

2 Answers 2

5

\documentclass{article}
\usepackage[version=4]{mhchem}

\ExplSyntaxOn
\keys_define:nn { mhchem }
 {
  arrow-min-length .code:n =
   \cs_set:Npn \__mhchem_arrow_options_minLength:n { {#1} } % default is 2em
 }
\ExplSyntaxOff

\begin{document}

\ce{(2Na+,SO4^2- ) + (Ba^2+, 2Cl- ) -> BaSO4 v + 2NaCl}

\mhchemoptions{arrow-min-length=1em}

\ce{(2Na+,SO4^2- ) + (Ba^2+, 2Cl- ) -> BaSO4 v + 2NaCl}

\mhchemoptions{arrow-min-length=10em}

\ce{(2Na+,SO4^2- ) + (Ba^2+, 2Cl- ) -> BaSO4 v + 2NaCl}

\end{document}

enter image description here

1
  • I'm not sure if it's clashing with some other package I'm using, but if I paste this into the document I'm working on, it has no effect.
    – N. Virgo
    Feb 8, 2020 at 8:01
1

Considering the tags , , you could built your chemical reaction also using the basic command of LaTeX. With \xrightarrow{\hspace*{6cm}} (for example) you can increase o decrease the lenght of the arrows. The equations are all aligned.

enter image description here

\documentclass[a4paper,12pt]{article}
\usepackage{amsmath,amssymb}

\begin{document}
\[
\begin{aligned}
\mathrm{Na}_2\mathrm{SO}_6 & \overset{\mathrm{H}_2\mathrm{O}}{\longrightarrow} \mathrm{Na}^+ + \mathrm{SO}_4^{2-}\\
(2\mathrm{Na}^+\mathrm{SO}_4^{2-})+(\mathrm{Ba}^{2+}, 2\mathrm{Cl}^-) & \longrightarrow \mathrm{Ba}\mathrm{SO}_4\!\downarrow+2\mathrm{NaCl} \\
\mathrm{Na}_2\mathrm{SO}_6 & \overset{\mathrm{H}_2\mathrm{O}}{\xrightarrow{\hspace*{5cm}}} \mathrm{Na}^+ + \mathrm{SO}_4^{2-}\\
(2\mathrm{Na}^+\mathrm{SO}_4^{2-})+(\mathrm{Ba}^{2+}, 2\mathrm{Cl}^-) & \xrightarrow{\hspace*{6cm}} \mathrm{Ba}\mathrm{SO}_4\!\downarrow+2\mathrm{NaCl}
\end{aligned}
\]
\end{document}
2
  • that's a great functional method for a document that doesn't use mhchem! Must be bug-safe!
    – twp
    Aug 6, 2019 at 0:53
  • @twp It is a classic simple method :-) of basic LaTeX. :-) I'm very happy to help you with another approach.
    – Sebastiano
    Aug 6, 2019 at 11:42

You must log in to answer this question.

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