latex调整caption图表标题行间距、字体大小、左对齐

本文分享了解决LaTeX论文中长标题caption字体大小调整与行间距问题的方法,包括使用captionsetup和fontsize命令,确保图表清晰易读。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

论文模板中设置的caption字体为五号加粗,由于标题太长,多行显示时行间距一直不对,latex小白,探索了两天终于给解决了。


问题解决

刚开始尝试修改模板,虽然也可以实现,但修改后的格式会破坏一些图表上下文之间的间距。考虑到长标题的图表并不多,因此尝试对单个图表进行修改


方法1 :设置\captionsetup

\begin{figure}
	\centering
	\subcaptionbox{}{\includegraphics[scale=0.33]{ExtendedYaleB10_data_tSNE.png}}
	\subcaptionbox{}{\includegraphics[scale=0.33]{ExtendedYaleB10_proposed1_tSNE.png}}
	\subcaptionbox{}{\includegraphics[scale=0.33]{ExtendedYaleB10_proposed2_tSNE.png}}
	\captionsetup{font={small,bf,stretch=1.25},justification=raggedright}
	\caption{Extended Yale B数据集前$10$类实验的t-SNE可视化(a)原始样本;
	(b)SC-LRDG1学习到的亲和矩阵;(c)SC-LRDG2学习到的亲和矩阵}
	\label{fig_ExtYaleB10_Visualization}
\end{figure}

通过\captionsetup{font={small,bf,stretch=1.25}, justification=raggedright} 来进行重新修改caption格式。

  1. 字体设为small(对应五号字体,还有其他选择\tiny\scriptsize\footnotesize\small\normalsize\large\Large\LARGE\huge\Huge)
  2. bf表示加粗显示
  3. stretch=1.25表示1.25倍行距
  4. justification=raggedright设置左对齐,默认情况应该就是左对齐,不齐可能是设置了首部缩进。

由于字体选项中都是固定的,如果需要其他字号,需要手动设置

方法2:\fontsize设置字号

\begin{figure}
	\centering
	\subcaptionbox{}{\includegraphics[scale=0.33]{ExtendedYaleB10_data_tSNE.png}}
	\subcaptionbox{}{\includegraphics[scale=0.33]{ExtendedYaleB10_proposed1_tSNE.png}}
	\subcaptionbox{}{\includegraphics[scale=0.33]{ExtendedYaleB10_proposed2_tSNE.png}}
	\captionsetup{font={bf},justification=raggedright}
	\caption{\fontsize{10.5bp}{17bp}Extended Yale B数据集前$10$类实验的t-SNE可视化(a)原始样本;
	(b)SC-LRDG1学习到的亲和矩阵;(c)SC-LRDG2学习到的亲和矩阵}
	\label{fig_ExtYaleB10_Visualization}
\end{figure}

通过对\caption中字体设置,\fontsize{10.5bp}{17bp} 小五号字体就是10.5磅,单位磅基本与bp一样,17bp对应行间距,10.5*1.3*行距倍数=行间距bp。

### 使用 `subfigure` 包为每个子图添加独立的 Caption 为了在 LaTeX 文档中实现一行内排列多个子图并分别为这些子图添加独立的小标题(即 caption),可以采用如下方法: 首先,在导言区引入必要的宏包。这里推荐使用较新的 `\usepackage{subcaption}` 而不是旧版的 `subfigure`,因为前者提供了更好的兼容性和更多功能[^2]。 接着,在正文中创建 figure 环境,并在其内部嵌套若干个 subfigure 环境来放置各个子图及其对应的说明文字。通过调整宽度参数控制每张图片所占的空间比例以及它们之间的间距。下面给出一段具体的例子代码用于展示这一过程: ```latex \documentclass{article} \usepackage{graphicx} % Required for including images \usepackage{subcaption} % For creating side-by-side figures with captions % Customize the format of main and sub-figure labels according to journal requirements. \captionsetup[figure]{labelsep=period}% 主图图题设置成 FIG.1. \captionsetup[subfigure]{justification=centering, labelformat=simple}% 子图图题居中对齐且简单格式化 \renewcommand{\thesubfigure}{(\alph{subfigure})} \begin{document} \begin{figure}[htbp] \centering % First subfigure (left) \begin{subfigure}[b]{0.47\textwidth} \includegraphics[width=\linewidth]{example-image-a} \caption{Positions trajectories and errors} \label{fig:pos_errors} \end{subfigure} % Space between subfigures \hfill % Second subfigure (right) \begin{subfigure}[b]{0.47\textwidth} \includegraphics[width=\linewidth]{example-image-b} \caption{Velocities trajectories and errors} \label{fig:vel_errors} \end{subfigure} \caption{Tracking control for MAS without any faults.} \label{fig:tracking_control} \end{figure} \end{document} ``` 上述代码片段展示了如何利用 `subcaption` 宏包中的命令构建两个横向排列的子图,并给定各自的小标题和全局的大标题。注意这里的 `\includegraphics[]{} ` 部分应当替换为你实际使用的图像文件路径;同时也可以根据具体需求修改其他样式选项如字体大小、边距等[^4]。
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值