在 chemfig 中的方案环境中, \setarrowlabelsep 参数放在哪里?

在 chemfig 中的方案环境中, \setarrowlabelsep 参数放在哪里?

我尝试查看文档,但似乎找不到包环境\setarrowlabelsep中的确切位置。我希望标签 Gpx 更靠近向下弯曲的箭头,标签 GR 更靠近向上弯曲的箭头。如能提供任何正确方向的帮助或提示,我将不胜感激。\schemestartchemfig

\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(@[email protected]){s>[][*{0.base east}Gpx][+(180:1.5)and+(180:1.5)]}[-90]
\arrow(@[email protected]){s>[][*{0.base west}GR][+(0:1.5)and+(0:1.5)]}[90]
\schemestop

\end{document}

答案1

您的代码在箭头定义中缺少一个左括号\parbox和 a \fi。添加这些后,我更改了箭头的定义,如下所示:

\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

s>这定义了一个具有四个可选参数的箭头类型:

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

当第三个选项为空时,它会产生一个直箭头(但也不会显示标签,因为它们被放置在分支中\else;您可能需要更改这一点)。如果指定了第三个参数,则会绘制弯曲箭头。这要求第三个参数是 TikZ.. controls ..语法的正确规范:.. controls <here goes the third argument> ..

根据上述定义,我们得到:

在此处输入图片描述

完整代码:

\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(@[email protected]){s>[][*{0.base east}Gpx][+(180:1.5)and+(180:1.5)]}[-90]
  \arrow(@[email protected]){s>[][*{0.base west}GR][+(0:1.5)and+(0:1.5)][5pt]}[90]
\schemestop

\end{document}

相关内容