当我使用 chemfig 时\tikz[overlay,remember picture]
定位确实处于正确的位置。我使用的是 XeLaTeX 和 yLaTeX 类(请参阅此链接:https://github.com/HarveySheppard/yLaTeX)。下面是一些错误示例:
\begin{center}
\setchemfig{cram width=3pt}
\schemestart
\subscheme{
\chemleft[
\chemfig{@{F}\Lewis{0:2:4:6:,F}}
\chemright]}
\+
\chemfig{F-@{B}{\phantom{B}}(-[2,0,,,draw=none]{})(<[:-20]F)<:[:20]F}
\arrow{->}
\chemleft[
\chemfig{\chembelow[0.5pt]{F}{\scriptstyle\hspace{4.5mm}\oplus}-[:-90,0.8]@{cb}\chemabove[0.5pt]{B}{\scriptstyle\hspace{4.5mm}\ominus}(<:[:-40,0.8]F)(<[:-70,0.8]F)-[:-140]F}
\chemright]
\schemestop
\tikz[overlay,remember picture]{
\begin{scope}[overlay,shift={(B)}]
\draw[-] (-0.1,0.2) ..controls +(120:1) and +(60:1) .. (0.1,0.2);
\draw[-,fill=black!10] (-0.1,-0.2) ..controls +(-120:1) and +(-60:1) ..
+(0.2,0);
\end{scope}
\node[fill=white,inner sep=0.1pt] at (B){{\fontfamily{cmr}\selectfont
B
}};
\draw[-latex,shorten <=2pt] (F) ..controls +(90:1.7cm)and+(90:1cm)..
([yshift=9pt]B.north);
}
\tikz[overlay,remember picture]{
\draw[-latex,shorten <=2pt,densely dashed] ([yshift=9pt]cb.north) ..controls +(180:0.7) and +(-90:1).. +(-0.7,1) node[above,align=center] {\scriptsize coordinate \scriptsize covalent\\ \scriptsize bond};
}
\chemmove{\node[xshift=6pt] at (c2.north east) {$-$};}
\chemmove{\node[xshift=6pt] at (c3.north east) {$-$};}
\end{center}
输出如下: 指向配位共价键的虚线箭头应该来自最后一个化合物中硼(B)和氟(F)之间的垂直键。
另一个例子:
\setchemfig{cram width=3pt}
\chemnameinit{}
\schemestart
\chemname{\chemfig{H_{3}C-C(=[:45]O)-[:-45]O-[:0]H}}{\tikzmarknode{A}{Acetic
Acid}}
+
\chemname{\chemfig{H_{3}C-\Lewis{2:,N}(<:[:-15]H)<[:-40]H}}{\tikzmarknode{B}{Methylamine}}
\arrow{<=>}
\chemname{\chemfig{H_{3}C-C(=[:45]O)-[:-45]O\rlap{${}^-$}}}{\tikzmarknode{C}{Acetate
Ion}}
+
\chemname{\chemfig{H_{3}C-N\rlap{${}^+$}(-[:45]H)(<:[:-15]H)<[:-40]H}}{\tikzmarknode{D}{Mathylammonium
Ion}}
\schemestop
\begin{tikzpicture}[overlay,remember picture]
\node[below=3mm of A,fill=dullblue,draw,ellipse] (Acid1) {Acid};
\node[below=3mm of B,draw,ellipse] (Base1) {Base};
\node[below=3mm of C,fill=dullblue,draw,ellipse] (Base2) {Base};
\node[below=3mm of D,draw,ellipse] (Acid2) {Acid};
\draw[blue!50] (Acid1) -- ++ (0,-1.5) coordinate(aux) -| (Base2);
\draw (Base1) -- ++ (0,-2) -| (Acid2);
\node[anchor=south,blue!50,fill=white,outer sep=1pt] at (aux-|Base1) {Conjugate pair};
\end{tikzpicture}
序言中要求以下内容:
\usepackage{chemfig}
\usepackage{tikz}
\usetikzlibrary{tikzmark,positioning,shapes.geometric}
\definecolor{dullblue}{RGB}{178,201,231}
该代码来自我之前的一个问题:如何排版/绘制共轭酸和碱. 它产生以下输出 文本来自我的文档的其余部分。我更担心的是 tikz 椭圆不在正确的位置,不知道如何解决这个问题。任何帮助都将不胜感激。
答案1
根据 @whatisit 的建议,将以下代码添加到序言中可以使代码正确呈现:
\makeatletter
\def\pgfsys@hboxsynced#1{%
{%
\pgfsys@beginscope%
\setbox\pgf@hbox=\hbox{%
\hskip\pgf@pt@x%
\raise\pgf@pt@y\hbox{%
\pgf@pt@x=0pt%
\pgf@pt@y=0pt%
\special{pdf: content q}%
\pgflowlevelsynccm%
\pgfsys@invoke{q -1 0 0 -1 0 0 cm}%
\special{pdf: content -1 0 0 -1 0 0 cm q}% translate to original coordinate system
\pgfsys@invoke{0 J [] 0 d}% reset line cap and dash
\wd#1=0pt%
\ht#1=0pt%
\dp#1=0pt%
\box#1%
\pgfsys@invoke{n Q Q Q}%
}%
\hss%
}%
\wd\pgf@hbox=0pt%
\ht\pgf@hbox=0pt%
\dp\pgf@hbox=0pt%
\pgfsys@hbox\pgf@hbox%
\pgfsys@endscope%
}%
}
\makeatother
代码来自这里