
我需要繪製通用的三嵌段共聚物,如 MWE 和圖中所示。我遇到的問題是分子的左側和右側。我希望它們僅以“(”和“)”結尾,不代表化學鍵。如果我保留“-”,那麼我會在圖像左側得到帶有化學鍵的結果。如果我不包含它,我會得到圖像右側顯示的結果,但「)」和一些垃圾字元的位置會出現錯誤。
我正在使用 Ubuntu 18.04 檔案中的 chemfig 1.2e。這意味著我沒有新版本的軟體包中引入的新功能。
謝謝 !
編輯:如果化學鍵變短,還有加分:)
\documentclass{article}
\usepackage{mwe}
\usepackage{chemfig}
\begin{document}
% Define a function to draw polymer structures
\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{
-[@{opa,.75}]A-[@{cla,0.25}]
-[@{opb,.75}]B-[@{clb,0.25}]
-[@{opc,.75}]A\ [@{clc,0.25}]
}
\makebraces[5pt,5pt]{\!\!n_{i}}{opa}{cla}
\makebraces[5pt,5pt]{\!\!n_{i+1}}{opb}{clb}
\makebraces[5pt,5pt]{\!\!n_{i+2}}{opc}{clc}
\end{document}
答案1
歡迎!這是一種方法:將這些債券的不透明度設為零。
\documentclass{article}
\usepackage{chemfig}
\begin{document}
% Define a function to draw polymer structures
\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{
-[@{opa,.75},,,,opacity=0]A-[@{cla,0.25}]
-[@{opb,.75}]B-[@{clb,0.25}]
-[@{opc,.75}]A-[@{clc,0.25},,,,opacity=0]
}
\makebraces[5pt,5pt]{\!\!n_{i}}{opa}{cla}
\makebraces[5pt,5pt]{\!\!n_{i+1}}{opb}{clb}
\makebraces[5pt,5pt]{\!\!n_{i+2}}{opc}{clc}
\end{document}
請注意,很可能有更好的方法。然而這就是A擺脫這些束縛的方法。