注释化学反应下方的化学计量数

注释化学反应下方的化学计量数

我用化学宏指令 使用 LaTeX 编写化学反应的软件包,如下所示:

\ch{CH4 + 2 O2 -> CO2 + 2 H2O}

但现在,我想注释化学反应下面的化学计量数,如下图所示。

我知道蒂克兹可以做到,但我不知道怎么做。非常感谢您的帮助。

带注释化学计量数的化学方程式

答案1

chemformula人们可以利用允许在单引号或双引号之间插入相对任意代码的事实\ch。尽管手册上说转义代码不能包含空格,但似乎可以通过将代码放在括号之间来解决这个问题,这就是我下面所做的(尽管在这种情况下实际上不需要这样做)。

这个annotate宏有点基础/粗糙,但应该很容易看出如何改进。主要问题是如何将图片相对于其余文本进行良好的定位,同时忽略大部分图片(即注释位)。

baseline下面我展示了使用和trim left/键执行此操作的 PGF/TikZ 方法trim right

\documentclass[varwidth,border=5]{standalone}
\usepackage{tikz,chemmacros}
\usetikzlibrary{positioning}
\newcommand\annotate[3][below]{%
\tikz[baseline=0pt,trim left=(@.west), trim right=(@.east)]{%
  \node [draw=orange!50, top color=white, bottom color=orange!25, rounded corners=2pt, inner xsep=1pt,anchor=base](@){#2};
  \node [font=\footnotesize, align=center,inner ysep=2pt, #1=1cm/2 of @] (@') {#3};
  \draw[cyan,-stealth](@)--(@');}%
  \ignorespaces%
}
\begin{document}
\ch{CH4 + "{\annotate{2}{Coeficiente\\estequiom\'etrico}}" O2 -> CO2 + 2 H2O}
\end{document}

在此处输入图片描述

答案2

psmatrix您可以通过以下环境执行此操作pst-node

\documentclass[pdf, x11names]{article}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}
\usepackage{pst-node, pst-grad, pst-blur}
\usepackage{mhchem}

\begin{document}

\[ \psset{linewidth=0.5pt, arrows = ->, nodesepA=0pt, nodesepB=2pt, arrowinset=.25, framearc=0.15}
\psset{fillstyle=gradient, gradbegin=white, gradend=LightSalmon1!40! white}
 \begin{psmatrix}
\ce{CH4 + \Rnode{coeff}{\psframebox[linecolor=LightSalmon1!80! white, shadow=true, blur=true, shadowsize =.6pt, blurradius=0.3pt, ]{2}} O2 ―――→ CO2 + 2 H2O}%\\
\uput{7ex}[d](coeff){\Rnode{annot}{\textsf{\footnotesize Coeficiente estequiométrico}}}%
\ncline[linecolor=SkyBlue3]{coeff}{annot}
\end{psmatrix}
\]

\end{document} 

在此处输入图片描述

答案3

另一个 PSTricks 解决方案:

\documentclass[pdf, x11names]{article}
\usepackage[utf8]{inputenc}
\usepackage{pst-node, pst-grad, pst-blur}
\usepackage{chemmacros}
 \psset{linewidth=0.5pt, arrows = ->, arrowinset=.25, framearc=0.15, 
  fillstyle=gradient, gradbegin=white, gradend=LightSalmon1!40! white}
\def\Annote#1#2{\rnode[b]{coeff}{\psframebox[linecolor=LightSalmon1!80! white, 
  shadow, blur, shadowsize =.6pt, blurradius=0.3pt]{#1}%
  \uput{7ex}[-90](coeff){\textsf{\footnotesize\shortstack{#2}}}%
  \ncline[linecolor=SkyBlue3,offsetB=-6.5ex,nodesep=-1.4ex]{coeff}{coeff}}}
 \begin{document}

 \ch{CH4 + "{\Annote{2}{Coeficiente\\estequiométrico}}" O2 -> CO2 + 2 H2O}

 \end{document}

在此处输入图片描述

相关内容