Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I tried looking in the documentation, but I can't seem to find the exact position for the \setarrowlabelsep in the \schemestart environment of the chemfig package. I would like the label Gpx shifted closer to the curved downwards arrow and the label GR closer to the curved upwards arrow. Any help or hint in the right direction would be appreciated.

\documentclass{standalone}
\usepackage{chemfig}
\usepackage[version=3]{mhchem}
\usepackage{hyphenat}
\usepackage{upgreek}

\makeatletter
\definearrow4{s>}{%
\ifx\@empty#3\@empty
\expandafter\draw\expandafter[\CF@arrow@current@style,-CF@full]\CF@arrow@start@node)--(\CF@arrow@end@node);%
\else
\def\curvedarrow@style{shorten <=\CF@arrow@offset,shorten >=\CF@arrow@offset,}%
\CF@expadd@tocs\curvedarrow@style\CF@arrow@current@style
\expandafter\draw\expandafter[\curvedarrow@style,-CF@full(\CF@arrow@start@name)..controls#3..(\CF@arrow@end@name);
\CF@arrow@display@label{#1}{0.5}{+}{\CF@arrow@start@name}{#2}{0.5}{-}{\CF@arrow@end@name}
}
\makeatother

\begin{document}
\schemedebug{true}
\schemestart
\textsc{l}-Glutamate\arrow(c1--c2){->}[-90]\parbox{2cm}\centering$\upgamma$\hyp{}Glutamyl\hyp{}cysteine}
\arrow(--c3){->}[-90]\chemfig{GSH}
\arrow(--c4){0}[-90]\chemfig{GSSG}
\arrow(@c3.180--@c4.180){s>[][*{0.base east}Gpx][+(180:1.5)and+(180:1.5)]}[-90]
\arrow(@c4.0--@c3.0){s>[][*{0.base west}GR][+(0:1.5)and+(0:1.5)]}[90]
\schemestop

\end{document}
share|improve this question

1 Answer 1

up vote 3 down vote accepted

Your code is missing an opening brace for the \parbox and a \fi in the arrow definition. After adding those I changed the definition of the arrow as follows:

\makeatletter
\definearrow4{s>}{%
  \ifx\@empty#3\@empty
    \expandafter\draw\expandafter[\CF@arrow@current@style,-CF@full]
      \CF@arrow@start@node)--(\CF@arrow@end@node);%
  \else
    \def\curvedarrow@style{shorten <=\CF@arrow@offset,shorten >=\CF@arrow@offset,}%
    \CF@expadd@tocs\curvedarrow@style\CF@arrow@current@style
    \expandafter\draw\expandafter[\curvedarrow@style,-CF@full]
    (\CF@arrow@start@name)..controls#3..(\CF@arrow@end@name);
    % here would be a better position for the \fi
    %
    % this will allow to shift the label nodes
    % (argument #4 wasn't used, anyway) ...
    \CF@arrow@shift@nodes{#4}%
    % ... if you use the \CF@arrow@...@node rather than
    % \CF@arrow@...@name:
    \CF@arrow@display@label{#1}{0.5}{+}{\CF@arrow@start@node}{#2}{0.5}{+}{\CF@arrow@end@node}
  \fi
}
\makeatother

This defines an arrow type s> that has four optional arguments:

\arrow{s>[ label ][ label ][ specs for the curve ][ label offset ]}

which produces a straight arrow when the third option is empty (but also won't display the labels then, since they are placed in the \else branch; you might want to change that). If the third argument is specified a curved arrow is drawn. This requires the third argument to be a correct specification for the TikZ .. controls .. syntax: .. controls <here goes the third argument> ...

With the above definition we get:

enter image description here

The complete code:

\documentclass{article}
\usepackage{chemfig}
\usepackage[version=3]{mhchem}
\usepackage{hyphenat}
\usepackage{upgreek}

\makeatletter
\definearrow4{s>}{%
  \ifx\@empty#3\@empty
    \expandafter\draw\expandafter[\CF@arrow@current@style,-CF@full]
      \CF@arrow@start@node)--(\CF@arrow@end@node);%
  \else
    \def\curvedarrow@style{shorten <=\CF@arrow@offset,shorten >=\CF@arrow@offset,}%
    \CF@expadd@tocs\curvedarrow@style\CF@arrow@current@style
    \expandafter\draw\expandafter[\curvedarrow@style,-CF@full]
    (\CF@arrow@start@name)..controls#3..(\CF@arrow@end@name);
    \CF@arrow@shift@nodes{#4}%
    \CF@arrow@display@label{#1}{0.5}{+}{\CF@arrow@start@node}{#2}{0.5}{+}{\CF@arrow@end@node}
  \fi
}
\makeatother

\begin{document}
% \schemedebug{true}
\schemestart
  \textsc{l}-Glutamate
  \arrow(c1--c2){->}[-90]
  \parbox{2cm}{\centering$\upgamma$\hyp{}Glutamyl\hyp{}cysteine}
  \arrow(--c3){->}[-90]
  \chemfig{GSH}
  \arrow(--c4){0}[-90]
  \chemfig{GSSG}
  \arrow(@c3.180--@c4.180){s>[][*{0.base east}Gpx][+(180:1.5)and+(180:1.5)]}[-90]
  \arrow(@c4.0--@c3.0){s>[][*{0.base west}GR][+(0:1.5)and+(0:1.5)][5pt]}[90]
\schemestop

\end{document}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.