有没有办法调整包装的聚合物支架的水平对齐chemmacros
?这只是一个不重要的细节,但我很好奇。
梅威瑟:
\documentclass{scrreprt}
\usepackage{chemformula}
\usepackage{chemfig}
\setangleincrement{30}
\usepackage{chemmacros}
\chemsetup{modules={polymers}}
\begin{document}
\begin{figure}[ht]
\centering
\small
\setatomsep{18.34pt}
\chemfig{([:-126]O*5(--(-[@{d}:210]O-[:150]-[:210]-[@{c}:150]HO)-(-[@{e}-1]O-[1]-[-1]-[@{f}1]OH)-(-[1](-[:90]-[@{i}1]O-[-1]-[1]-[@{j}-1]O-[1](=[:90]O)-[-1]-[1]-[-1]-[1]-[-1]-[1]-[-1]-[1]=[-1]-[:270]-[:330]-[:270]-[:330]-[:270]-[:330]-[:270]-[:330])-[@{g}-1]O-[1]-[-1]-[@{h}1]OH)-))}
\makepolymerdelims[subscript={\small w}]{8.15pt}{c}{d}
\makepolymerdelims[subscript={\small x}]{8.15pt}{e}{f}
\makepolymerdelims[subscript={\small y}]{8.15pt}{g}{h}
\makepolymerdelims[subscript={\small z}]{8.15pt}{i}{j}
\end{figure}
\end{document}
答案1
括号未对齐的原因是两个括号的节点首先没有对齐:
\documentclass{article}
\usepackage{chemfig}
\begin{document}
\setatomsep{18.34pt}
\chemfig{-[@{a}:-30]O-[::60]-[::-60]-[@{b}::60]OH}
\chemmove{
\draw[red] (a) -- (b) ;
}
\end{document}
一个简单的解决方案是使用节点(a-|b)
(与 一起(a)
)或(a|-b)
(与 一起(b)
)。请参阅 PGF 手册以了解-|
语法的解释(第 137f 节第 13.3.1 节)垂直线的交点)。下面这个可能给你一点提示:
\documentclass{article}
\usepackage{chemfig}
\begin{document}
\setatomsep{18.34pt}
\chemfig{-[@{a}:-30]O-[::60]-[::-60]-[@{b}::60]OH}
\chemmove{
\draw[red] (a) -- (b) ;
\draw[green] (a) -- (a-|b) ;
\draw[blue] (a|-b) -- (b) ;
}
\end{document}
与括号一起使用:
\documentclass{article}
\usepackage{chemfig}
\usepackage{chemmacros}
\chemsetup{modules={polymers}}
\begin{document}
\setatomsep{18.34pt}
\chemfig{-[@{a}:-30]O-[::60]-[::-60]-[@{b}::60]OH}
\makepolymerdelims{8.15pt}{a|-b}{b}
\end{document}
将上述内容应用到您的示例中:
\documentclass{article}
\usepackage{chemfig}
\setangleincrement{30}
\usepackage{chemmacros}
\chemsetup{modules={polymers}}
\begin{document}
\small
\setatomsep{18.34pt}
\chemfig{([:-126]O*5(--(-[@{d}:210]O-[:150]-[:210]-[@{c}:150]HO)-(-[@{e}-1]O-[1]-[-1]-[@{f}1]OH)-(-[1](-[:90]-[@{i}1]O-[-1]-[1]-[@{j}-1]O-[1](=[:90]O)-[-1]-[1]-[-1]-[1]-[-1]-[1]-[-1]-[1]=[-1]-[:270]-[:330]-[:270]-[:330]-[:270]-[:330]-[:270]-[:330])-[@{g}-1]O-[1]-[-1]-[@{h}1]OH)-))}
\makepolymerdelims[subscript={\small$w$}]{8.15pt}{c}{c-|d}
\makepolymerdelims[subscript={\small$x$}]{8.15pt}{e|-f}{f}
\makepolymerdelims[subscript={\small$y$}]{8.15pt}{g|-h}{h}
\makepolymerdelims[subscript={\small$z$}]{8.15pt}{i|-j}{j}
\end{document}
不幸的是,下标的深度仍然会导致错位(这里是y
as 下标的情况)。这可以通过粉碎下标来解决。
我会将其添加到 的下一版本中chemmacros
。同时这里有一个修复:
\documentclass{article}
\usepackage{chemfig}
\setangleincrement{30}
\usepackage{chemmacros}
\chemsetup{modules={polymers}}
\ExplSyntaxOn
\chemmacros_if_compatibility:nnF {>} {5.8b}
{
\chemmacros_define_keys:nn {polymers}
{
subscript .code:n =
\tl_set:Nn \l__chemmacros_polymer_subscript_tl { \smash {#1} }
}
}
\ExplSyntaxOff
\begin{document}
\small
\setatomsep{18pt}
\chemfig{([:-126]O*5(--(-[@{d}:210]O-[:150]-[:210]-[@{c}:150]HO)-(-[@{e}-1]O-[1]-[-1]-[@{f}1]OH)-(-[1](-[:90]-[@{i}1]O-[-1]-[1]-[@{j}-1]O-[1](=[:90]O)-[-1]-[1]-[-1]-[1]-[-1]-[1]-[-1]-[1]=[-1]-[:270]-[:330]-[:270]-[:330]-[:270]-[:330]-[:270]-[:330])-[@{g}-1]O-[1]-[-1]-[@{h}1]OH)-))}
\makepolymerdelims[subscript={\small$w$}]{10pt}{c}{c-|d}
\makepolymerdelims[subscript={\small$x$}]{10pt}{e|-f}{f}
\chemmove{\draw[red,-] (g|-h) -- (h) ;}
\makepolymerdelims[subscript={\small$y$}]{10pt}{g|-h}{h}
\makepolymerdelims[subscript={\small$z$}]{10pt}{i|-j}{j}
\end{document}
答案2
我猜,这是因为您在倾斜的边缘使用了括号。但您可以使用不同的方法来移动括号并定义其高度和深度。然而,即使采用以下设置,括号也不会完全对齐:
\documentclass{scrreprt}
\usepackage{chemformula}
\usepackage{chemfig}
\setangleincrement{30}
\usepackage{chemmacros}
\chemsetup{modules={polymers}}
\begin{document}
\begin{figure}[ht]
\centering
\small
\setatomsep{18.34pt}
\chemfig{([:-126]O*5(--(-[@{d,.75}:210]O-[:150]-[:210]-[@{c,.75}:150]HO)-(-[@{e,.75}-1]O-[1]-[-1]-[@{f,.75}1]OH)-(-[1](-[:90]-[@{i,.75}1]O-[-1]-[1]-[@{j,.75}-1]O-[1](=[:90]O)-[-1]-[1]-[-1]-[1]-[-1]-[1]-[-1]-[1]=[-1]-[:270]-[:330]-[:270]-[:330]-[:270]-[:330]-[:270]-[:330])-[@{g,.75}-1]O-[1]-[-1]-[@{h,.75}1]OH)-))}
\makepolymerdelims[subscript={\small w}]{7pt}[11pt]{c}{d}
\makepolymerdelims[subscript={\small x}]{7pt}[11pt]{e}{f}
\makepolymerdelims[subscript={\small y}]{7pt}[11pt]{g}{h}
\makepolymerdelims[subscript={\small z}]{7pt}[11pt]{i}{j}
\end{figure}
\end{document}
编辑:第一个问题是,括号所连接的节点未垂直对齐。这个问题可以用 clemens 的答案来解决。第二个问题是,即使两个节点都对齐,括号可能仍未对齐,因为每个括号在其各自的节点处垂直居中,但右括号附有下标文本,使其略微向上移动。这是因为括号不使用相同的基线。
但是,您可以创建自己的自定义宏,它是预定义宏的变体。它将第三个节点放置在引用节点的中心。此节点包含两个括号以及它们之间的一些水平空间。这样,两个括号就使用相同的基线。缺点:需要进行大量微调:
\documentclass{scrreprt}
\usepackage{chemfig}
\setangleincrement{30}
%\usepackage{chemformula}
%\usepackage{chemmacros}
%\chemsetup{modules={polymers}}
\newcommand{\makemypolymerdelims}[7][]{%
\chemmove{\path (#6) -- node[pos=#4] {$\left[\vrule height#2 depth#3 width0pt\hspace{#5}\right]_\textrm{#1}$} (#7);}%
}
\begin{document}
\begin{figure}[ht]
\centering
\small
\setatomsep{18.34pt}
\chemfig{([:-126]O*5(--(-[@{c}:210]O-[:150]-[:210]-[@{d}:150]HO)-(-[@{e}-1]O-[1]-[-1]-[@{f}1]OH)-(-[1](-[:90]-[@{i}1]O-[-1]-[1]-[@{j}-1]O-[1](=[:90]O)-[-1]-[1]-[-1]-[1]-[-1]-[1]-[-1]-[1]=[-1]-[:270]-[:330]-[:270]-[:330]-[:270]-[:330]-[:270]-[:330])-[@{g}-1]O-[1]-[-1]-[@{h}1]OH)-))}
\makemypolymerdelims[w]{8pt}{8pt}{.45}{40pt}{c}{d}
\makemypolymerdelims[x]{8pt}{8pt}{.59}{40pt}{e}{f}
\makemypolymerdelims[y]{8pt}{8pt}{.59}{40pt}{g}{h}
\makemypolymerdelims[z]{8pt}{8pt}{.59}{40pt}{i}{j}
\end{figure}
\end{document}
产生完全对齐的括号: