> 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/tu-xing-he-biao-ge/04-picture-environment.md).

# 直接在 LaTeX 中绘制图表

## 引言

LaTeX 内置的 `picture` 环境可用于创建图表/图形——你不需要 *需要* 加载任何外部宏包即可使用它，但像以下宏包这样的包： [`pict2e`](https://ctan.org/pkg/pict2e?lang=en) 和 [`picture`](https://ctan.org/pkg/picture) 是为了增强或改进其功能而编写的。

本文对 `picture` 环境作简要介绍，所有示例都使用 [`pict2e` 宏包](https://ctan.org/pkg/pict2e?lang=en)。更详尽的文档和一系列有用的示例可在以下资源中轻松找到：

* [LaTeX2e 非官方参考手册](https://latexref.xyz/picture.html)
* [《LaTeX2ε 不太短的介绍》](https://tobi.oetiker.ch/lshort/lshort.pdf) （见第 5 章）
* [Wikibooks](https://en.wikibooks.org/wiki/LaTeX/Picture)
* [带有标签的提问 `picture-mode` 在 tex.stackexchange 上](https://tex.stackexchange.com/questions/tagged/picture-mode)
* [`pict2e` 包文档](https://mirror.ox.ac.uk/sites/ctan.org/macros/latex/contrib/pict2e/pict2e.pdf)

与功能强大且复杂的图形工具如 [TikZ/PGF](https://en.wikipedia.org/wiki/PGF/TikZ), [MetaPost](https://tug.org/metapost.html), [PSTricks](https://ctan.org/topic/pstricks?lang=en) 或 [Asymptote](https://ctan.org/pkg/asymptote?lang=en) 该 `picture` 环境看起来可能相当有限，但有时它足以满足你的需求。

## 创建新的 picture

创建新的 picture 通常包括以下步骤：

1. 定义你希望使用的绘图单位大小；
2. 声明一个 `picture` 定义图形尺寸的环境；
3. 使用以下命令绘制各个图形组件： `\put`, `\multiput` 或 `\qbezier` 命令。

### 定义绘图单位的大小

要创建一幅图，你通常先设置 *绘图单位* 通过命令 `\unitlength`，它必须在 `picture` 环境外使用。例如，如果你写

```latex
\setlength{\unitlength}{1cm}
```

绘图单位将被解释为 1cm 的倍数。默认单位是 1pt。

### 定义你的图形尺寸

其一般形式为 `picture` 环境如下

```latex
\begin{picture}(width, height)(Xoffset, Yoffset)
 ...
\end{picture}
```

其中

* `width` 和 `高度` 是以 `\unitlength`为单位的值，用于定义图形的尺寸。LaTeX 使用这些值创建一个框，其尺寸为
  * 框（图形）宽度 = `width` × `\unitlength`
  * 框（图形）高度 = `高度` × `\unitlength`
* `(Xoffset, Yoffset)` 是一个可选坐标，用于设置图形的原点（左下角），表示为相对于默认位置的 *偏移量* 。 `Xoffset` 和 `Yoffset` 也以当前 `\unitlength`.

请注意 `Xoffset` 和 `Yoffset` 的值所决定的单位表示，并不会影响 LaTeX 预留的空间量；也就是框的尺寸。

#### 理解图形尺寸

我们将创建两个图形，都使用 `\setlength{\unitlength}{1cm}` ，并且每个都具有一个 `width` 和 `高度` 为 3 个单位的

第一个图形使用默认原点 `(0,0)`:

```latex
\begin{picture}(3,3)
...
\end{picture}
```

第二个图形将原点偏移（平移） `(1,1)`:

```latex
\begin{picture}(3,3)(1,1)
...
\end{picture}
```

### 绘制图形

图形是通过一系列 `\put`, `\multiput`，或 `\qbezier` 命令创建的，这些命令生成构成图形或插图的各个“组件”（或“对象”）：

* `\put(x, y){*component*}` 绘制 `*component*` 在位置 `(x, y)`.
* `\multiput(x, y)(dx, dy){n}{*component*}` 绘制 `*component*` `n` 次：从位置 `(x, y)` 开始，并反复平移 `(dx, dy)` 以重新绘制 `*component*`.
* `\qbezier[n](x<sub>1</sub>, y<sub>1</sub>)(x, y)(x<sub>2</sub>, y<sub>2</sub>)`：绘制一条 [二次贝塞尔曲线](https://en.wikipedia.org/wiki/B%C3%A9zier_curve#Quadratic_B%C3%A9zier_curves) 其中：
  * `n` 一个可选整数，用于确定绘制/生成曲线时所使用的点数
  * `(x<sub>1</sub>, y<sub>1</sub>)` 是曲线的起点
  * `(x<sub>2</sub>, y<sub>2</sub>)` 是曲线的终点
  * `(x, y)` 表示（二次）贝塞尔曲线的控制点

一个 `*component*` 是一个图形元素，通常使用如下图形原语生成： `\line`, `\oval`, `\circle`, `\vector` 等等——参见 [LaTeX2e 非官方参考手册](https://latexref.xyz/picture.html) 或 [《LaTeX2ε 不太短的介绍》](https://tobi.oetiker.ch/lshort/lshort.pdf) （第 5 章）了解可用原语的详细信息。

**注意**： [`pict2e` 宏包](https://mirror.ox.ac.uk/sites/ctan.org/macros/latex/contrib/pict2e/pict2e.pdf) 扩展了原始的 `picture` 环境，提供若干用于绘制贝塞尔曲线的命令： `\bezier`, `\qbezier`, `\cbezier` 和 `\qbeziermax`.

### 理解偏移量和原点

在以下示例中， `\put` 命令用于绘制彩色点，以标示图形中的关键坐标（位置）。两个示例都使用 LaTeX 的 `\fbox` 命令在 LaTeX 为容纳我们的图形而创建的框周围绘制边框，显示 *边界框* 。

**示例 1：使用默认原点**

```latex
\documentclass{article}
\usepackage[pdftex]{pict2e}
\usepackage[dvipsnames]{xcolor}
\begin{document}
\setlength{\unitlength}{1cm}
\setlength{\fboxsep}{0pt}

这是我的图形\fbox{%
\begin{picture}(3,3)
\put(0,0){{\color{blue}\circle*{0.25}}\hbox{\kern3pt \texttt{(0,0)}}}
\put(3,3){{\color{red}\circle*{0.25}}\hbox{\kern3pt \texttt{(3,3)}}}
\end{picture}}
\end{document}
```

[在 Overleaf 中打开此示例](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=understanding+picture+dimensions+example+1\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cusepackage%5Bpdftex%5D%7Bpict2e%7D%0A%5Cusepackage%5Bdvipsnames%5D%7Bxcolor%7D%0A%5Cbegin%7Bdocument%7D%0A%5Csetlength%7B%5Cunitlength%7D%7B1cm%7D%0A%5Csetlength%7B%5Cfboxsep%7D%7B0pt%7D%0A%0AThis+is+my+picture%5Cfbox%7B%25%0A%5Cbegin%7Bpicture%7D%283%2C3%29%0A%5Cput%280%2C0%29%7B%7B%5Ccolor%7Bblue%7D%5Ccircle%2A%7B0.25%7D%7D%5Chbox%7B%5Ckern3pt+%5Ctexttt%7B%280%2C0%29%7D%7D%7D%0A%5Cput%283%2C3%29%7B%7B%5Ccolor%7Bred%7D%5Ccircle%2A%7B0.25%7D%7D%5Chbox%7B%5Ckern3pt+%5Ctexttt%7B%283%2C3%29%7D%7D%7D%0A%5Cend%7Bpicture%7D%7D%0A%5Cend%7Bdocument%7D)

此示例生成如下输出：

![LaTeX picture 环境的尺寸](/files/c829e1ee7ee324cd51ff5dbf8e104f1129f43209)

该 `\fbox` 命令在图形的边界框周围绘制边框，显示 LaTeX 预留的空间（区域）：

* 图形宽度 = `width` × `\unitlength` = 3 × 1cm = 3cm。
* 图形高度 = `高度` × `\unitlength` = 3 × 1cm = 3cm。

第一个示例表明，原点 `(0,0)`，位于 `\begin{picture}` 命令执行的位置，也就是文本“这是我的图形”之后紧接着的位置。此外，右上角位于 `(3,3)`， `(width,height)` 由以下参数给出的 `\begin{picture}(3,3)`.

**示例 2：将原点偏移 (1,1)**

```latex
\documentclass{article}
\usepackage[pdftex]{pict2e}
\usepackage[dvipsnames]{xcolor}
\begin{document}
\setlength{\unitlength}{1cm}
\setlength{\fboxsep}{0pt}

这是我的图形\fbox{%
\begin{picture}(3,3)(1,1)
\put(0,0){{\color{blue}\circle*{0.25}}\hbox{\kern3pt\texttt{(0,0)}}}
\put(1,1){{\color{orange}\circle*{0.25}}\hbox{\kern3pt\texttt{(1,1)}}}
\put(3,3){{\color{red}\circle*{0.25}}\hbox{\kern3pt\texttt{(3,3)}}}
\put(4,4){{\color{black}\circle*{0.25}}\hbox{\kern3pt\texttt{(4,4)}}}
\end{picture}}
\end{document}
```

[在 Overleaf 中打开此示例](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=understanding+picture+dimensions+example+2\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cusepackage%5Bpdftex%5D%7Bpict2e%7D%0A%5Cusepackage%5Bdvipsnames%5D%7Bxcolor%7D%0A%5Cbegin%7Bdocument%7D%0A%5Csetlength%7B%5Cunitlength%7D%7B1cm%7D%0A%5Csetlength%7B%5Cfboxsep%7D%7B0pt%7D%0A%0AThis+is+my+picture%5Cfbox%7B%25%0A%5Cbegin%7Bpicture%7D%283%2C3%29%281%2C1%29%0A%5Cput%280%2C0%29%7B%7B%5Ccolor%7Bblue%7D%5Ccircle%2A%7B0.25%7D%7D%5Chbox%7B%5Ckern3pt%5Ctexttt%7B%280%2C0%29%7D%7D%7D%0A%5Cput%281%2C1%29%7B%7B%5Ccolor%7Borange%7D%5Ccircle%2A%7B0.25%7D%7D%5Chbox%7B%5Ckern3pt%5Ctexttt%7B%281%2C1%29%7D%7D%7D%0A%5Cput%283%2C3%29%7B%7B%5Ccolor%7Bred%7D%5Ccircle%2A%7B0.25%7D%7D%5Chbox%7B%5Ckern3pt%5Ctexttt%7B%283%2C3%29%7D%7D%7D%0A%5Cput%284%2C4%29%7B%7B%5Ccolor%7Bblack%7D%5Ccircle%2A%7B0.25%7D%7D%5Chbox%7B%5Ckern3pt%5Ctexttt%7B%284%2C4%29%7D%7D%7D%0A%5Cend%7Bpicture%7D%7D%0A%5Cend%7Bdocument%7D)

此示例生成如下输出：

![LaTeX picture 环境的尺寸](/files/d75ff4b32f5b539bd2f7d7838bfd1822b50f9542)

第二个示例展示了移动原点的效果，并突出了一些关键点：

* 由 `\fbox` 显示图形的边界框，也就是 LaTeX 创建的框的宽度和高度， *不受影响* ；移动原点并不会改变它：它仍然由 `(width,height)` 由以下参数给出的 `\begin{picture}(3,3)(1,1)`
  * 图形宽度 = `width` × `\unitlength` = 3 × 1cm = 3cm
  * 图形高度 = `高度` × `\unitlength` = 3 × 1cm = 3cm
* 绘图元素并不受 LaTeX 创建的区域（边界框尺寸）限制（裁剪）。例如，蓝点和 `(0,0)` 坐标被绘制在由 `\fbox`生成的边界线之外，该边界线表示边界框。
  * 需要由用户自行确保绘图元素保持在边界框内，并且不覆盖周围文本。
* 原点， `(0,0)`，是 *不再* 位于文本“这是我的图形”之后紧接着的位置，也就是 `\begin{picture}` 命令执行的位置：原点现在向左移动 1 个单位，并向下移动 1 个单位
* 右上角现在位于 `(4,4)`

## picture 环境示例

### 来自 LaTeX2e 非官方参考手册的示例

该 [LaTeX2e 非官方参考手册](https://latexref.xyz/picture.html) 包含若干 `picture` 环境示例，其中一些在此重现，并附有可在 Overleaf 中打开的链接，方便你编辑和探索代码。

#### 示例 1：\vector 命令

```latex
\documentclass{article}
\usepackage[pdftex]{pict2e}
\begin{document}
\setlength{\unitlength}{1cm}
\begin{picture}(6,6)      % picture box will be 6cm wide by 6cm tall
  \put(0,0){\vector(2,1){4}}  % for every 2 over this vector goes 1 up
    \put(2,1){\makebox(0,0)[l]{\ first leg}}
  \put(4,2){\vector(1,2){2}}
    \put(5,4){\makebox(0,0)[l]{\ second leg}}
  \put(0,0){\vector(1,1){6}}
    \put(3,3){\makebox(0,0)[r]{sum\ }}
\end{picture}
\end{document}
```

[在 Overleaf 中打开此示例](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=picture+environment+example\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cusepackage%5Bpdftex%5D%7Bpict2e%7D%0A%5Cbegin%7Bdocument%7D%0A%5Csetlength%7B%5Cunitlength%7D%7B1cm%7D%0A%5Cbegin%7Bpicture%7D%286%2C6%29++++++%25+picture+box+will+be+6cm+wide+by+6cm+tall%0A++%5Cput%280%2C0%29%7B%5Cvector%282%2C1%29%7B4%7D%7D++%25+for+every+2+over+this+vector+goes+1+up%0A++++%5Cput%282%2C1%29%7B%5Cmakebox%280%2C0%29%5Bl%5D%7B%5C+first+leg%7D%7D%0A++%5Cput%284%2C2%29%7B%5Cvector%281%2C2%29%7B2%7D%7D%0A++++%5Cput%285%2C4%29%7B%5Cmakebox%280%2C0%29%5Bl%5D%7B%5C+second+leg%7D%7D++%0A++%5Cput%280%2C0%29%7B%5Cvector%281%2C1%29%7B6%7D%7D%0A++++%5Cput%283%2C3%29%7B%5Cmakebox%280%2C0%29%5Br%5D%7Bsum%5C+%7D%7D++%0A%5Cend%7Bpicture%7D%0A%5Cend%7Bdocument%7D)

此示例生成如下输出：

![picture 环境示例](/files/460bcad61742248ba1646b79a4e2bd75d1fec4b7)

#### 示例 2：\qbezier、\line、\vector、\thinlines 和 \thicklines 命令

注意 `\qbezier` 命令 *并未* 在 `\put{...}` 中使用，而其他原始命令，如 `\line`, `\vector` *已* 在 `\put{...}`.

```latex
\documentclass{article}
\usepackage[pdftex]{pict2e}
\begin{document}
\setlength{\unitlength}{1cm}
\begin{picture}(8,4)
  \thinlines % Start with thin lines
  \put(0,0){\vector(1,0){8}}  % x axis
  \put(0,0){\vector(0,1){4}}  % y axis
  \put(2,0){\line(0,1){3}}    % left side
  \put(4,0){\line(0,1){3.5}}  % right side
  \thicklines % Use thicker lines for the \qbezier commands
  \qbezier(2,3)(2.5,2.9)(3,3.25)
  \qbezier(3,3.25)(3.5,3.6)(4,3.5)
  \thinlines % Back to using thin lines
  \put(2,3){\line(4,1){2}}
  \put(4.5,2.5){\framebox{Trapezoidal Rule}}
\end{picture}
\end{document}
```

[在 Overleaf 中打开此示例](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=qbezier+picture+environment+example\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cusepackage%5Bpdftex%5D%7Bpict2e%7D%0A%5Cbegin%7Bdocument%7D%0A%5Csetlength%7B%5Cunitlength%7D%7B1cm%7D%0A%5Cbegin%7Bpicture%7D%288%2C4%29%0A++%5Cthinlines+%25+Start+with+thin+lines%0A++%5Cput%280%2C0%29%7B%5Cvector%281%2C0%29%7B8%7D%7D++%25+x+axis%0A++%5Cput%280%2C0%29%7B%5Cvector%280%2C1%29%7B4%7D%7D++%25+y+axis%0A++%5Cput%282%2C0%29%7B%5Cline%280%2C1%29%7B3%7D%7D++++%25+left+side%0A++%5Cput%284%2C0%29%7B%5Cline%280%2C1%29%7B3.5%7D%7D++%25+right+side%0A++%5Cthicklines+%25+Use+thicker+lines+for+the+%5Cqbezier+commands%0A++%5Cqbezier%282%2C3%29%282.5%2C2.9%29%283%2C3.25%29%0A++%5Cqbezier%283%2C3.25%29%283.5%2C3.6%29%284%2C3.5%29%0A++%5Cthinlines+%25+Back+to+using+thin+lines%0A++%5Cput%282%2C3%29%7B%5Cline%284%2C1%29%7B2%7D%7D%0A++%5Cput%284.5%2C2.5%29%7B%5Cframebox%7BTrapezoidal+Rule%7D%7D%0A%5Cend%7Bpicture%7D%0A%5Cend%7Bdocument%7D)

此示例生成如下输出：

![LaTeX picture 环境示例](/files/e94d8a63cf050b4549d88cdbaeac133bf2b761ff)

#### 示例 3：\multiput 和 \linethickness 命令

```latex
\documentclass{article}
\usepackage[pdftex]{pict2e}
\begin{document}
\setlength{\unitlength}{1cm}
\thicklines
\begin{picture}(10,10)
  \linethickness{0.05mm}
  \multiput(0,0)(1,0){10}{\line(0,1){10}}
  \multiput(0,0)(0,1){10}{\line(1,0){10}}
  \linethickness{0.5mm}
  \multiput(0,0)(5,0){3}{\line(0,1){10}}
  \multiput(0,0)(0,5){3}{\line(1,0){10}}
\end{picture}
\end{document}
```

[在 Overleaf 中打开此示例](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=multiput+command+picture+environment+example\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cusepackage%5Bpdftex%5D%7Bpict2e%7D%0A%5Cbegin%7Bdocument%7D%0A%5Csetlength%7B%5Cunitlength%7D%7B1cm%7D%0A%5Cthicklines%0A%5Cbegin%7Bpicture%7D%2810%2C10%29%0A++%5Clinethickness%7B0.05mm%7D%0A++%5Cmultiput%280%2C0%29%281%2C0%29%7B10%7D%7B%5Cline%280%2C1%29%7B10%7D%7D+%0A++%5Cmultiput%280%2C0%29%280%2C1%29%7B10%7D%7B%5Cline%281%2C0%29%7B10%7D%7D%0A++%5Clinethickness%7B0.5mm%7D%0A++%5Cmultiput%280%2C0%29%285%2C0%29%7B3%7D%7B%5Cline%280%2C1%29%7B10%7D%7D%0A++%5Cmultiput%280%2C0%29%280%2C5%29%7B3%7D%7B%5Cline%281%2C0%29%7B10%7D%7D%0A%5Cend%7Bpicture%7D%0A%5Cend%7Bdocument%7D)

此示例生成如下输出：

![\multiput 命令 LaTeX picture 环境示例](/files/50787d25b7fa5c653a814a4dd1a048a28bf00788)

### 其他示例

#### 一个基本的贝塞尔曲线

下面的示例使用 `\qbezier` 用于绘制贝塞尔曲线的命令：

```latex
\qbezier(1,1)(5,5)(9,0.5)
```

请注意以下几点：

* 该 `\qbezier` 命令未在 `\put` 命令
* 贝塞尔曲线的起点是 `(1,1)`
* 贝塞尔曲线的终点是 `(9,0.5)`
* 贝塞尔曲线的控制点是 `(5,5)`
* 我们没有使用用于确定绘制/生成贝塞尔曲线时所用点数的可选整数

```latex
\documentclass{article}
\usepackage[pdftex]{pict2e}
\begin{document}
\setlength{\unitlength}{0.8cm}
\begin{picture}(10,5)
\thicklines
\qbezier(1,1)(5,5)(9,0.5)
\put(2,1){{Bézier curve}}
\end{picture}
\end{document}
```

[在 Overleaf 中打开此示例](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=multiput+command+picture+environment+example\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cusepackage%5Bpdftex%5D%7Bpict2e%7D%0A%5Cbegin%7Bdocument%7D%0A%5Csetlength%7B%5Cunitlength%7D%7B0.8cm%7D%0A%5Cbegin%7Bpicture%7D%2810%2C5%29%0A%5Cthicklines%0A%5Cqbezier%281%2C1%29%285%2C5%29%289%2C0.5%29%0A%5Cput%282%2C1%29%7B%7BB%C3%A9zier+curve%7D%7D%0A%5Cend%7Bpicture%7D%0A%5Cend%7Bdocument%7D)

此示例生成如下输出：

![使用 LaTeX 绘制贝塞尔曲线](/files/579503f4f023e8e29ee09512f66d0947b462a6ce)

#### 椭圆、线条和圆

以下示例演示了 `\line`, `\circle` 和 `\oval` 命令——请注意它们如何 *已* 都在 `\put{...}` 命令：

```latex
\documentclass{article}
\usepackage[pdftex]{pict2e}
\begin{document}
\setlength{\unitlength}{1cm}
\thicklines
\begin{picture}(10,6)
\put(2,2.2){\line(1,0){6}}
\put(2,2.2){\circle{2}}
\put(6,2.2){\oval(4,2)[r]}
\end{picture}
\end{document}
```

[在 Overleaf 中打开此示例](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=picture+environment+example\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cusepackage%5Bpdftex%5D%7Bpict2e%7D%0A%5Cbegin%7Bdocument%7D%0A%5Csetlength%7B%5Cunitlength%7D%7B1cm%7D%0A%5Cthicklines%0A%5Cbegin%7Bpicture%7D%2810%2C6%29%0A%5Cput%282%2C2.2%29%7B%5Cline%281%2C0%29%7B6%7D%7D%0A%5Cput%282%2C2.2%29%7B%5Ccircle%7B2%7D%7D%0A%5Cput%286%2C2.2%29%7B%5Coval%284%2C2%29%5Br%5D%7D%0A%5Cend%7Bpicture%7D%0A%5Cend%7Bdocument%7D)

此示例生成如下输出：

![LaTeX picture 环境示例](/files/b97bccb3327fe0f4d0ab994844427e8477688f22)

下面是这些命令的说明：

* `\put(2,2.2){\line(1,0){6}}`：绘制一条线 `6` 个单位长，使用“方向向量” `(1,0)`
* `\put(6,2.2){\oval(4,2)[r]}`：绘制一个以该点为中心的椭圆 `(4,2)`。参数 `[r]` 是可选的，你可以使用 `r`, `l`, `t` 和 `b` 来显示椭圆的右、左、上或下部分。
* `\put(2,2.2){\circle{2}}`：绘制一个以该点为中心的圆 `(2,2.2)` 其直径为 `2`.

#### 组合线条、圆和文本

不同的基本元素可以组合成更复杂的图形。在这个示例中，若干线条和圆被组合成一个图形，并配有文本来标注各个点：

```latex
\documentclass{article}
\usepackage[pdftex]{pict2e}
\begin{document}
\setlength{\unitlength}{0.8cm}
\begin{picture}(12,4)
\thicklines
\put(8,3.3){{\footnotesize $3$-simplex}}
\put(9,3){\circle*{0.1}}
\put(8.3,2.9){$a_2$}
\put(8,1){\circle*{0.1}}
\put(7.7,0.5){$a_0$}
\put(10,1){\circle*{0.1}}
\put(9.7,0.5){$a_1$}
\put(11,1.66){\circle*{0.1}}
\put(11.1,1.5){$a_3$}
\put(9,3){\line(3,-2){2}}
\put(10,1){\line(3,2){1}}
\put(8,1){\line(1,0){2}}
\put(8,1){\line(1,2){1}}
\put(10,1){\line(-1,2){1}}
\end{picture}
\end{document}
```

[在 Overleaf 中打开此示例](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=understanding+picture+dimensions+example+1\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cusepackage%5Bpdftex%5D%7Bpict2e%7D%0A%5Cbegin%7Bdocument%7D%0A%5Csetlength%7B%5Cunitlength%7D%7B0.8cm%7D%0A%5Cbegin%7Bpicture%7D%2812%2C4%29%0A%5Cthicklines%0A%5Cput%288%2C3.3%29%7B%7B%5Cfootnotesize+%243%24-simplex%7D%7D%0A%5Cput%289%2C3%29%7B%5Ccircle%2A%7B0.1%7D%7D%0A%5Cput%288.3%2C2.9%29%7B%24a_2%24%7D%0A%5Cput%288%2C1%29%7B%5Ccircle%2A%7B0.1%7D%7D%0A%5Cput%287.7%2C0.5%29%7B%24a_0%24%7D%0A%5Cput%2810%2C1%29%7B%5Ccircle%2A%7B0.1%7D%7D%0A%5Cput%289.7%2C0.5%29%7B%24a_1%24%7D%0A%5Cput%2811%2C1.66%29%7B%5Ccircle%2A%7B0.1%7D%7D%0A%5Cput%2811.1%2C1.5%29%7B%24a_3%24%7D%0A%5Cput%289%2C3%29%7B%5Cline%283%2C-2%29%7B2%7D%7D%0A%5Cput%2810%2C1%29%7B%5Cline%283%2C2%29%7B1%7D%7D%0A%5Cput%288%2C1%29%7B%5Cline%281%2C0%29%7B2%7D%7D%0A%5Cput%288%2C1%29%7B%5Cline%281%2C2%29%7B1%7D%7D%0A%5Cput%2810%2C1%29%7B%5Cline%28-1%2C2%29%7B1%7D%7D%0A%5Cend%7Bpicture%7D%0A%5Cend%7Bdocument%7D)

此示例生成如下输出：

![LaTeX picture 环境示例](/files/63e8d1a170420d9fe75dda1b5e9863cd5ad955fc)

以下是所用一些命令的摘要：

* `\thicklines`：这会增加线条的粗细。 `\thinlines` 命令则起相反作用。
* `\put(8,3.3){{\footnotesize $3$-simplex}}`：文本“3-simplex”插入在点 `(8,3.3)`，字体大小设为 `\footnotesize`。同样的命令也用于标注每个点。
* `\put(9,3){\circle*{0.1}}`：这会绘制一个实心圆，圆心位于 `(9,3)` ，直径很小，为 `0.1` （绘图单位），因此可用作一个点。
* `\put(10,1){\line(3,2){1}}`：创建一条从 `(10,1)` 开始、沿着 `(3,2)` 方向绘制、长度为 1（绘图单位）的直线。

#### 使用箭头

箭头也可以在 `picture` 环境中使用，因此这里给出第二个示例：

```latex
\documentclass{article}
\usepackage[pdftex]{pict2e}
\begin{document}
\setlength{\unitlength}{0.20mm}
\begin{picture}(400,250)
\put(75,10){\line(1,0){130}}
\put(75,50){\line(1,0){130}}
\put(75,200){\line(1,0){130}}
\put(120,200){\vector(0,-1){150}}
\put(190,200){\vector(0,-1){190}}
\put(97,120){$\alpha$}
\put(170,120){$\beta$}
\put(220,195){upper state}
\put(220,45){lower state 1}
\put(220,5){lower state 2}
\end{picture}
\end{document}
```

[在 Overleaf 中打开此示例](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=Example+of+arrows+in+LaTeX+picture+environment\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cusepackage%5Bpdftex%5D%7Bpict2e%7D%0A%5Cbegin%7Bdocument%7D%0A%5Csetlength%7B%5Cunitlength%7D%7B0.20mm%7D%0A%5Cbegin%7Bpicture%7D%28400%2C250%29%0A%5Cput%2875%2C10%29%7B%5Cline%281%2C0%29%7B130%7D%7D%0A%5Cput%2875%2C50%29%7B%5Cline%281%2C0%29%7B130%7D%7D%0A%5Cput%2875%2C200%29%7B%5Cline%281%2C0%29%7B130%7D%7D%0A%5Cput%28120%2C200%29%7B%5Cvector%280%2C-1%29%7B150%7D%7D%0A%5Cput%28190%2C200%29%7B%5Cvector%280%2C-1%29%7B190%7D%7D%0A%5Cput%2897%2C120%29%7B%24%5Calpha%24%7D%0A%5Cput%28170%2C120%29%7B%24%5Cbeta%24%7D%0A%5Cput%28220%2C195%29%7Bupper+state%7D%0A%5Cput%28220%2C45%29%7Blower+state+1%7D%0A%5Cput%28220%2C5%29%7Blower+state+2%7D%0A%5Cend%7Bpicture%7D%0A%5Cend%7Bdocument%7D)

此示例生成如下输出：

![LaTeX picture 环境中的箭头示例](/files/0d49dc6fa43bddbc39cf7aa4cdb2011f470e51fd)

该 `\vector` 命令使用与 `\line`:

* `\put(120,200){\vector(0,-1){150}}`：绘制一条向量，其起点是 `(120,200)`，长度为 `150` ，绘制方向为 `(0,-1)`.

## 进一步阅读

更多信息请参见以下资源：

* [LaTeX2e 非官方参考手册](https://latexref.xyz/picture.html)
* [《LaTeX2ε 不太短的介绍》](https://tobi.oetiker.ch/lshort/lshort.pdf) （见第 5 章）
* [Wikibooks](https://en.wikibooks.org/wiki/LaTeX/Picture)
* [带有标签的提问 `picture-mode` 在 tex.stackexchange 上](https://tex.stackexchange.com/questions/tagged/picture-mode)
* [`pict2e` 包文档](https://mirror.ox.ac.uk/sites/ctan.org/macros/latex/contrib/pict2e/pict2e.pdf)
* [TikZ 宏包](/latex/zh-cn/tu-xing-he-biao-ge/05-tikz-package.md)
* [Pgfplots 宏包](/latex/zh-cn/te-ding-ling-yu/08-pgfplots-package.md)
* [图片和表格的定位](/latex/zh-cn/tu-xing-he-biao-ge/02-positioning-images-and-tables.md)
* [表格和图形列表](/latex/zh-cn/tu-xing-he-biao-ge/03-lists-of-tables-and-figures.md)


---

# 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/tu-xing-he-biao-ge/04-picture-environment.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.
