0

This issue very well could be related to: this post

When \callchemfigsymbol{s_adenosyl_l_methionine.tex} is uncommented, an error is observed. When \callchemfigsymbol{methane_pseudo_3D_stereo.tex} is called, the mwe compiles.

What's the difference? My first guess is that the commands (e.g. \mcfabove, \mcfplus, and \phantom) in the more complex structural formula are not playing well with catchfile?

I am compiling on W10 with MiKTeX. The version of mol2chemfig I am using should be the latest.

Error message:

Runaway argument?
{
! Paragraph ended before \CF_chemfigb was complete.
<to be read again> 
                   \par 
l.190 ...hemfigsymbol{s_adenosyl_l_methionine.tex}
                                                  %
? 

Here is the not so minimal working (fingers crossed) example:

\documentclass[english,border=1mm]{standalone}
\usepackage[T1]{fontenc}
\usepackage{chemfig}
\usepackage{tikz}
\usepackage{catchfile}
\usepackage{mol2chemfig}%


\tikzset{
  % #1 = left, #2 = lower, #3 = right, #4 = upper
  enlarge bounding box by/.style n args={4}{
    execute at end picture={
      \path ([shift={(-#1, -#2)}]current bounding box.south west) --
            ([shift={(#3, #4)}]current bounding box.north east);
    }
  }
}

% chemfigdo
\newcommand{\chemfigdo}[2]{\chemfig[#2]{#1}}%

% chemfiginput
\newcommand{\chemfiginput}[2][]{%
  \CatchFileDef{\chemfiginputtemp}{#2}{\csname CF_sanitizecatcode\endcsname}%
  \expandafter\chemfigdo\expandafter{\chemfiginputtemp}{#1}%
}%

% create new command for tikzpicture call
\newcommand\callchemfigsymbol[1]{%
  \chemfiginput[
      atom style={scale=\chemfigscale},
      atom sep=\chemfigatomsep,
      chemfig style={
        enlarge bounding box by={\chemfigborder}{\chemfigborder}{\chemfigborder}{\chemfigborder},
        baseline=(current bounding box.center),
        color=\chemfigcolor,
        line width=\chemfiglinewidth
      }
    ]{#1}%
}


\begin{filecontents}{s_adenosyl_l_methionine.tex}
                   O% 6
           =[:95.9]% 26
                      (
               -[:35.9]O% 5
         -[:335.9,0.62]H% 50
                      )
          -[:155.9]% 24
                      (
              <:[:95.9]N% 10
                          (
             -[:155.9,0.62]H% 46
                          )
          -[:35.9,0.62]H% 45
                      )
                      (
         -[:155.9,0.62]H% 44
                      )
          -[:215.9]% 21
                      (
         -[:235.9,0.62]H% 39
                      )
                      (
         -[:315.9,0.62]H% 40
                      )
          -[:155.9]% 18
                      (
          -[:55.9,0.62]H% 34
                      )
                      (
         -[:135.9,0.62]H% 35
                      )
          -[:215.9]\mcfabove{S}{_{\mcfplus}}% 1
                      (
              -[:275.9]% 22
                          (
             -[:275.9,0.62]H% 42
                          )
                          (
               -[:5.9,0.62]H% 43
                          )
         -[:185.9,0.62]H% 41
                      )
          -[:155.9]% 17
                      (
          -[:55.9,0.62]H% 32
                      )
                      (
         -[:135.9,0.62]H% 33
                      )
          >[:215.9]% 13
                      (
         -[:332.9,0.62]H% 28
                      )
          -[:269.9]O% 2
          -[:197.9]% 16
                      (
              -[:125.9]% 15
                          (
                   -[:53.9]% 14
                              (
                      -[:341.9]% -> 13
                              )
                              (
                  -[:44.9,0.62]H% 29
                              )
                 <:[:107.9]O% 3
              -[:47.9,0.62]H% 36
                          )
                          (
             -[:116.9,0.62]H% 30
                          )
             <:[:179.9]O% 4
         -[:119.9,0.62]H% 37
                      )
                      (
         -[:314.9,0.62]H% 31
                      )
          <[:251.9]N% 7
    -[:197.8,0.994]% 19
           =^[:150]N% 9
            -[:210]% 27
                      (
           -[:150,0.62]H% 47
                      )
           =^[:270]N% 11
            -[:330]% 25
                      (
                -[:270]N% 12
                          (
               -[:330,0.62]H% 49
                          )
           -[:210,0.62]H% 48
                      )
            =^[:30]% 23
                      (
                 -[:90]% -> 19
                      )
    -[:342.2,0.994]N% 8
      =^[:54,0.994]% 20
                      (
          -[:126,0.994]\phantom{N}% -> 7
                      )
           -[,0.62]H% 38
\end{filecontents}


\begin{filecontents}{methane_pseudo_3D_stereo.tex}
           H% 2
     -[:270]C% 1
              (
        -[:200]H% 4
              )
              (
         <[:310]H% 5
              )
    <:[:350]H% 3
\end{filecontents}


% define the atom sep
\newlength{\chemfigatomsep}%
\setlength{\chemfigatomsep}{2.75em}%

% define the line width
\newlength{\chemfiglinewidth}%
\setlength{\chemfiglinewidth}{0.75pt}%

% define the scale
\def\chemfigscale{1}

% define the color
\def\chemfigcolor{blue!40!black}

% define separation length
\newlength{\chemfigborder}
\setlength{\chemfigborder}{1mm}



\begin{document}

%\callchemfigsymbol{s_adenosyl_l_methionine.tex}% when I uncomment this, I observe error
\callchemfigsymbol{methane_pseudo_3D_stereo.tex}% this works fine

\end{document}
6
  • 1
    I have deleted only \usepackage[latin9]{inputenc} because give me an error but your mwe compiles correctly. What OS, do you use and what is the your LaTeX distribuition (is it outdata?), please? Regards.
    – Sebastiano
    Aug 1, 2020 at 11:45
  • 1
    The "MWE" does not load the mol2chemfig package. This is the package which defines the \mcfabove \mcfplus macros with occur in the generated code. Maybe that would already fix it; however, I am reluctant to try, since there is so much cruft in this "MWE". Aug 1, 2020 at 13:55
  • @Sebastiano, did you uncomment the line which calls the more complex formula? @Michael, I edited the mwe incorporating your suggestions which are very much appreciated. If the mwe appears complex, it is because two features are included (1) being able to call symbols from a library (2) being able to nicely align symbols in the tabular environment. I'm likely ignorant of a more elegant implementation, any advice is appreciated.
    – John Chris
    Aug 1, 2020 at 17:11
  • @JohnChris I have not understood your comment "did you uncomment the line which calls the more complex formula?" sorry.
    – Sebastiano
    Aug 1, 2020 at 20:49
  • I meant: Did you uncomment %\callchemfigsymbol{s_adenosyl_l_methionine.tex}% this line?
    – John Chris
    Aug 1, 2020 at 20:56

1 Answer 1

3

The "MWE" in the question is neither minimal nor working. Here is a real MWE, which shows that the issue has nothing to do with mol2chemfig:

\documentclass{standalone}
\usepackage{mol2chemfig}

\begin{document}

\chemfig{
           H% 2
     -[:270]C% 1
              (
        -[:200]H% 4
              )
              (
         <[:310]H% 5
              )
    <:[:350]H% 3
}

\bigskip

\chemfig{
                   O% 6
           =[:95.9]% 26
                      (
               -[:35.9]O% 5
         -[:335.9,0.62]H% 50
                      )
          -[:155.9]% 24
                      (
              <:[:95.9]N% 10
                          (
             -[:155.9,0.62]H% 46
                          )
          -[:35.9,0.62]H% 45
                      )
                      (
         -[:155.9,0.62]H% 44
                      )
          -[:215.9]% 21
                      (
         -[:235.9,0.62]H% 39
                      )
                      (
         -[:315.9,0.62]H% 40
                      )
          -[:155.9]% 18
                      (
          -[:55.9,0.62]H% 34
                      )
                      (
         -[:135.9,0.62]H% 35
                      )
          -[:215.9]\mcfabove{S}{_{\mcfplus}}% 1
                      (
              -[:275.9]% 22
                          (
             -[:275.9,0.62]H% 42
                          )
                          (
               -[:5.9,0.62]H% 43
                          )
         -[:185.9,0.62]H% 41
                      )
          -[:155.9]% 17
                      (
          -[:55.9,0.62]H% 32
                      )
                      (
         -[:135.9,0.62]H% 33
                      )
          >[:215.9]% 13
                      (
         -[:332.9,0.62]H% 28
                      )
          -[:269.9]O% 2
          -[:197.9]% 16
                      (
              -[:125.9]% 15
                          (
                   -[:53.9]% 14
                              (
                      -[:341.9]% -> 13
                              )
                              (
                  -[:44.9,0.62]H% 29
                              )
                 <:[:107.9]O% 3
              -[:47.9,0.62]H% 36
                          )
                          (
             -[:116.9,0.62]H% 30
                          )
             <:[:179.9]O% 4
         -[:119.9,0.62]H% 37
                      )
                      (
         -[:314.9,0.62]H% 31
                      )
          <[:251.9]N% 7
    -[:197.8,0.994]% 19
           =^[:150]N% 9
            -[:210]% 27
                      (
           -[:150,0.62]H% 47
                      )
           =^[:270]N% 11
            -[:330]% 25
                      (
                -[:270]N% 12
                          (
               -[:330,0.62]H% 49
                          )
           -[:210,0.62]H% 48
                      )
            =^[:30]% 23
                      (
                 -[:90]% -> 19
                      )
    -[:342.2,0.994]N% 8
      =^[:54,0.994]% 20
                      (
          -[:126,0.994]\phantom{N}% -> 7
                      )
           -[,0.62]H% 38
}
    
\end{document}
1
  • Thanks, Michael. This is helpful.
    – John Chris
    Aug 1, 2020 at 16:56

You must log in to answer this question.

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