我正在尝试获得这种化学结构的外观(参见突出显示的区域):
到目前为止我可以这样做:
这是我的代码:
\documentclass[12pt]{standalone}
\usepackage{tikz}
\usepackage{fontspec}
\setmainfont{Times New Roman}
\usepackage{chemfig}
\usepackage[version=3]{mhchem}
\usetikzlibrary{arrows,shadows,calc,shapes,backgrounds,intersections,positioning}
\makeatletter
\def\CF@node@content{%
\expandafter\expandafter\expandafter
\printatom\expandafter\expandafter\expandafter
{\csname atom@\number\CF@cnt@atomnumber\endcsname}%
\ensuremath{\CF@node@strut}%
}
\makeatother
\setdoublesep{0.35700 em} % 'Bond Spacing'
\setatomsep{1.78500 em} % 'Fixed Length'
\setbondoffset{0.18265 em} % 'Margin Width'
\newcommand{\bondwidth}{0.06642 em} % 'Line Width'
\setbondstyle{line width = \bondwidth}
\renewcommand*{\printatom}[1]{{\sffamily\cf{#1}}}
\begin{document}
\begin{tikzpicture}[font=\small ,line width=1pt,node distance=1cm, inner sep=-0.05cm]
\node[anchor=north] at(0,0){
\chemname{
\chemfig{[:135]Ru?[o](-[,2.2]N*6([:80]=-=-*6(=<=>(-*6([:-120]-=(-*6(-=-(-*6(=*6(-=-=-)-=-*6(-=-=-)=-))=-=-))-=([:-80]-*6(=-=-*6(-=-[,,,,line width=2pt]=N?[o,{-}]-)=-))-N?[o,{-}]=))=)--))([:45]-[,2.2]N*6([:100]-*6(-(-*6([:-60]-N?[o,{-}]=([:-100]-*6(=*6(-N?[o,{-}]=-=-)-=<=>-))-=(-*6(=-=(-*6(-*6(-=-=-)=-=*6(-=-=-)-=))-=-))-=))=-@{tr}=-=)--=-[,,,,line width=2pt]=))}}{\textbf{\large 2}}
\chemmove{\draw[very thick,inner sep=0pt](tr)++(1cm,-.1cm)--++(0,2em)node[anchor=north west,yshift=-4mm]{$\sf \left(PF_{6}\right)_2$}--++(-2em,0);}
};
\path (0,.5)--++(2,0);
\path (0,-6.5)--++(1,0);
\end{tikzpicture}
\end{document}
如何使用 chemfig 实现我想要的外观?
答案1
我会用线宽命令绘制粗体单键-[,,,,line width=2pt]
。可以通过在双键上向后(角度 = 180°)绘制粗体单键来实现粗体双键:-[::180,,,,line width=2pt]
。
以下是一个例子:
\documentclass[a4paper]{scrreprt}
\usepackage[utf8]{inputenc}
\usepackage{chemfig}
\renewcommand*\printatom[1]{\small\ensuremath{\mathsf{#1}}}
\setatomsep{16.5pt}
\setbondstyle{line width=0.6pt}
\setcrambond{3pt}{0.6pt}{1.5pt}
\setdoublesep{2.6pt}
\setbondoffset{1.6pt}
\setarrowdefault{,1.0,}
\begin{document}
\chemfig{*6(=(-[::180,,,,line width=2pt])-(*6(=-=(-NH_2)-(-*6(=(-NHTs)(-[::180,,,,line width=2pt])-[,,,,line width=2pt]=(-[::180,,,,line width=2pt])-(*6(=-=-=-))--))=-))--=(-[::180,,,,line width=2pt])-[,,,,line width=2pt])}
\end{document}
答案2
我取得了不错的成果。这是我注释的代码:
\documentclass[10pt]{article}
\pagestyle{empty} % required
\usepackage{chemfig}
\renewcommand{\familydefault}{\sfdefault}
\usepackage[scaled=1]{helvet}
\usepackage[helvet]{sfmath}
\everymath={\sf}
\begin{document}
\setchemfig{
atom sep=15pt,
double bond sep=2.6pt,
bond join=true,
cram width=3.0pt,
cram dash width=0.75pt,
cram dash sep=2.0pt
}
\chemfig{
Ru?[Ru] % central atom (with hook)
% 1st moiety (left)
(-[:180,3.25,,,dash pattern=on 2pt off 2pt] % long dashed bond to pyridyl left ring
N*6(=( % pyridyl ring
-[::-45] % to avoid stay too close to Ru atom
*6(=( % 1st 8-quinolyl ring (upper left benzene ring)
*6(-N?[Ru,,{dash pattern=on 2pt off 2pt}]=-=-) % 8-quinolyl (pyridine ring, with hook to Ru bond)
)-=<=( % 1st 8-quinolyl ring (continuation)
-[::0,0.1,,,draw=none]-[::180,1.2,,,line width=2pt] % bold bond as a branch
)>)) % 1st 8-quinolyl (end)
-=(-R_{1})-= % pyridyl (continuation)
(-[::-75] % to avoid stay too close to Ru atom
*6(=-=-( % 2nd 8-quinolyl ring (lower left)
*6(- % benzene ring
(-[::60,1.01,,,line width=2pt]-[::60,1.01,,,line width=2pt]) % bold bond as a branch
=-=N?[Ru,,{dash pattern=on 2pt off 2pt}] % 8-quinolyl (pyridine ring, with hook to Ru bond)
(-[::180,1.05,,,line width=2pt])-))=-)) % bold N= bond as a branch
-)) % Ending the 1st moiety
%
% 2nd moiety (right, same as above)
(-[:0.0,3.25,,,dash pattern=on 2pt off 2pt]
N*6(=(
-[::-45]
*6(=(
*6(-N?[Ru,,{dash pattern=on 2pt off 2pt}]=-=-)
)-=<=(
-[::0,0.1,,,draw=none]-[::180,1.2,,,line width=2pt]
)>))
-=(-R_{2})-=
(-[::-75]
*6(=-=-(
*6(-
(-[::60,1.01,,,line width=2pt]-[::60,1.01,,,line width=2pt])
=-=N?[Ru,,{dash pattern=on 2pt off 2pt}]
(-[::180,1.05,,,line width=2pt])-))=-))
-))
}
\end{document}
最终结果:
答案3
我并不是 pgf 和 tikz 方面的专家,所以可能可以做得更好。但这是我的解决方案,我定义了一种新的键样式。
灵感来自在没有 tikzset 的情况下在 chemfig 中创建离域双键?和将参数传递给 \pgfdeclaredecoration
\documentclass[a4paper]{article}
\usepackage{chemfig}
\usetikzlibrary{decorations}
\makeatletter
\pgfdeclaredecoration{halfbold}{initial}{%
\state{initial}[width=0.5*\pgfdecoratedpathlength,next state=final]{%
\pgfsetlinewidth{5\pgflinewidth}
\pgfpathmoveto{\pgfpoint{0}{0}}
\pgfpathlineto{\pgfpoint{\pgfdecoratedpathlength}{0}}
\pgfusepathqstroke
\pgfsetlinewidth{\tikzscope@linewidth}
\pgfpathmoveto{\pgfpoint{2pt}{4pt}}
\pgfpathlineto{\pgfpoint{0.9*\pgfdecoratedpathlength}{4pt}}
\pgfusepathqstroke
}
\state{final}{%
\pgfpathmoveto{\pgfpoint{0pt}{0pt}}
\pgfpathlineto{\pgfpoint{0.5*\pgfdecoratedpathlength}{0}}}}
\makeatother
\tikzset{myrbond/.style={decorate, decoration=halfbold}}
\tikzset{mylbond/.style={decorate, decoration={halfbold, mirror}}}
\setatomsep{4em}
\begin{document}
\chemfig{[:-30]R-C-[::60]C(-[::60,,,,,mylbond]O)-[,,,,myrbond]N(-[::-60]H)-[::60]C-R}
\end{document}
您可以调整线条的粗细\pgfsetlinewidth{5\pgflinewidth}
以及线条上双键之间的距离
\pgfpathmoveto{\pgfpoint{2pt}{4pt}}
\pgfpathlineto{\pgfpoint{0.9*\pgfdecoratedpathlength}{4pt}}
但我真的不确定,这是否比 @dieg0 提出的解决方案更好(或更好)