图片
上一节
下一节
### 图片
1. tex/chap-3.tex
2. xelatex 支持的图片格式包括
- 矢量图: .pdf .eps
- 位图: .jpg .png .bmp
3. 图片文件放到img目录
4. 插入图片
- 使用环境`figure`
- 使用命令`\centering`,设置位置
- 使用命令`\includegraphics`,引入图片
- 使用命令`\caption`,设置标题,不需要设置序号,标题会自动进入图目录
- 使用命令`\label`,添加标签,(注意:标签不能重复)
```
\begin{figure}[H] % [H] 浮动优先级,当前位置
\centering % 居中
% width=.5\textwidth 文档宽度的0.5
% fig1图片放在img目录下,在此处引用无需img/前缀和图片格式后缀(png, jpg等)
\includegraphics[width=.5\textwidth]{fig1}
\caption{图的标题}
\label{fig:single} % label紧接caption之后,用于引用
\end{figure}
```
5. 引用图片,使用命令`\ref`,引用标签
- `如图\ref{fig:single}所示`

