> For the complete documentation index, see [llms.txt](https://ayakaleaf-pro.ayaka.space/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ayakaleaf-pro.ayaka.space/latex/zh-cn/te-ding-ling-yu/04-molecular-orbital-diagrams.md).

# 分子轨道图

本文简要介绍如何创建 [分子轨道图](https://en.wikipedia.org/wiki/Molecular_orbital_diagram) 在 LaTeX 中使用 [`modiagram` 宏包](https://ctan.org/pkg/modiagram?lang=en)。读者强烈建议查阅 [`modiagram` 包文档](http://mirrors.ctan.org/macros/latex/contrib/modiagram/modiagram_en.pdf) ，其中包含大量有助于展示其众多特性的示例——远远超出我们在这篇短文中能涉及的范围。

有关更传统的 *分子结构图* ，请参阅我们关于 [化学公式](/latex/zh-cn/te-ding-ling-yu/02-chemistry-formulae.md).

## 引言

分子图是使用 [`modiagram` 宏包](https://ctan.org/pkg/modiagram?lang=en) 创建的，你可以通过在文档导言区添加下面这一行将其引入文档：

`\usepackage{modiagram}`\[$$\langle$$`选项`$$\rangle$$]

以下 $$\langle$$`选项`$$\rangle$$ 设置被列出并演示于 [包文档](http://mirrors.ctan.org/macros/latex/contrib/modiagram/modiagram_en.pdf).

要在 $$\langle$$`选项`$$\rangle$$ *全局* 应用该宏包，你可以

* 在加载宏包时通过 `\usepackage{modiagram}`\[$$\langle$$`选项`$$\rangle$$，或者
* 使用设置命令 `\setmodiagram`{$$\langle$$`选项`$$\rangle$$}

MO 图通过 `modiagram` 环境创建，该环境支持局部使用宏包 $$\langle$$`选项`$$\rangle$$:

`\begin{modiagram}`\[$$\langle$$`选项`$$\rangle$$] ...

`\end{modiagram}`

下面的示例演示了一个最小的 `modiagram` 环境，未使用任何 $$\langle$$`选项`$$\rangle$$:

```latex
\documentclass{article}
\usepackage{modiagram}
\begin{document}

第一个示例原子：

\begin{modiagram}
\atom{left}{1s, 2s, 2p}
\end{modiagram}
\end{document}
```

[在 Overleaf 中打开此示例。](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=example+of+molecular+diagram\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cusepackage%7Bmodiagram%7D%0A%5Cbegin%7Bdocument%7D%0A%0AFirst+example+atoms%3A%0A%0A%5Cbegin%7Bmodiagram%7D%0A%5Catom%7Bleft%7D%7B1s%2C+2s%2C+2p%7D%0A%5Cend%7Bmodiagram%7D%0A%5Cend%7Bdocument%7D)

此示例生成如下输出：

![在 LaTeX 中生成的分子图示例](/files/311f6f8bcbd7fe0ef958cdca22a9fff4ff009266)

绘制 MO 图的基本命令是 `\atom` ，如上例所示，它接受两个参数：

* `左侧`：原子的对齐方式。
* `1s, 2s, 2p`：要绘制的能级子层。这些还可以进一步自定义，正如你将在 [下一节](#atoms).

## 原子

中学到的那样。你可以向入门示例中介绍的命令传递一些关于原子轨道的额外信息。

```latex
\documentclass{article}
\usepackage{modiagram}
\begin{document}

\begin{modiagram}
 \atom{right}{
    1s = { 0; pair} ,
    2s = { 1; pair} ,
    2p = {1.5; up, down }
 }

 \atom{left}{
    1s = { 0; pair} ,
    2s = { 1; pair} ,
    2p = {1.5; up, down }
 }
 \end{modiagram}
\end{document}
```

[在 Overleaf 中打开此示例。](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=example+of+molecular+diagram\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cusepackage%7Bmodiagram%7D%0A%5Cbegin%7Bdocument%7D%0A%0A%5Cbegin%7Bmodiagram%7D%0A+%5Catom%7Bright%7D%7B%0A++++1s+%3D+%7B+0%3B+pair%7D+%2C%0A++++2s+%3D+%7B+1%3B+pair%7D+%2C%0A++++2p+%3D+%7B1.5%3B+up%2C+down+%7D%0A+%7D%0A%0A+%5Catom%7Bleft%7D%7B%0A++++1s+%3D+%7B+0%3B+pair%7D+%2C%0A++++2s+%3D+%7B+1%3B+pair%7D+%2C%0A++++2p+%3D+%7B1.5%3B+up%2C+down+%7D%0A+%7D%0A+%5Cend%7Bmodiagram%7D%0A%5Cend%7Bdocument%7D)

此示例生成如下输出：

![原子轨道示例](/files/2e0b888f225549b5d6addb753cf6ebcc1138ea45)

在此示例中，绘制了两个相同的原子，分别左对齐和右对齐。

遵循 `modiagram` 宏包文档的风格，创建原子的一般语法可写为：

`\atom`\[$$\langle$$`名称`$$\rangle$$]{$$\langle$$`左侧`$$\rangle$$|$$\langle$$`右侧`$$\rangle$$}{$$\langle$$`AO-spec`$$\rangle$$}

其中

* $$\langle$$`名称`$$\rangle$$ 是原子的可选名称
* $$\langle$$`左侧`$$\rangle$$ 和 $$\langle$$`右侧`$$\rangle$$ 用于确定其在图中的位置
* $$\langle$$`AO-spec`$$\rangle$$ 是原子轨道的规范。

该 $$\langle$$`AO-spec`$$\rangle$$ 采用如下通用形式

```latex
子层 = {能量; 规格}
```

其中

* `子层` 可以是 `1s`, `2s` 或 `2p`
* `能量` 是能级，一个决定图中垂直间距的数值。若省略，则设为 0。
* `规格` 是一个以逗号分隔的电子自旋列表，包含于每个轨道中的电子。可取的值有 `上`, `下`, `成对` 以及 empty（只需输入分号）表示空轨道。若省略，则设为 `成对`.

下面是前一个示例中所用命令的说明：

* `1s = { 0; pair}`。子层 `1s` 位于 `0` 能级中，该轨道包含两个（成对的）电子。
* `2s = { 1; pair}`。子层 `2s` 绘制在 `1` 能级中，该轨道中有两个电子。
* `2p = {1.5; up, down}`。子层 `2p` 绘制在能级 `1.5`中，也就是说，在图中垂直间距设为 1.5；这个子能级有两个电子：一个自旋为 `上` 的电子位于第一个轨道，另一个自旋为 `下` 的电子位于第二个轨道。

右侧第二个原子重复了相同的命令。

要显示原子的（可选） `名称` 名称，请使用带有 `modiagram` 环境和 `[names]` 选项的

```latex
\documentclass{article}
\usepackage{modiagram}
\begin{document}
\begin{modiagram}[names]
 \atom[Atom on the right]{right}{
    1s = { 0; pair} ,
    2s = { 1; pair} ,
    2p = {1.5; up, down }
 }

 \atom[Atom on the left]{left}{
    1s = { 0; pair} ,
    2s = { 1; pair} ,
    2p = {1.5; up, down }
 }
\end{modiagram}
\end{document}
```

[在 Overleaf 中打开此示例。](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=Using+the+names+option+in+a+molecular+diagram\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cusepackage%7Bmodiagram%7D%0A%5Cbegin%7Bdocument%7D%0A%5Cbegin%7Bmodiagram%7D%5Bnames%5D%0A+%5Catom%5BAtom+on+the+right%5D%7Bright%7D%7B%0A++++1s+%3D+%7B+0%3B+pair%7D+%2C%0A++++2s+%3D+%7B+1%3B+pair%7D+%2C%0A++++2p+%3D+%7B1.5%3B+up%2C+down+%7D%0A+%7D%0A%0A+%5Catom%5BAtom+on+the+left%5D%7Bleft%7D%7B%0A++++1s+%3D+%7B+0%3B+pair%7D+%2C%0A++++2s+%3D+%7B+1%3B+pair%7D+%2C%0A++++2p+%3D+%7B1.5%3B+up%2C+down+%7D%0A+%7D%0A%5Cend%7Bmodiagram%7D%0A%5Cend%7Bdocument%7D)

此示例生成如下输出：

![分子轨道示例](/files/6b96295590d3893c5d5ef096ec7ad8b78feb2343)

## 分子

分子的语法与 [`\atom`](#atoms) 非常相似，按照文档风格可以写为：

`\molecule`\[$$\langle$$`名称`$$\rangle$$]{$$\langle$$`MO-spec`$$\rangle$$}

其中

* $$\langle$$`名称`$$\rangle$$ 是分子的可选标题
* $$\langle$$`MO-spec`$$\rangle$$ 是分子轨道的规范

能级子层 `1s`, `2s` 和 `2p` 变为 `1sMO`, `2sMO` 和 `2pMO` ，依次对应。下面是一个基本示例：

```latex
\documentclass{article}
\usepackage{modiagram}
\begin{document}
\begin{modiagram}
 \atom{left}{1s}
 \atom{right}{1s={;up}}
 \molecule{
    1sMO={0.75;pair,up}
  }
\end{modiagram}
\end{document}
```

[在 Overleaf 中打开此示例](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=Molecule+example+with+modiagram+package\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cusepackage%7Bmodiagram%7D%0A%5Cbegin%7Bdocument%7D%0A%5Cbegin%7Bmodiagram%7D%0A+%5Catom%7Bleft%7D%7B1s%7D%0A+%5Catom%7Bright%7D%7B1s%3D%7B%3Bup%7D%7D%0A+%5Cmolecule%7B%0A++++1sMO%3D%7B0.75%3Bpair%2Cup%7D%0A++%7D%0A%5Cend%7Bmodiagram%7D%0A%5Cend%7Bdocument%7D)

此示例生成如下输出：

![分子图示例](/files/06e9d0982e8698ef2adb82fb32467f3514ef8ee2)

在上面的示例中，分子轨道规范（$$\langle$$`MO-spec`$$\rangle$$ ）是

```latex
1sMO={0.75;pair,up}
```

其中

* `0.75` 现在是比率 *（能量增益）/（能量损失）*.
* `成对、上` 分别是成键和反键分子轨道中电子的自旋。

下一个稍微复杂一些的示例将有助于你理解语法：

```latex
\documentclass{article}
\usepackage{modiagram}
\begin{document}
\begin{modiagram}
 \atom{left}{
      1s, 2s, 2p = {;pair,up,up}
  }
  \atom{right}{
      1s, 2s, 2p = {;pair,up,up}
  }
  \molecule{
      1sMO, 2sMO, 2pMO = {;pair,pair,pair,up,up}
  }
\end{modiagram}
\end{document}
```

[在 Overleaf 中打开此示例](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=More+elaborate+modiagram+example\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cusepackage%7Bmodiagram%7D%0A%5Cbegin%7Bdocument%7D%0A%5Cbegin%7Bmodiagram%7D%0A+%5Catom%7Bleft%7D%7B%0A++++++1s%2C+2s%2C+2p+%3D+%7B%3Bpair%2Cup%2Cup%7D%0A++%7D%0A++%5Catom%7Bright%7D%7B%0A++++++1s%2C+2s%2C+2p+%3D+%7B%3Bpair%2Cup%2Cup%7D%0A++%7D%0A++%5Cmolecule%7B%0A++++++1sMO%2C+2sMO%2C+2pMO+%3D+%7B%3Bpair%2Cpair%2Cpair%2Cup%2Cup%7D%0A++%7D%0A%5Cend%7Bmodiagram%7D%0A%5Cend%7Bdocument%7D)

此示例生成如下输出：

![分子轨道详细示例](/files/7672e27f972a12b7a6a9b345d6e80ef70c9e17b3)

图的每一侧各设置了三个原子，中间是对应的分子。

## 命名方案

下图转载自 [`modiagram` 宏包](https://ctan.org/pkg/modiagram?lang=en) 文档。它包含用于轨道的名称（标签），这些名称是 `tikzpicture` 中的节点，因此可在标准 TikZ 绘图命令中使用，位于一个 `modiagram` 环境中。

![modiagram 轨道名称](/files/010ec8a051c74552ffb65ef5cae0c174e8f830b4)

下面是一个使用反键轨道名称的示例 `1sigma*` 用于相对定位。

```latex
\documentclass{article}
\usepackage{modiagram}
\begin{document}
\begin{modiagram}
 \atom{left}{1s}
 \atom{right}{1s={;up}}
 \molecule{
    1sMO={;pair,up}
 }
 \draw[<-,shorten <=8pt,shorten >=15pt,blue]
 (1sigma*) --++(2,1) node {anti-bonding MO};
\end{modiagram}
\end{document}
```

[在 Overleaf 中打开此示例。](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=Using+orbital+labels+in+an+modiagram+environment\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cusepackage%7Bmodiagram%7D%0A%5Cbegin%7Bdocument%7D%0A%5Cbegin%7Bmodiagram%7D%0A+%5Catom%7Bleft%7D%7B1s%7D%0A+%5Catom%7Bright%7D%7B1s%3D%7B%3Bup%7D%7D%0A+%5Cmolecule%7B%0A++++1sMO%3D%7B%3Bpair%2Cup%7D%0A+%7D%0A+%5Cdraw%5B%3C-%2Cshorten+%3C%3D8pt%2Cshorten+%3E%3D15pt%2Cblue%5D%0A+%281sigma%2A%29+--%2B%2B%282%2C1%29+node+%7Banti-bonding+MO%7D%3B%0A%5Cend%7Bmodiagram%7D%0A%5Cend%7Bdocument%7D)

此示例生成如下输出：

![反键轨道示例](/files/bb4ef24509efd9e6f17163bc243576e32a2d6546)

## 进一步阅读

更多信息请参见：

* [化学公式](/latex/zh-cn/te-ding-ling-yu/02-chemistry-formulae.md)
* [费曼图](/latex/zh-cn/te-ding-ling-yu/03-feynman-diagrams.md)
* [TikZ 宏包](/latex/zh-cn/tu-xing-he-biao-ge/05-tikz-package.md)
* [在 LaTeX 中直接绘制图表](/latex/zh-cn/tu-xing-he-biao-ge/04-picture-environment.md)
* [插入图片](/latex/zh-cn/geng-duo-zhu-ti/27-inserting-images.md)
* [希腊字母和数学符号列表](/latex/zh-cn/shu-xue/11-list-of-greek-letters-and-math-symbols.md)
* [该 `modiagram` manual](http://mirrors.ctan.org/macros/latex/contrib/modiagram/modiagram_en.pdf)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://ayakaleaf-pro.ayaka.space/latex/zh-cn/te-ding-ling-yu/04-molecular-orbital-diagrams.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
