[Tex/LaTex] Chemical bonds and atom position with chemfig

chemfigchemistry

I have been working in the cylindrospermopsin structure using chemfig. The structure is:enter image description here

I draw it with te following code:

\documentclass[12pt, border={10pt 10pt 10pt 10pt}]{standalone}
\pagestyle{empty}
\usepackage{standalone} 
\usepackage[utf8]{inputenc}%Para copiar caracteres especiais como ç, á, à
\usepackage[T1]{fontenc}%Para copiar caracteres especiais como ç, á, à
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{makeidx}
\usepackage{graphicx,graphics}
\usepackage[brazil]{babel}
\usepackage{chemfig}
\begin{document}
\chemfig{%
*6(-(-[:-72]?[a])(<[:-150]H)-N*6(-^{+}(-[:-108]NH2?[a])-NH1-(<[:90]H)(-[:30](<[:90]OH)-[:-30]*6(-M-(=[:-90]O)-NH-(=[:30]O)-=\phantom{L}))-?[b])-?[b](<[:90]H)--(<[:150]^{-}O_{3}SO)-)(<[:-150]H_3C)
}
\end{document}

The result is:

enter image description here

My questions:

  1. How can I put the positive charge out the structure, like the example?
  2. How can I draw the double bonds with one dashed line between N, NH1 and NH2?
  3. How can I link the NH2 atom correctly with the hydrogen outside?
  4. How can I put HN instead of M? I've been trying, but the bounds link in the H atom

Any help, indication, suggestion?

Best Answer

\documentclass[12pt, border=3mm,tikz]{standalone}
\usepackage[utf8]{inputenc}%Para copiar caracteres especiais como ç, á, à
\usepackage[T1]{fontenc}%Para copiar caracteres especiais como ç, á, à
\usepackage{chemfig}
\usetikzlibrary{decorations.markings} % You need this for q2

% From package documentation, pg 29, change ‘ to ` (2 instances)
\catcode`\@=11
\tikzset{
    ddbond/.style args={#1}{
        draw=none,
        decoration={%
            markings,
            mark=at position 0 with {
                \coordinate (CF@startdeloc) at (0,\dimexpr#1\CF@double@sep/2)
                coordinate (CF@startaxis) at (0,\dimexpr-#1\CF@double@sep/2);
            },
            mark=at position 1 with {
                \coordinate (CF@enddeloc) at (0,\dimexpr#1\CF@double@sep/2)
                coordinate (CF@endaxis) at (0,\dimexpr-#1\CF@double@sep/2);
                \draw[dash pattern=on 2pt off 1.5pt] (CF@startdeloc)--(CF@enddeloc);
                \draw (CF@startaxis)--(CF@endaxis);
            }
        },
        postaction={decorate}
    }
}
\catcode`\@=12

\begin{document}
\chemfig{%
    *6(-(-[:-72]?[a])(<[:-150]H)
    -N*6(-[,,,,ddbond={+}](-[7,0.2,,,draw=none]{\scriptstyle+})
    (-[:-108,,,1,ddbond={-}]N?[a]H2)
    -[,,,,ddbond={+}]NH1-(<[:90]H)(-[:30](<[:90]OH)
    -[:-30]*6(-[,,,2]HN-(=[:-90]O)-NH-(=[:30]O)-
    =\phantom{L}))-?[b])-?[b](<[:90]H)--(<[:150]^{-}O_{3}SO)-)(<[:-150]H_3C)
}

\end{document}

Just some small notes on each question. The very well-written package documentation goes into more details, I'll just point you to what's relevant.

  1. with -[7,0.2,,,draw=none]{\scriptstyle+}: This draws a + at the end of an invisible bond, drawn -45deg from the C atom (that's what the 7 means), 0.2*bond length away.

  2. with -[,,,,ddbond={+/-}]: this is taken from the chemfig documentation, pg 29. You need to use \usetikzlibrary{decorations.markings} in the preamble for this to work, and add the relevant part in the preamble. Then just add the ddbond={+} or ddbond={-} option to the relevant bonds (after 4 commas in the optional argument).

  3. with -[:-108,,,1]N?[a]H2: This bond is drawn from the + to the NH2, so set its arrival atom to 1 explicitly, which is the N atom. (Try removing the 1 in the argument, note what you get).

  4. with -[,,,2]HN instead of -M Similar with question 3, set the arrival atom to the second atom (the N), by passing 2 to the fourth optional argument.

chemfig

Off-topic: Please refrain from asking multiple (unrelated) questions in a single TeX.SE question in the future. This not only increases your chances of the question(s) being answered, but it also allows other users with similar questions to find this question(s) (and solution(s)) more easily.

Related Question