2

I'm trying to create the following image in LaTeX: Chemical Degradation Pathway

However, I'm having trouble positioning the label on the second curved arrow. Below is what I have been able to generate.

LaTeX-generated Degradation Pathway

If you'll notice that the second O2 is not exactly spaced like the first O2. Below is my MWE:

\documentclass{article}
\usepackage{chemfig}
\usepackage{fixltx2e}   % needed on my machine for textsubscript
\begin{document}
\begin{center}
\schemestart
\chemfig{*6(-=-=(-CH_3)-=)}
\arrow{-U>[O\textsubscript{2}][][][.5][]}
\chemfig{*6(-=-(-OH)=(-CH_3)-=)}
\arrow{-U>[*{0.north east}O\textsubscript{2}][][][-.5][-60]}
\chemfig{*6(-=(-OH)-(-OH)=(-CH_3)-=)}
\schemestop
\end{center}
\end{document}

I'm compiling using pdflatex mwe.tex using pdfTeX 3.1415926502.6.1.40.15 (TeX Live 2015/dev/Debian)

  • I seem not to replicate the OP figure with the MWE – Moriambar May 18 '17 at 18:22
  • Still not able to generate your output… – Moriambar May 18 '17 at 18:28
  • @Moriambar I just tried copying/pasting into a new file and running it. It compiles fine on my machine. What error(s) is/are you getting? – Joshua Grant May 18 '17 at 18:32
  • It compiles, but simply the output you give is not the output I get – Moriambar May 18 '17 at 18:32
  • @Moriambar Okay, in the original image I used .333 and -.333 instead of .5 and -.5 for the coefficients for each arrow. I'm updating the image in the OP to reflect the MWE. – Joshua Grant May 18 '17 at 18:36
3

TL;DR: If you just want the solution, scroll down to after the line break.

Defining a new -u> arrow

From what I can see, there's not really an easy way to place the label for the -U> arrow at the bottom without a redefinition, shown below (place this in your preamble):

