制作 chemfig 支架

制作 chemfig 支架

我正在尝试绘制一些带有括号 ()n 的聚合物结构,但我真的不明白 chemfig 手册的说明......

下面是一个在错误的地方给出奇怪的括号的示例:

\documentclass{article}
%
\usepackage[utf8]{inputenc}
\usepackage[square,numbers]{natbib}
%\bibliographystyle{plainnat}
\bibliographystyle{abbrvnat}

\usepackage{siunitx}
\usepackage{textgreek}
%
\usepackage{caption}
\usepackage[left=2cm,right=2cm,top=2cm,bottom=2cm]{geometry}%showframe 
nachher löschen
\usepackage{chemfig}

\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\vruleheight\delimhalfdim depth\delimhalfdimwidth0pt\right.$};%
        \node[at=(#5),yshift=(\delimvshift)]{$\left.\vrule height\delimhalfdimdepth\delimhalfdimwidth0pt\right\delimright_{\rlap{$\scriptstyle#3$}}$};
    }
}

\begin{document}

\chemfig{-[@{op, 0.75}:30](-[:90])-[:-30](=[:-90]O)-[:30]O-[@{cl, 0.25}:-30]} \makebraces[5pt,25pt]{\!\!\!n}{op}{cl}
\bigskip \\

\end{document}

在此处输入图片描述

答案1

chemfig 包现在提供\polymerdelim宏:

\documentclass{article}
\usepackage{chemfig}
\begin{document}
\chemfig{-[@{op, 0.75}:30](-[:90])-[:-30](=[:-90]O)-[:30]O-[@{cl, 0.25}:-30]}
\polymerdelim[indice=n]{op}{cl}
\end{document}

在此处输入图片描述

相关内容