转载请注明出处:小锋学长生活大爆炸 如果本文帮助到了你,欢迎[点赞、收藏、关注]哦~
在 LaTeX 中,subfigure
和 subcaption
都是用于处理多张子图的工具,但它们有显著的区别。以下从功能、兼容性、语法、优势/劣势几个方面详细对比两者。
特性 | subfigure | subcaption |
---|---|---|
宏包状态 | 过时,不再更新 | 现代化的宏包,当前推荐使用 |
依赖性 | 独立宏包 | 基于 caption 宏包 |
功能扩展性 | 功能有限,较为基础 | 功能强大,支持更复杂的布局和样式 |
兼容性 | 不兼容现代宏包(如 hyperref) | 高度兼容,推荐用于新文档 |
subfigure
的例子subfigure
的语法简单,直接通过 \subfigure
命令插入子图:
\documentclass{article}
\usepackage{graphicx}
\usepackage{subfigure}
\begin{document}
\begin{figure}[htbp]
\centering
\subfigure[Subfigure A]{
\includegraphics[width=0.45\linewidth]{example-image-a}
\label{fig:subfig-a}
}
\hfill
\subfigure[Subfigure B]{
\includegraphics[width=0.45\linewidth]{example-image-b}
\label{fig:subfig-b}
}
\caption{Overall caption for the figure.}
\label{fig:overall}
\end{figure}
\end{document}
subcaption
的例子subcaption
的语法基于 subfigure
环境,写法更直观:
\documentclass{article}
\usepackage{graphicx}
\usepackage{subcaption}
\begin{document}
\begin{figure}[htbp]
\centering
\begin{subfigure}[b]{0.45\linewidth}
\centering
\includegraphics[width=\linewidth]{example-image-a}
\caption{Subfigure A}
\label{fig:subfig-a}
\end{subfigure}
\hfill
\begin{subfigure}[b]{0.45\linewidth}
\centering
\includegraphics[width=\linewidth]{example-image-b}
\caption{Subfigure B}
\label{fig:subfig-b}
\end{subfigure}
\caption{Overall caption for the figure.}
\label{fig:overall}
\end{figure}
\end{document}
维度 | subfigure | subcaption |
---|---|---|
子图命令形式 | 使用 \subfigure[caption]{image} | 使用 \begin{subfigure} 环境 |
对齐方式 | 自动对齐,但控制灵活性较低 | 支持更精确的对齐方式,结合 subfigure 宽度 |
兼容性 | 不支持 hyperref,容易与其他宏包冲突 | 高度兼容,支持 hyperref、beamer 等现代宏包 |
图形标注方式 | 子图编号由 \alph 或 \arabic 控制 | 子图编号通过 caption 宏包灵活设置 |
全局样式定制 | 样式固定,扩展性差 | 样式完全由 caption 宏包控制 |
维护状态 | 已不再维护 | 正在维护,官方推荐 |
优势:
劣势:
hyperref
),容易引发冲突。优势:
hyperref
、beamer
)一起使用。caption
宏包)。劣势:
subfigure
。subfigure
也可以胜任。hyperref
、beamer
),建议使用 subcaption
。subcaption
。推荐优先使用 subcaption
,除非有兼容性限制或特定需求需要使用 subfigure
。
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有