latex minipage 的使用

今天整理了下想实现一个2*2图片排列的效果。minipage的代码如下:

\begin{figure}
%\begin{tabular}{cc}   
\begin{minipage}{0.48\linewidth}
  \centerline{\includegraphics[width=4.0cm]{image1.jpg}}
  \centerline{(a) Result 1}
\end{minipage}
\hfill
\begin{minipage}{.48\linewidth}
  \centerline{\includegraphics[width=4.0cm]{image2.jpg}}
  \centerline{(b) Results 2}
\end{minipage}
\vfill
\begin{minipage}{0.48\linewidth}
  \centerline{\includegraphics[width=4.0cm]{image3.jpg}}
  \centerline{(c) Result 3}
\end{minipage}
\hfill
\begin{minipage}{0.48\linewidth}
  \centerline{\includegraphics[width=4.0cm]{image4.jpg}}
  \centerline{(d) Result 4}
\end{minipage}
%\end{tabular}
\caption{Example of placing a figure with experimental results.}
\label{fig:res}
\end{figure}
发现有\vfill 与空行的效果完全一样,一般在使用的过程中,每弄一个minipage,最好都使用\vfill or \hfill来表达下一张图片与上一张图片 的关系,是上下排的关系还是并排的关系。

当然还可以使用

\begin{figure*}
\end{figure*}来破栏,因为好多paper的格式是双栏的,所以有时候放图片可以破栏放置。
当然图片属性还有如下的格式
\begin{figure}[bhtp]
\end{figure}
 在这里补充说一下浮动图形figure环境, 它能自动调整图形在页 面中出现的位置: 
\begin{figure}[位置] 
\caption{图的标题} 
\end{figure} 
这里[位置]可以是h(当前位置),t(页顶),b(页底),p(另页),如果前面加了个!(感叹号),那么则是忽略
美学标准,强制排列了.
 
 

 

### 使用 `minipage` 实现多图多排布局 为了在 LaTeX 中实现多张图片以多排形式展示,可以利用 `minipage` 环境来控制每张图片的位置和大小。下面是一个具体的例子,展示了如何通过嵌套多个 `minipage` 来创建两行三列的图像布局。 #### 完整代码示例 ```latex \documentclass{article} \usepackage{graphicx} \begin{document} % 开始 figure 环境定义整体图形区域 \begin{figure}[htbp] \centering % 第一排三个子图 \begin{minipage}{0.32\textwidth} \centering \includegraphics[width=\linewidth]{example-image-a} \subcaption{First image (A)} \end{minipage}% \hfill \begin{minipage}{0.32\textwidth} \centering \includegraphics[width=\linewidth]{example-image-b} \subcaption{Second image (B)} \end{minipage}% \hfill \begin{minipage}{0.32\textwidth} \centering \includegraphics[width=\linewidth]{example-image-c} \subcaption{Third image (C)} \end{minipage}\\[\baselineskip] % 第二排三个子图 \begin{minipage}{0.32\textwidth} \centering \includegraphics[width=\linewidth]{example-image-a} \subcaption{Fourth image (D)} \end{minipage}% \hfill \begin{minipage}{0.32\textwidth} \centering \includegraphics[width=\linewidth]{example-image-b} \subcaption{Fifth image (E)} \end{minipage}% \hfill \begin{minipage}{0.32\textwidth} \centering \includegraphics[width=\linewidth]{example-image-c} \subcaption{Sixth image (F)} \end{minipage} % 整体标题与标签 \caption{Multiple images arranged in two rows and three columns using the minipage environment. Each sub-figure has its own caption provided by \texttt{\textbackslash{}subcaption}.} \label{fig:multipanel_images_minipage} \end{figure} \end{document} ``` 在这个例子中: - `\begin{minipage}` 和 `\end{minipage}` 用来指定每个独立的小环境。 - `{0.32\textwidth}` 表示每个 `minipage` 的宽度占文档文本宽度的大约三分之一[^4]。 - `%` 符号用于防止额外空白影响排版效果;`\hfill` 则是在各 `minipage` 之间添加水平填充空间使它们均匀分布。 - `\\[\baselineskip]` 创建了一个新行,并增加了适当间距以便区分不同行之间的图片。 - `\subcaption` 提供给各个子图各自的描述文字。 此方法允许灵活调整每一幅图的具体尺寸以及整个图表区间的相对位置关系,非常适合处理复杂的图文混排需求。
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值