Latex 中如何使插图的位置不跑到开头而紧跟插入的文字后

使用Latex编辑时常遇到这样一个问题,当插入图片时,图片的位置总是会自动跑到当页的最上方,有时很不合意。 如果想让插入的图片紧跟在文字后面可以用以下方法:

首先,在编辑器头部加入宏包   \usepackage{float}
然后,在插入图片的语句后加个[H]即可,如:
\begin{figure}[H]


本文转自:http://blog.sina.com.cn/s/blog_64827e4c0100up7l.html

### 插入图片的方法 在 TeX/LaTeX 文档中插入图片通常通过 `graphicx` 宏包来实现。该宏包提供了 `\includegraphics` 命令用于实际插入图像文件[^1]。 #### 使用 figure 环境插入单张图片 为了使图片成为浮动体并可以添加标题标签,应将 `\includegraphics` 放置于 `figure` 环境内: ```latex \begin{figure}[htbp] \centering \includegraphics[width=0.8\textwidth]{imagefile1} \caption{描述这张图的内容} \label{fig:imagefile1} \end{figure} ``` 这里指定了宽度为文本宽度的 80%,可以根据需求调整此参数;同时定义了一个标签以便后续引用。 #### 设置图片路径 为了避免频繁输入完整的相对或绝对路径名,在导言区设置默认目录是一个好办法。这可以通过 `graphicx` 提供的 `\graphicspath` 来完成。下面的例子设定了一个名为 figs 的子文件夹作为存储位置: ```latex \usepackage{graphicx} \graphicspath{{figs/}} ``` 这样就可以只写文件名而需要每次都带上完整路径了[^2]。 #### 实现多幅图片并列显示 如果想要在同一行内展示多个图形,则可借助额外工具如 `subfigure` 或者较新的替代方案 `subcaption` 宏包。以下是利用后者的一个例子: ```latex \documentclass{article} \usepackage{graphicx} \usepackage{subcaption} \begin{document} \begin{figure}[htbp] \centering \begin{subfigure}{0.45\textwidth} \includegraphics[width=\linewidth]{imagefileA} \caption{左图说明} \label{fig:imagefileA} \end{subfigure} \hfill \begin{subfigure}{0.45\textwidth} \includegraphics[width=\linewidth]{imagefileB} \caption{右图说明} \label{fig:imagefileB} \end{subfigure} \caption{(a) (b) 是两张同的图表} \end{figure} \end{document} ``` 上述代码创建了一组由两个独立编号的小图为一组的大图,并为其整体以及各部分分别设置了说明文字
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值