我想使用 绘制以下共聚物结构\chemfig
。
但事实证明,我无法将右括号和下一个左括号放在同一个键内。我在网上找到的都是一些我不太理解的解决方法。
我最接近的是
\documentclass{article}
\usepackage{chemfig}
\begin{document}
\newcommand\setpolymerdelim[2]{\def\delimleft{#1}\def\delimright{#2}}
\def\makebraces[#1,#2]#3#4#5{%
\edef\delimhalfdim{\the\dimexpr(#1+#2)/2}%
\edef\delimvshift{\the\dimexpr(#1-#2)/2}%
\chemmove{%
\node[at=(#4),yshift=(\delimvshift)]
{$\left\delimleft\vrule height\delimhalfdim depth\delimhalfdim
width0pt\right.$};%
\node[at=(#5),yshift=(\delimvshift)]
{$\left.\vrule height\delimhalfdim depth\delimhalfdim
width0pt\right\delimright_{\rlap{$\scriptstyle#3$}}$};}}
\setpolymerdelim()
\chemfig{H_2N-[:30](-[:90])-[:-30]-[@{L1,.75}:30]O-[:-30]-[:30](-[:90])-[@{R1}:-30]O(@{L2})-[:30]-[:-30]-[@{R2}:30]@{L3}O-[:-30]-[:30](-[:90])-[@{R3}:-30]NH_2}
\makebraces[20pt,20pt]{\!\!\!x}{L1}{R1}
\makebraces[20pt,20pt]{\!\!\!y}{L2}{R2}
\makebraces[20pt,20pt]{\!\!\!z}{L3}{R3}
\end{document}
这使
如您所见,我无法移动氧原子上的括号。我希望将所有东西都排列整齐。
谢谢你的帮助!
编辑
检查后如何在 chemfig 中画括号作为鲍勃·鲍勃告诉我,我稍微调整了代码并且更接近我想要的,但现在我需要将括号变得更大。
\documentclass{article}
\usepackage{chemfig}
\begin{document}
\def\L1{\llap{$\left(\strut\right.$\kern2pt }}
\def\Rx{\rlap{$\kern60pt \left.\strut\right)_x$}}
\def\Ry{\rlap{$\kern60pt \left.\strut\right)_y$}}
\def\Rz{\rlap{$\kern60pt \left.\strut\right)_z$}}
\chemfig{H_2N-[:30](-[:90])-[:-30]-[:30] \L1 \Rx O-[:-30]-[:30](-[:90])-[:-30] \L1 \Ry O-[:30]-[:-30]-[:30] \L1 \Rz O-[:-30]-[:30](-[:90])-[:-30]NH_2}
\end{document}
有什么建议么?
答案1
我发现一个老问题有类似的问题,其中的答案也可能是你的解决方案。
它利用了模块中定义的宏polymers
。
\documentclass{article}
\usepackage{chemfig}
\newcommand{\makemypolymerdelims}[7][]{%
\chemmove{\path (#6) -- node[pos=#4] {$\left(\vrule height#2 depth#3 width0pt\hspace{#5}\right)_#1$} (#7);}%
}
\begin{document}
\chemfig{H_2N-[:30](-[:90])-[:-30]-[@{a}:30]O-[:-30]-[:30](-[:90])-[@{b}:-30] O-[:30]-[:-30]-[@{c}:30]O-[:-30]-[:30](-[:90])-[@{d}:-30]NH_2}
\makemypolymerdelims[x]{8pt}{8pt}{.55}{60pt}{a}{b}
\makemypolymerdelims[y]{8pt}{8pt}{.55}{60pt}{b}{c}
\makemypolymerdelims[z]{8pt}{8pt}{.55}{60pt}{c}{d}
\end{document}
答案2
我最终找到了解决此问题的方法。
\documentclass{article}
\usepackage{chemfig}
\begin{document}
\def\L{\llap{$\left(\rule{0pt}{20pt}\right.$\kern0pt }}
\def\Ly{\llap{$\left(\rule{0pt}{20pt}\right.$\kern-78pt }}
\def\Rx{\rlap{$\kern60pt \left.\rule{-2pt}{20pt}\right)_x$}}
\def\Ry{\rlap{$\kern140pt \left.\rule{-2pt}{20pt}\right)_y$}}
\def\Rz{\rlap{$\kern60pt \left.\rule{-2pt}{20pt}\right)_z$}}
\chemfig{H_2N-[:30](-[:90])-[:-30]-[:30] \L \Rx \Ly \Ry O-[:-30]-[:30](-[:90])-[:-30]O-[:30]-[:-30]-[:30] \L \Rz O-[:-30]-[:30](-[:90])-[:-30]NH_2}
\end{document}
说实话,我认为它还可以做得更好。x
、y
和z
离它们各自的右括号太远了,但我可以忍受。
无论如何,如果有人碰巧发现更专业的解决方案我很高兴听到这个消息!
谢谢!!