7
\documentclass[12pt]{article}
\usepackage[version=3]{mhchem}
\begin{document}
   \ce{CH2OH + ATP <=>>[\text{Hexokinase}] + \text{glucose 6-phosphate} + ADP + H+} \\
   \ce{CH2OH + ATP <=>> + \text{glucose 6-phosphate} + ADP + H+}
\end{document}

See the resulting Latex output, and compare. In [1] the difference between the two arrows of the unequal equilibrium sign becomes less perceptible because the sign has been stretched by the text. Compare to the same sign without the text [2]. I want the the differences between the upper and lower arrows to be exacerbated a bit more. How can I achieve this in LaTEX?

3 Answers 3

8

Another answer because I misunderstood your question. Digging around in the source code there are several macros which affect the length of the arrows.

From mhchem.sty we have

\newcommand*\mhchem@xlongrightshortleftharpoons[2][]{\mathrel{%
  \sbox{\mhchem@arrows@box}%
    {$\mkern9mu\ext@arrow 3399\mhchem@leftharpoondownfill@%
     {#1}{\hphantom{#2}\mkern-6mu\mkern-12mu}$}%
  \rlap{\protect\raisebox{-.22ex}{\usebox{\mhchem@arrows@box}}}%     
  \protect\raisebox{.22ex}{$\ext@arrow 3399\mhchem@rightharpoonupfill@%
    {\hphantom{\usebox{\mhchem@arrows@box}}\mkern-6mu}{#2}$}%
  }}

It's basically a front end to amsmath's \ext@arrow macro:

\def\ext@arrow#1#2#3#4#5#6#7{%
  \mathrel{\mathop{%
    \setbox\z@\hbox{#5\displaystyle}%
    \setbox\tw@\vbox{\m@th
      \hbox{$\scriptstyle\mkern#3mu{#6}\mkern#4mu$}%
      \hbox{$\scriptstyle\mkern#3mu{#7}\mkern#4mu$}%
      \copy\z@
    }%
    \hbox to\wd\tw@{\unhbox\z@}}%
  \limits
    \@ifnotempty{#7}{^{\if0#1\else\mkern#1mu\fi
                       #7\if0#2\else\mkern#2mu\fi}}%
    \@ifnotempty{#6}{_{\if0#1\else\mkern#1mu\fi
                       #6\if0#2\else\mkern#2mu\fi}}}%
}

So playing around with the arguments to \ext@arrow in lines 3-4 will affect the length of the lower arrow. I could not grok the \ext@arrow code enough to figure out how.

Instead I tried the option of drawing arrows with pgf. You have to put

\usepackage{tikz}
\mhchemoptions{arrows=pgf}

in the preamble. Then the relevant macro is:

\newcommand*\mhchem@longrightshortleftharpoons@pgf[1]{%
  \begin{tikzpicture}[baseline]%
    \draw[use as bounding box] (0,0) (#1,1ex);
    \draw[cap=round, join=round, line width=0.09ex]
        (0.0cm,0.575ex+0.22ex) -- ++(#1,0cm) arc (250:198:0.9ex);  
    \draw[cap=round, join=round, line width=0.09ex]
        (#1+0.5em-1em,0.575ex-0.22ex) -- (0.5em,0.575ex-0.22ex) arc (70:18:0.9ex);
  \end{tikzpicture}%
}% 

From this you can see that the bottom arrow is 1em shorter than the top one. To make it even shorter, change the last line to something like:

(#1-0.75em,0.575ex-0.22ex) -- (0.75em,0.575ex-0.22ex) arc (70:18:0.9ex);

This will make the bottom arrow 1.5em shorter.

To make this configurable, define a key and invoke it. Here's the complete example:

\documentclass[12pt]{minimal}
\usepackage[version=3]{mhchem}
\usepackage{tikz}
\mhchemoptions{arrows=pgf}

\makeatletter
\newlength{\mhchem@shortarrow@reduction}
\define@key{mhchem}{shortarrowreduction}{\setlength{\mhchem@shortarrow@reduction}{#1}}
\renewcommand*\mhchem@longrightshortleftharpoons@pgf[1]{%
  \begin{tikzpicture}[baseline]%
    \draw[use as bounding box] (0,0) (#1,1ex);
    \draw[cap=round, join=round, line width=0.09ex]
        (0.0cm,0.575ex+0.22ex) -- ++(#1,0cm) arc (250:198:0.9ex);  
    \draw[cap=round, join=round, line width=0.09ex]
       % was: (#1+0.5em-1em,0.575ex-0.22ex) -- (0.5em,0.575ex-0.22ex) arc (70:18:0.9ex);
        (#1-\the\mhchem@shortarrow@reduction,0.575ex-0.22ex) 
        -- (\the\mhchem@shortarrow@reduction,0.575ex-0.22ex) arc (70:18:0.9ex);
  \end{tikzpicture}%
}
\AtBeginDocument{\mhchemoptions{shortarrowreduction=0.5em}}
\makeatother


\begin{document}

\noindent%
   \ce{CH2OH + ATP <=>>[\text{Hexokinase}] + \text{glucose 6-phosphate} + ADP + H+} \\
   {\mhchemoptions{shortarrowreduction=2em}
   \ce{CH2OH + ATP <=>>[\text{Hexokinase}] + \text{glucose 6-phosphate} + ADP + H+}} \\
\end{document}

sample code output

3
  • 2
    Go TikZ! (and some more to get to 15 characters) Commented Apr 28, 2011 at 13:37
  • Thank you - very good sir. For a novice like me though, that is a touch daunting being somewhat of a hacky - though clever - way of going about it... Isn't there an easier, officially supported way? Perhaps some package supports it?
    – ptrcao
    Commented May 1, 2011 at 12:25
  • Perhaps you should ask the packages author, or read te source code. There didn't appear to be an elegant solution to me. Commented May 1, 2011 at 16:09
7

Here is a solution using (my own) chemformula. It provides the option arrow-ratio=<num> where <num> should be a value between 0 and 1:

\documentclass{article}
\usepackage{chemformula}

\begin{document}

\ch{CH2OH + ATP <=>>[Hexokinase] "glucose~6-phosphate" + ADP + H+}

\ch[arrow-ratio=.2]{CH2OH + ATP <=>>[Hexokinase] "glucose~6-phosphate" + ADP + H+}

\end{document}

enter image description here

Note: the quotation marks around "glucose~6-phosphate" prevent it from being treated as a formula.

4

A good trick is the \phantom command which typesets things invisibly:

\documentclass[12pt]{article}
\usepackage[version=3]{mhchem}
\begin{document}
   \ce{CH2OH + ATP <=>>[\text{Hexokinase}] + \text{glucose 6-phosphate} + ADP + H+} \\
   \ce{CH2OH + ATP <=>>[\phantom{\text{Hexokinase}}] + \text{glucose 6-phosphate} + ADP + H+}
\end{document}

enter image description here

1
  • TY, that was insightful Matthew. However my question was a little different; my apologies for not being clearer. What I meant to ask was how do I make the lower arrow in the equilibrium sign much smaller, to emphasise the lopsidedness of the equilibrium?
    – ptrcao
    Commented Apr 27, 2011 at 7:01

You must log in to answer this question.

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