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}
\usepackage[utf8]{inputenc}%Para copiar caracteres especiais como ç, á, à
\usepackage[T1]{fontenc}%Para copiar caracteres especiais como ç, á, à

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?

  • 1
    For the positive charge (1) I'd use an invisible bond: tex.stackexchange.com/q/267684 For the atom groups and the bonds (3 & 4) I'd use the departure/arrival option: tex.stackexchange.com/q/327278
    – cgnieder
    May 28, 2017 at 16:16
  • 1
    For the delocalized double bond (2) have a look in the chemfig manual section Delocalized double bonds
    – cgnieder
    May 28, 2017 at 16:19
  • @clemens I'm not understandig how works the delocalized double bonds. I pasted the code from the manual and it is not working. The message isInvalid code (1000), should be in the range 0..15. \catcode‘\@ Missing $ inserted. \catcode‘\@ Missing number, treated as zero. \catcode‘ Missing number, treated as zero. \catcode‘ You can't use `\spacefactor' in math mode. \catcode‘\@ Package pgfkeys Error: I do not know the key '/tikz/decoration', to which you May 28, 2017 at 19:38
  • 1
    @DanielValencia You need to change to ` (backtick)
    – Troy
    May 29, 2017 at 2:56
  • @ DanielValencia errors without examples to reproduce them are often impossible to debug. I would have added an answer but @Troy already did, so…
    – cgnieder
    May 29, 2017 at 7:30

1 Answer 1

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

% From package documentation, pg 29, change ‘ to ` (2 instances)
    ddbond/.style args={#1}{
            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);



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.


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.

  • The LaTeX versions of \catcode`\@=11 and \catcode`\@=12 are \makeatletter and \makeatother
    – cgnieder
    May 29, 2017 at 7:28
  • I have recently been trying to use delocalized bonds and have copied the code from pg 30 character for character but I am getting an error {! Undefined control sequence.<argument> 0,\dimexpr +\CF_doublesep/2'}. The error is basically saying it needs a number rather than a {+} or a {-} in the ddbond={+/-}. Can anyone else repeat this and get the same issue?
    – Leeser
    Jan 27, 2020 at 16:03

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.