如何在 Chemfig 中抵消键的一端

如何在 Chemfig 中抵消键的一端

我试图绘制两个分子之间的氢键,但是虚线与氧上的电荷相交。我想知道是否有办法在保持格式(tabu 和 scalebox)不变的情况下抵消氢键?

\documentclass{article}
\usepackage{graphicx}
\usepackage{chemfig}
\usepackage{geometry}
\usepackage{tabu}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usepackage[ghsystem=false]{chemmacros}
    \chemsetup{modules = all}
    \chemsetup[orbital]{overlay}
\usetikzlibrary{arrows}

\makeatletter
\tikzset{
    dot diameter/.store in=\dot@diameter,
    dot diameter=1pt,
    dot spacing/.store in=\dot@spacing,
    dot spacing=5.5pt,
    dots/.style={
        line width=\dot@diameter,
        line cap=round,
        dash pattern=on 0pt off \dot@spacing
    }
}
\makeatother

\title{d}
\author{Generic Account}
\date{July 2021}

\begin{document}


\begin{center}
\tabulinesep = ^ 20mm _ 20mm % border gap
\begin{tabu} to 10.5cm {|X[cm]|}
    \hline
    \scalebox{1.25}{
    \chemfig{H-[:30]\charge{145=\:,35=\:}{O}(-[:-30]H)-[:30,1.25,,,dots]H-[:30]\charge{150=\:,30=\:}{O}-[:-30]-[:30]-[:-30]}
    }
    \\
    \hline
\end{tabu}
\end{center}


\end{document}

这是我得到的: 在此处输入图片描述

答案1

编辑:这个怎么样? 在此处输入图片描述%% <--这是通过在示例文件中 添加带有注释的单行获得的。

\documentclass{article}
\usepackage{graphicx}
\usepackage{chemfig}
\usepackage{geometry}
\usepackage{tabu}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usepackage[ghsystem=false]{chemmacros}
    \chemsetup{modules = all}
    \chemsetup[orbital]{overlay}
\usetikzlibrary{arrows}

\makeatletter
\tikzset{
    dot diameter/.store in=\dot@diameter,
    dot diameter=1pt,
    dot spacing/.store in=\dot@spacing,
    dot spacing=5.5pt,
    dots/.style={
        shorten <=5pt,     %% <-- this line does the trick
        line width=\dot@diameter,
        line cap=round,
        dash pattern=on 0pt off \dot@spacing
    }
}
\makeatother

\title{d}
\author{Generic Account}
\date{July 2021}

\begin{document}
\begin{center}
\tabulinesep = ^ 20mm _ 20mm % border gap
\begin{tabu} to 10.5cm {|X[cm]|}
    \hline
    \scalebox{1.25}{
    \chemfig{H-[:30]\charge{145=\:,35=\:}{O}(-[:-30]H)-[:30,1.25,,,dots]H-[:30]\charge{150=\:,30=\:}{O}-[:-30]-[:30]-[:-30]}
    }
    \\
    \hline
\end{tabu}
\end{center}
\end{document}

以下是我原来的近似解决方案: 在此处输入图片描述

\documentclass{article}
\usepackage{graphicx}
\usepackage{chemfig}
\usepackage{tikz}
\usepackage{geometry}
\usepackage{tabu}
\usepackage[utf8]{inputenc}
\usepackage[ghsystem=false]{chemmacros}
    \chemsetup{modules = all}
    \chemsetup[orbital]{overlay}
\usetikzlibrary{arrows}
\makeatletter
\tikzset{
    dot diameter/.store in=\dot@diameter,
    dot diameter=1pt,
    dot spacing/.store in=\dot@spacing,
    dot spacing=5.5pt,
    dots/.style={
        line width=\dot@diameter,
        line cap=round,
        dash pattern=on 0pt off \dot@spacing
    }
}
\makeatother
\begin{document}
\begin{center}
%\tabulinesep = ^ 20mm _ 20mm 
%\begin{tabu} to 10.5cm {|X[cm]|}
%    \hline
%\scalebox{1.25}{
  \chemfig{
    H
    -[:30]\charge{145=\:,35=\:}{O}(-[:-30]H)
    -#(7pt)[:30,1.25,,,dots]H     % <-- #(7pt) adjusts the departure bond sep.
    -[:30]\charge{150=\:,30=\:}{O}
    -[:-30]
    -[:30]
    -[:-30]
  }
%
%    \\
%    \hline
%\end{tabu}
\end{center}
\end{document}

我不得不注释掉破坏#(7pt)“出发边界 sep”参数的几行代码。

相关内容