有时,我们会需要在文档中插入图像。在LaTeX中,使用figure环境和graphicx包插入图片,图片将会被自动编号和标记。
\documentclass{article}
\usepackage{graphicx}
\begin{document}
\begin{figure}
\includepraghics[width=\linewidth]{location_of_img_file}
\caption{description_of_img}
\label{refercence_label}
\end{figure}
Figure\ref{refercence_label} shows something.
\end{document}
注:
-
\includegraphics命令,使用方括号[]传入一个表示图片宽度的参数,使用{}传入图像文件位置 -
\linewidth参数表示图片尺寸适应行宽,尺寸过小的图片将被拉伸,尺寸过大的图片将被压缩 - 文件位置参数,如与
.tex文件在同一目录下,则直接写明文件名,如在.tex所在目录的子目录下则写folder/file_name.png。 -
\caption是出现在图片下方的描述信息 -
\label是不可见的,作为下次引用的标签
插入图片到特定位置
...
\begin{figure}[h!]
...
注:参数意义如下表
| ? | meaning |
|---|---|
| h(here) | same location |
| t(top) | top of page |
| b(bottom) | bottom of page |
| p(page) | on a extra page |
| !(override) | will force the specified location |
常用h!参数即可。
