我想要实现类似于此图中的公式
我是包装新手chemfig
,我用过mol2chemfig 网络工具以获得基本的分子结构,然后我手动修改它以插入圆形和方形的条目和箭头。
这是迄今为止的代码:
\documentclass[tikz]{standalone}
\newcommand*\circled[1]{\tikz[baseline=(char.base)]{
\node[shape=circle,draw,inner sep=0.5pt] (char) {#1};}}
\newcommand*\squared[1]{\tikz[baseline=(char.base)]{
\node[shape=rectangle,draw,inner sep=2pt] (char) {#1};}}
\usepackage{chemformula}
\usepackage{mol2chemfig}
% bond styling
\setcrambond{2.5pt}{0.4pt}{1.0pt}
\setbondoffset{1pt}
\setdoublesep{2pt}
\setatomsep{16pt}
% print atoms with smaller font and in sans-serif
\renewcommand{\printatom}[1]%
{\fontsize{8pt}{10pt}\selectfont{\ensuremath{\mathsf{#1}}}}%
\begin{document}
\schemestart
\chemname{
\chemfig{
O% 3
=[:330]C% 2
(
-[:30]\mcfright{O}{^{\mcfminus}}% 4
)
-[:270,,,2]HC% 1
(
-[:270,,2,1]CH_3% 5
)
-[,,2]O% 6
-P% 7
(
=[:90]O% 8
)
(
-[:270,,,1]OH% 10
)
-[,,,1]OH% 9
}}{fosfoenolpiruvato}
\+
\chemname{
\chemfig{
\circled{P}% 3
-[:270]\circled{P}% 2
-[:270]O% 1
-[:270]\squared{Rib}% 4
--\squared{Adenine}% 5
}}{ADP}
\arrow{->[\ch{Mg^2+},\ch{K+}][piruvato chinasi]}
\chemname{
\chemfig{
O% 3
=[:330]C% 2
(
-[:30]\mcfright{O}{^{\mcfminus}}% 4
)
-[:270,,,2]HC% 1
(
-[:270,,2,1]CH_3% 5
)
=[,,2]O% 6
}}{piruvato}
\+
\chemname{
\chemfig{
-\squared{Adenine}% 4
-[:180]\squared{Rib}% 3
-[:90]O% 1
-[:90]\circled{P}%% 2
-[:90]\circled{P}%% 5
-[:90]P% 6
(
-[:90]\mcfright{O}{^{\mcfminus}}% 7
)
(
-[:180,,,2]^{\mcfminus}O% 8
)
=O% 9
}}{ATP}
\schemestop
\end{document}
结果如下:
我希望实现以下目标:
- 让整个方程式垂直居中
- 在第二和第四个结构中,圆和矩形没有以正确的方式连接,即直线与圆和矩形连接不好
- 箭应该更长,或者至少弦吡咯烷酮应该放在两行(但 nor 都
\\
不起作用\par
) - 用一个装有选定颜色的盒子作为证据,其中有第一和第四个分子的一部分。
唯一的要求是:
- 应该这样做
chemfig
- 它应该与 PDFLaTeX 兼容
请注意,为了编译代码,你必须下载软件包mol2chemfig.sty
答案1
@{...}
您可以通过使用以下语法命名某些节点来实现垂直对齐使用它们作为基础命名节点还允许您为图表的某些部分添加阴影。我还将箭头加长了。为了制作您的剪辑编译,我必须下载mol2chemfig.sty。请注意,我删除了命令\squared
和\circled
,转而采用不嵌套tikzpicture
s 的解决方案。嵌套tikzpicture
s 是有风险的,总是存在这样的风险:在某个时刻某些东西会以无法轻易修复的方式损坏。这就是为什么我想说最好避免它。
\documentclass[tikz]{standalone}
\usetikzlibrary{fit}
\usepackage{chemformula}
\usepackage{mol2chemfig}
% bond styling
\setcrambond{2.5pt}{0.4pt}{1.0pt}
\setbondoffset{1pt}
\setdoublesep{2pt}
\setatomsep{16pt}
% print atoms with smaller font and in sans-serif
\renewcommand{\printatom}[1]%
{\fontsize{8pt}{10pt}\selectfont{\ensuremath{\mathsf{#1}}}}%
\begin{document}
\setarrowdefault{0,1.2}
\schemestart[][base]
\chemname{
\chemfig[baseline=(HC1.base)]{ % <- added base
@{O1}O% 3
=[:330]C% 2
(
-[:30]@{O2}\mcfright{O}{^{\mcfminus}}% 4
)
-[:270,,,2]@{HC1}HC% 1 % <- added @{HC1}
(
-[:270,,2,1]CH_3% 5
)
-[,,2]O% 6
-P% 7
(
=[:90]@{O1}O% 8
)
(
-[:270,,,1]@{OH1}OH% 10
)
-[,,,1]O@{OH2}H% 9
}}{fosfoenolpiruvato}
\+
\chemname{
\chemfig[baseline=(P1.base)]{ %<-
@{P4}{P\strut}% 3
-[:270]@{P1}{P\strut}% 2 %<-
-[:270]@{O6}{O}% 1
-[:270]@{R1}{Rib}% 4
--@{A1}{Adenine}% 5
}}{ADP}
\arrow(.mid east--.mid west){->[\ch{Mg^2+},\ch{K+}][\begin{tabular}{c}
piruvato\\ chinasi
\end{tabular}]}
\chemname{
\chemfig[baseline=(HC2.base)]{
O% 3
=[:330]C% 2
(
-[:30]\mcfright{O}{^{\mcfminus}}% 4
)
-[:270,,,2]@{HC2}HC% 1
(
-[:270,,2,1]CH_3% 5
)
=[,,2]O% 6
}}{piruvato}
\+
\chemname{
\chemfig[baseline=(P2.base)]{
-[:180]@{A2}{Adenine}% 4
-[:180,2]@{R2}{Rib}% 3
-[:90]O% 1
-[:90]@{P2}{P\strut}%% 2
-[:90]@{P5}{P\strut}%% 5
-[:90]@{P3}P% 6
(
-[:90]\mcfright{O}@{O3}{^{\mcfminus}}% 7
)
(
-[:180,,,2]@{O4}^{\mcfminus}O% 8
)
=@{O5}O% 9
}}{ATP}
\chemmove{
\node[inner sep=2pt,fill=red,fill opacity=0.2,fit=(OH1) (OH2) (O1)]{};
\node[inner sep=2pt,fill=red,fill opacity=0.2,fit=(P3) (O3) (O4) (O5)]{};
\node[inner sep=1pt,draw,fit=(A1)]{};
\node[inner sep=1pt,draw,fit=(R1)] (R1box){};
\node[inner sep=1pt,draw,fit=(A2)]{};
\node[inner sep=1pt,draw,fit=(R2)]{};
\foreach \X in {1,2,4,5}
{\node[draw,circle,fit=(P\X)]{};}
\draw[thin,-] ([yshift=-1mm]O6.center) -- (R1box);
\draw[thin,-] ([yshift=1.5mm]O6.center) -- (P1);
}
\schemestop
\end{document}