![用化学公式写出数学表达式](https://linux22.com/image/450312/%E7%94%A8%E5%8C%96%E5%AD%A6%E5%85%AC%E5%BC%8F%E5%86%99%E5%87%BA%E6%95%B0%E5%AD%A6%E8%A1%A8%E8%BE%BE%E5%BC%8F.png)
答案1
您可以使用 Ti 创建自定义符号钾例如Z:
\documentclass{article}
\usepackage{amsmath}
\usepackage{tikz}
\newcommand{\moleculeA}{%
\begin{tikzpicture}[x=.5em, y=.5em, baseline]
\foreach \x in {{{-1*cos(30)},1.5}, {0,0}, {{2*cos(30)},0}, {{4*cos(30)},0}, {{5*cos(30)},1.5}} {
\begin{scope}[shift={(\x)}]
\draw (30:1) -- (90:1) -- (150:1) -- (210:1) -- (270:1) -- (330:1) -- cycle;
\end{scope}
}
\end{tikzpicture}%
}
\newcommand{\moleculeB}{%
\begin{tikzpicture}[x=.5em, y=.5em, baseline]
\foreach \x in {{{-1*cos(30)},1.5}, {0,0}, {{2*cos(30)},0}} {
\begin{scope}[shift={(\x)}]
\draw (30:1) -- (90:1) -- (150:1) -- (210:1) -- (270:1) -- (330:1) -- cycle;
\end{scope}
}
\begin{scope}[shift={({4*cos(30)},0)}]
\draw (210:1) -- (270:1) -- (330:1);
\end{scope}
\end{tikzpicture}%
}
\newcommand{\moleculeC}{%
\begin{tikzpicture}[x=.5em, y=.5em, baseline]
\foreach \x in {{{-1*cos(30)},1.5}, {0,0}, {{2*cos(30)},0}, {{4*cos(30)},0}} {
\begin{scope}[shift={(\x)}]
\draw (30:1) -- (90:1) -- (150:1) -- (210:1) -- (270:1) -- (330:1) -- cycle;
\end{scope}
}
\begin{scope}[shift={({5*cos(30)},1.5)}]
\draw (150:1) -- (210:1)
(270:1) -- (330:1);
\end{scope}
\end{tikzpicture}%
}
\newcommand{\moleculeD}{%
\begin{tikzpicture}[x=.5em, y=.5em, baseline]
\foreach \x in {{{-1*cos(30)},1.5}, {0,0}, {{2*cos(30)},0}, {{4*cos(30)},0}} {
\begin{scope}[shift={(\x)}]
\draw (30:1) -- (90:1) -- (150:1) -- (210:1) -- (270:1) -- (330:1) -- cycle;
\end{scope}
}
\begin{scope}[shift={({5*cos(30)},1.5)}]
\draw (90:1) -- (150:1) -- (210:1)
(270:1) -- (330:1) -- (30:1);
\end{scope}
\end{tikzpicture}%
}
\newcommand{\moleculeE}{%
\begin{tikzpicture}[x=.5em, y=.5em, baseline]
\foreach \x in {{{-1*cos(30)},1.5}, {0,0}, {{2*cos(30)},0}} {
\begin{scope}[shift={(\x)}]
\draw (30:1) -- (90:1) -- (150:1) -- (210:1) -- (270:1) -- (330:1) -- cycle;
\end{scope}
}
\end{tikzpicture}%
}
\newcommand{\moleculeF}{%
\begin{tikzpicture}[x=.5em, y=.5em, baseline]
\foreach \x in {{{-1*cos(30)},1.5}, {0,0}, {{2*cos(30)},0}, {{4*cos(30)},0}} {
\begin{scope}[shift={(\x)}]
\draw (30:1) -- (90:1) -- (150:1) -- (210:1) -- (270:1) -- (330:1) -- cycle;
\end{scope}
}
\end{tikzpicture}%
}
\begin{document}
\begin{align*}
P\Big(\moleculeA\Big)
& = wP\Big(\moleculeB\Big) + P\Big(\moleculeC\Big) + P\Big(\moleculeD\Big) \\
& = (w + 1)P\Big(\moleculeE\Big) + P\Big(\moleculeF\Big) \\
& = (w + 1)(w^2 + 5w + 5) + (2w^2 + 8w + 7) \\
& = w^3 + 8w^2 + 18w + 12.
\end{align*}
\end{document}
答案2
和chemfig
\documentclass{article}
\usepackage{amsmath}
\usepackage{chemfig}
\setchemfig{atom sep=1em, angle increment=30}
\begin{document}
\[
P\chemleft(\chemfig{*6(--*6(--*6(---*6(------)---)---)--*6(------)--)}\chemright)
\]
\begin{align*}
&= wP\chemleft(\chemfig{*6(--*6(--(--[1])---)--*6(------)--)}\chemright)
+ P\chemleft(\chemfig{*6(--*6(--*6(---(-)-(-)--)---)--*6(------)--)}\chemright)
+ P\chemleft(\chemfig{*6(--*6(--*6(---(--[3])-(--[1])--)---)--*6(------)--)}\chemright) \\
&= (w+1)P\chemleft(\chemfig{*6(--*6(-----)--*6(------)--)}\chemright)
+
P\chemleft(\chemfig{*6(--*6(--*6(------)---)--*6(------)--)}\chemright) \\
&= (w + 1)(w^2 + 5w + 5) + (2w^2 + 8w + 7) = w^3 + 8w^2 + 18w + 12.
\end{align*}
\end{document}