LaTeX如何实现子图标题居左上角、总图题位于图片右侧
LaTeX子图组排版实现
需求说明
使用LaTeX撰写报告时需要实现指定排版效果:
- 子标题(a)、(b)、(c)对齐至对应子图的左上角
- 整张图组的总标题位于图组右侧
- 目标效果:

此前尝试使用floatrow、subfig/subcaption宏包配置未达到预期,原有最小工作示例代码如下:
\documentclass{article} \usepackage[demo]{graphicx} \usepackage{floatrow} \usepackage{subfig} \floatsetup[figure]{style=plain,subcapbesideposition=top} \begin{figure*} \ffigbox[\FBwidth] {\begin{subfloatrow} \sidesubfloat[]{\includegraphics[width=.5\linewidth]{image1}\label{fig:a}}% \sidesubfloat[]{\includegraphics[width=.5\linewidth]{image2}\label{fig:b}}% \end{subfloatrow}} {\caption{Two figures}\label{}} \end{figure*} \end{document}
修正方案
原有代码缺少总标题位置的相关配置,同时没有为侧边标题预留显示空间,调整后可直接运行的完整代码如下:
\documentclass{article} \usepackage[demo]{graphicx} \usepackage{floatrow} \usepackage{subfig} % 浮动体全局配置 \floatsetup[figure]{ style=plain, subcapbesideposition=topleft, % 子标题对齐到子图左上角 capposition=beside, % 总标题放置在图组侧边 capbesideposition=right, % 侧边标题居右放置 capbesidealign=top, % 总标题与图组顶部对齐 capbesidewidth=0.2\linewidth % 配置右侧标题的占用宽度 } \begin{document} \begin{figure*} \ffigbox[0.78\linewidth]% 图组占用宽度,剩余宽度留给右侧标题 {\begin{subfloatrow} \sidesubfloat[]{\includegraphics[width=.38\linewidth]{image1}\label{fig:a}}% \hfill \sidesubfloat[]{\includegraphics[width=.38\linewidth]{image2}\label{fig:b}}% % 如需第三张子图,按相同格式添加即可 \end{subfloatrow}} {\caption{填写图组总标题,将自动显示在图组右侧顶部位置}\label{fig:fullgroup}} \end{figure*} \end{document}
关键配置说明
subcapbesideposition=topleft:精准控制子标签(a)(b)对齐到子图的左上角位置capbesidewidth:单独指定右侧标题的占用宽度,避免标题内容折行异常- 子图间使用
\hfill自动填充间距,无需手动调整距离,适配不同页面宽度 - 可根据实际子图数量,按比例调整单张子图的宽度参数即可
内容的提问来源于stack exchange,提问作者NDO
相关产品推荐
相关产品推荐

