2

Here is my input:

\begin{align}
&\text{HIn}_{(aq)} + \text{H$_2$O$_{(ℓ)}$} \rightleftharpoons \text{H$_3$O$^+_{(aq)}$} + &&\text{In$^-_{(aq)}$ $\kern 2pc$△H > O} 
\\
&\text{yellow} &&\text{purple}
\end{align}

Here is my output:

Output

Notice the gap between the '+' and the 'In' with 'purple' under it. How can I avoid this gap and have a single space instead?

4
  • 1
    Welcome to TeX.SE. This is expected with align. With alignat, the space between alignment columns can be controlled. Could you please transform you code snippet into a complete example that starts with \documentclass, ends with \end{document} and compiles without any error? This is what we call a minimal working example (MWE). Thanks.
    – frougon
    Apr 5, 2020 at 7:49
  • Why don't you use a package that ie dedicated to wirting chemical reactions such as the chemformula package?
    – leandriis
    Apr 5, 2020 at 8:18
  • Thank you for your responses. I've neglected to mention that this input i in a plugin field on a website we are building. My apologies for omitting that important info. As such, I'm not able to define classes or packages. This gives me limited control. I tried alignat, but this could not compile. The plugin appears to have limited interpreting. Apr 5, 2020 at 10:35
  • Although you say you can't use packages, you are using align. If this means that you have the facilities of amsmath, you could use begin{aligned}[t]... for the "purple" component without any && preceding it. Apr 5, 2020 at 16:16

3 Answers 3

1

As I said, horizontal space between adjacent right-left pairs of columns is expected with align and align*, but can be tuned and even removed using alignat, alignat*, etc. These environments expect an argument, maybe this is why you didn't manage to make alignat work? The argument in question is the number of pairs of right-left aligned columns. Equivalently, count the maximum number of &s in a given row and call it n. The argument to give to alignat (or alignat*, etc.) is then (n+1)/2.

\documentclass{article}
\usepackage{amsmath}

\begin{document}

\begin{alignat*}{2}
  & \text{HIn}_{(aq)} + \text{H$_2$O$_{(\ell)}$} \rightleftharpoons
  \text{H$_3$O$^+_{(aq)}$} + && \text{In$^-_{(aq)}$ $\kern 2pc \Delta H > O$} \\
  & \text{yellow} && \text{purple}
\end{alignat*}

\end{document}

enter image description here

1
  • 1
    This worked! The argument for alignat was the key info I needed. Thank you. Apr 10, 2020 at 6:48
2

There are a couple of well-designed LaTeX packages specifically for typesetting chemical formulae. I recommend that you use one of those. I have made good experiences with chemformula.

\documentclass{article}
\usepackage{chemformula}
\begin{document}
\[
    \ch{
        !(yellow)( HIn_{(aq)} ) + H2O_{($\ell$)} <=> H3O^+_{(aq)} + !(purple)( In^-_{(aq)} )
    }
    \quad \Delta H > O
\]
\end{document}

enter image description here

3
  • For the states, you could also use \aq{} and \lqd{} that come with the phases module of chemmacros.
    – leandriis
    Apr 5, 2020 at 8:40
  • @leandriis You should post an additional answer. Apr 5, 2020 at 8:49
  • @HenriMenke, thanks for this. You'll see from my comment on my question that I'm not able to use packages. My apologies for not including this info earlier. Apr 5, 2020 at 10:37
2

In addition to Henri Menke's answer, I have used \aq{} and \lqd{} from the phases module of chemmacros. For the enthalpy, I have used the \state command from the thermodynamics module of chemmacros. The reaction equation as well as the annotations below the reactant and product are done with the \ce command from chemformula (which itself is already loaded by the phases module of chemmacros, so no need for \usepackage{chemformula}):

enter image description here

\documentclass{article}
\usepackage{chemmacros}
\chemsetup{modules={phases, thermodynamics}}
\chemsetup[phases]{pos=sub}
\begin{document}
\begin{equation}
\ch{!(yellow)(HIn\aq{}) + H2O\lqd{} <=> H3O^{+}\aq{} + !(purple)(In$^{-}$\aq{})} \quad \state{H}> 0
\end{equation}
\end{document}
1
  • Thanks @leandriis, that is useful to know. Apr 5, 2020 at 10:36

You must log in to answer this question.

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