\makeatletter
\definearrow5{-u>}{%
    \CF@arrow@shift@nodes{#3}%
    \expandafter\draw\expandafter[\CF@arrow@current@style](\CF@arrow@start@node)--(\CF@arrow@end@node)node[midway](uarrow@arctangent){};%
    \CF@ifempty{#4}
    {\def\CF@uarrow@radius{0.333}}
    {\def\CF@uarrow@radius{#4}}%
    \CF@ifempty{#5}%
    {\def\CF@uarrow@absangle{60}}
    {\pgfmathsetmacro\CF@uarrow@absangle{abs(#5)}}
    %
    \edef\CF@tmp@str{[\CF@ifempty{#1}{draw=none}{\unexpanded\expandafter{\CF@arrow@current@style}},-]}%
    \expandafter\draw\CF@tmp@str (uarrow@arctangent)%
    arc[radius=\CF@compound@sep*\CF@current@arrow@length*\CF@uarrow@radius,start angle=\CF@arrow@current@angle+90,delta angle=\CF@uarrow@absangle]node(uarrow@start){};
    %
    \edef\CF@tmp@str{[\CF@ifempty{#2}{draw=none}{\unexpanded\expandafter{\CF@arrow@current@style}},-]}%
    \expandafter\draw\CF@tmp@str (uarrow@arctangent)%
    arc[radius=\CF@compound@sep*\CF@current@arrow@length*\CF@uarrow@radius,%
    start angle=\CF@arrow@current@angle+90,%
    delta angle=-\CF@uarrow@absangle]%
    node(uarrow@end){};
    \pgfmathsetmacro\CF@tmp@str{\CF@uarrow@radius*cos(\CF@arrow@current@angle)<0?"+":"-"}%
    \ifdim\CF@uarrow@radius pt>\z@
    \CF@arrow@display@label{#1}{0}\CF@tmp@str{uarrow@start}{#2}{1}\CF@tmp@str{uarrow@end}%
    \else
    \CF@arrow@display@label{#2}{0}\CF@tmp@str{uarrow@start}{#1}{1}\CF@tmp@str{uarrow@end}%
    \fi
}
\makeatother

This is based on the original -U> definition, but for labels below the arrow. Here, the syntax is (note the use of small letter u, instead of U):

\arrow{-u>[#1][#2][#3][#4][#5]}

Like the original, it takes 5 arguments, as follows:

  • #1: label to be placed 'first' (arrow start)
  • #2: label to be placed 'second' (arrow end)
  • #3: yshift for the arrow, positive for upwards shift, vice versa
  • #4: radius of arc (default 0.333)
  • #5: angle for arc (default 60)

Just to show it works for all 5 arguments:

\documentclass{article}
\usepackage{chemfig}
%\usepackage{fixltx2e}   % needed on my machine for textsubscript

\makeatletter
\definearrow5{-u>}{%
    \CF@arrow@shift@nodes{#3}%
    \expandafter\draw\expandafter[\CF@arrow@current@style](\CF@arrow@start@node)--(\CF@arrow@end@node)node[midway](uarrow@arctangent){};%
    \CF@ifempty{#4}
    {\def\CF@uarrow@radius{0.333}}
    {\def\CF@uarrow@radius{#4}}%
    \CF@ifempty{#5}%
    {\def\CF@uarrow@absangle{60}}
    {\pgfmathsetmacro\CF@uarrow@absangle{abs(#5)}}
    %
    \edef\CF@tmp@str{[\CF@ifempty{#1}{draw=none}{\unexpanded\expandafter{\CF@arrow@current@style}},-]}%
    \expandafter\draw\CF@tmp@str (uarrow@arctangent)%
    arc[radius=\CF@compound@sep*\CF@current@arrow@length*\CF@uarrow@radius,start angle=\CF@arrow@current@angle+90,delta angle=\CF@uarrow@absangle]node(uarrow@start){};
    %
    \edef\CF@tmp@str{[\CF@ifempty{#2}{draw=none}{\unexpanded\expandafter{\CF@arrow@current@style}},-]}%
    \expandafter\draw\CF@tmp@str (uarrow@arctangent)%
    arc[radius=\CF@compound@sep*\CF@current@arrow@length*\CF@uarrow@radius,%
    start angle=\CF@arrow@current@angle+90,%
    delta angle=-\CF@uarrow@absangle]%
    node(uarrow@end){};
    \pgfmathsetmacro\CF@tmp@str{\CF@uarrow@radius*cos(\CF@arrow@current@angle)<0?"+":"-"}%
    \ifdim\CF@uarrow@radius pt>\z@
    \CF@arrow@display@label{#1}{0}\CF@tmp@str{uarrow@start}{#2}{1}\CF@tmp@str{uarrow@end}%
    \else
    \CF@arrow@display@label{#2}{0}\CF@tmp@str{uarrow@start}{#1}{1}\CF@tmp@str{uarrow@end}%
    \fi
}
\makeatother

\begin{document}
    \begin{center}
        \schemedebug{true} % Only to show boxes, nodes etc.
        \schemestart
        \chemfig{*6(-=-=(-CH_3)-=)}
        \arrow{-U>[\chemfig{O_2}][][][.5][]}
        \chemfig{*6(-=-(-OH)=(-CH_3)-=)}
        \arrow{-u>[A][B][5pt][.5][75]} % <---------- applying the new arrow type here
        \chemfig{*6(-=(-OH)-(-OH)=(-CH_3)-=)}
        \schemestop
    \end{center}
\end{document}

yields:

example

Note how:

  • A and B are placed at start and end of the arrow (in that order), as specified.
  • I indicated a positive yshift value, and indeed, the arrow was shifted upwards. (compare the red node points and the white node points of the arrow)
  • The radius of the arc is also visibly longer because 0.5 > 0.333 of the default.
  • The angle of the arc can be seen to be larger than the default because 75 > 60 (change it to other values to see for yourself).

Your Solution

\documentclass{article}
\usepackage{chemfig}
%\usepackage{fixltx2e}   % needed on my machine for textsubscript

\makeatletter
\definearrow5{-u>}{%
    \CF@arrow@shift@nodes{#3}%
    \expandafter\draw\expandafter[\CF@arrow@current@style](\CF@arrow@start@node)--(\CF@arrow@end@node)node[midway](uarrow@arctangent){};%
    \CF@ifempty{#4}
    {\def\CF@uarrow@radius{0.333}}
    {\def\CF@uarrow@radius{#4}}%
    \CF@ifempty{#5}%
    {\def\CF@uarrow@absangle{60}}
    {\pgfmathsetmacro\CF@uarrow@absangle{abs(#5)}}
    %
    \edef\CF@tmp@str{[\CF@ifempty{#1}{draw=none}{\unexpanded\expandafter{\CF@arrow@current@style}},-]}%
    \expandafter\draw\CF@tmp@str (uarrow@arctangent)%
    arc[radius=\CF@compound@sep*\CF@current@arrow@length*\CF@uarrow@radius,start angle=\CF@arrow@current@angle+90,delta angle=\CF@uarrow@absangle]node(uarrow@start){};
    %
    \edef\CF@tmp@str{[\CF@ifempty{#2}{draw=none}{\unexpanded\expandafter{\CF@arrow@current@style}},-]}%
    \expandafter\draw\CF@tmp@str (uarrow@arctangent)%
    arc[radius=\CF@compound@sep*\CF@current@arrow@length*\CF@uarrow@radius,%
    start angle=\CF@arrow@current@angle+90,%
    delta angle=-\CF@uarrow@absangle]%
    node(uarrow@end){};
    \pgfmathsetmacro\CF@tmp@str{\CF@uarrow@radius*cos(\CF@arrow@current@angle)<0?"+":"-"}%
    \ifdim\CF@uarrow@radius pt>\z@
    \CF@arrow@display@label{#1}{0}\CF@tmp@str{uarrow@start}{#2}{1}\CF@tmp@str{uarrow@end}%
    \else
    \CF@arrow@display@label{#2}{0}\CF@tmp@str{uarrow@start}{#1}{1}\CF@tmp@str{uarrow@end}%
    \fi
}
\makeatother

\begin{document}
    \begin{center}
%       \schemedebug{true} % Activate if you want to see the nodes etc.
        \schemestart
        \chemfig{*6(-=-=(-CH_3)-=)}
        \arrow{-U>[\chemfig{O_2}][][][.5][]}
        \chemfig{*6(-=-(-OH)=(-CH_3)-=)}
        \arrow{-u>[\chemfig{O_2}][][][.5][]}
        \chemfig{*6(-=(-OH)-(-OH)=(-CH_3)-=)}
        \schemestop
    \end{center}
\end{document}

final pic

A few comments:

  • I used \chemfig{O_2} instead of the \textsubscript version in your original code.
  • Only other optional argument passed was 0.5 for the arc radius, which was in your original question. The rest can be left blank. Note the angle need not be specified if you just need it to be 60 degrees because it is the default value.
|improve this answer|||||
  • I was looking for something similar, but could you make a version that has an arrow tip towards the products, please? – Arch Stanton May 31 '17 at 13:20
  • @ArchStanton Please ask a separate question, and link to this answer/question if required. – Troy May 31 '17 at 13:23
  • Done, it's on tex.stackexchange.com/questions/372590/… – Arch Stanton May 31 '17 at 13:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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