Chemfig 双键外观不一致

Chemfig 双键外观不一致

我使用以下 Chemfig 代码绘制了 meso-四苯基卟啉分子:

\documentclass[12pt,twoside]{report}
\usepackage{chemfig}

\setchemfig{%
    atom sep = 1.75em,
    stack sep = 0.3em,
    bond offset = 1.25pt,
    double bond sep = .25em,
}
\begin{document}

\chemfig{[:-90](=_[::-120]*5(-N(-H)-(=(-[4]Ph)-[::-48]*5(=[,,,1]N-[,,1](=(-[2]Ph)-[:-30])-=-))-=-))(-[6]Ph)-[::120]*5(-=-(=^(-[8]Ph)-[::48]*5(=-=?-N(-H)-))-N=)}

\end{document}

这会产生以下输出(使用截图工具添加的红色框):

在此处输入图片描述

请注意,尽管键的类型完全相同,但突出显示的键看起来却不同。我希望所有这样的连接点都像右侧突出显示的键一样出现。我的代码中的什么导致了这种不一致的行为?

答案1

使用“_”将所有双键放在大环“内部”

\documentclass[12pt,border=2mm]{standalone}
\usepackage{chemfig}
\renewcommand*\printatom[1]{\ensuremath{\mathsf{#1}}}

\begin{document}
\setchemfig{%
    atom sep = 1.75em,
    stack sep = 0.3em,
    bond offset = 1.25pt,
    double bond sep = .25em,
}
\chemfig{[:-90](=_[::-120]*5(-N(-H)-(=_(-[4]Ph)-[::-48]*5(=[,,,1]N-[,,1](=_(-[2]Ph)-[:-30])-=-))-=-))(-[6]Ph)-[::120]*5(-=-(=^(-[8]Ph)-[::48]*5(=-=?-N(-H)-))-N=)}

\end{document}

在此处输入图片描述

答案2

\documentclass[border=3mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{decorations.markings}
\usepackage{chemfig}
\catcode`\_=11
\tikzset{
    mydb/.style args={#1}{
        decoration={%
            markings,
            mark=at position 0 with {
                \coordinate (CF@startdeloc) at (0,\dimexpr#1\CF_doublesep);
            },
            mark=at position 1 with {
                \coordinate (CF@enddeloc) at (0,\dimexpr#1\CF_doublesep);
                \draw[red,shorten <=\CF_doublesep/1.75,shorten >=\CF_doublesep/1.7] (CF@startdeloc)--(CF@enddeloc);
            }
        },
        postaction={decorate}
    }
}
\catcode`\_=8
\begin{document}
    \setchemfig{%
        atom sep = 1.75em,
        stack sep = 0.3em,
        bond offset = 1.25pt,
        double bond sep = .25em,
    }
    \chemfig{[:-90](=_[::-120]*5(-N(-H)-(-[,,,,mydb={-}](-[4]Ph)-[::-48]*5(=[,,,1]N-[,,1](=(-[2]Ph)-[:-30])-=-))-=-))(-[6]Ph)-[::120]*5(-=-(=^(-[8]Ph)-[::48]*5(=-=?-N(-H)-))-N=)}
\end{document}

在此处输入图片描述

编辑

\documentclass[border=3mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{decorations.markings}
\usepackage{chemfig}
\catcode`\_=11
\pgfmathsetlengthmacro{\dbsep}{\CF_doublesep}
\tikzset{
    mydb/.style args={#1}{
        decoration={%
            markings,
            mark=at position 0 with {
                \coordinate (CF@startdeloc) at (0,#1\dbsep);
            },
            mark=at position 1 with {
                \coordinate (CF@enddeloc) at (0,#1\dbsep);
                \draw[shorten <=\dbsep/1.75,shorten >=\dbsep/1.75] (CF@startdeloc)--(CF@enddeloc);
            }
        },
        postaction={decorate}
    }
}
\catcode`\_=8
\begin{document}
    \setchemfig{%
        atom sep = 1.75em,
        stack sep = 0.3em,
        bond offset = 1.25pt,
        double bond sep = .25em,
    }
    \chemfig{[:-90](-[::-120,,,,mydb={-}]*5(-N(-H)-(-[,,,,mydb={-}](-[4]Ph)-[::-48]*5(=[,,,1]N-[,,1](-[,,,,mydb={-}](-[2]Ph)-[:-30])-=-))-=-))(-[6]Ph)-[::120]*5(-=-(-[,,,,mydb={+}](-[8]Ph)-[::48]*5(=-=?-N(-H)-))-N=)}
\end{document}

在此处输入图片描述

相关内容