You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

LaTeX含图片表格边框不均问题排查求助

LaTeX表格边框不均问题排查与解决

我尝试在LaTeX文档中插入三张图片并放在表格内,但表格无法为每个单元格提供均等的边框,效果如下:
问题效果截图

原代码:

\makeatletter
\newcommand\extralabel[2]{{\edef\@currentlabel{\@currentlabel#2}\label{#1}}}
\makeatother

\begin{figure}
\centering
\begin{tabular}{|c|c|c|}
\hline \\
\includegraphics[height=4.5cm]{example-image-b} &
\includegraphics[height=4.5cm]{example-image-b} &
\includegraphics[height=4.5cm]{example-image-b} \\ \hline
\textbf{(a)}  & \textbf{(b)} & \textbf{(c)}  \\ \hline
\end{tabular}

\caption{ \textbf{(a)} Some text
\textbf{(b)} Some text
\textbf{(c)} Some text
}
\label{fig:Name}
\extralabel{fig:Name:a}{(a)}
\extralabel{fig:Name:b}{(b)}
\extralabel{fig:Name:c}{(c)}
\end{figure}

问题原因

  • 第一行\hline后多余的\\导致第一个单元格顶部产生额外空白,使得该单元格边框高度明显大于其他单元格。
  • 图片所在行与下方标注行的单元格高度不匹配,进一步放大了边框不均的视觉效果。

解决方案

方案1:将图片与标注放在同一单元格(推荐)

把每个图片和对应的标注放在同一个单元格内,确保每个单元格的内容高度一致,边框自然均等。修正后的代码:

\makeatletter
\newcommand\extralabel[2]{{\edef\@currentlabel{\@currentlabel#2}\label{#1}}}
\makeatother

\begin{figure}
\centering
\begin{tabular}{|c|c|c|}
\hline
\includegraphics[height=4.5cm]{example-image-b} \\ \textbf{(a)} &
\includegraphics[height=4.5cm]{example-image-b} \\ \textbf{(b)} &
\includegraphics[height=4.5cm]{example-image-b} \\ \textbf{(c)} \\
\hline
\end{tabular}

\caption{ \textbf{(a)} Some text
\textbf{(b)} Some text
\textbf{(c)} Some text
}
\label{fig:Name}
\extralabel{fig:Name:a}{(a)}
\extralabel{fig:Name:b}{(b)}
\extralabel{fig:Name:c}{(c)}
\end{figure}

方案2:修正原表格的换行问题

如果坚持分两行布局,需要去掉多余换行并调整行间距,保证上下单元格高度匹配:

\makeatletter
\newcommand\extralabel[2]{{\edef\@currentlabel{\@currentlabel#2}\label{#1}}}
\makeatother

\begin{figure}
\centering
% 调整表格行间距,让上下单元格高度更协调
\renewcommand{\arraystretch}{1.2}
\begin{tabular}{|c|c|c|}
\hline
\includegraphics[height=4.5cm]{example-image-b} &
\includegraphics[height=4.5cm]{example-image-b} &
\includegraphics[height=4.5cm]{example-image-b} \\ \hline
\textbf{(a)} & \textbf{(b)} & \textbf{(c)} \\ \hline
\end{tabular}

\caption{ \textbf{(a)} Some text
\textbf{(b)} Some text
\textbf{(c)} Some text
}
\label{fig:Name}
\extralabel{fig:Name:a}{(a)}
\extralabel{fig:Name:b}{(b)}
\extralabel{fig:Name:c}{(c)}
\end{figure}

内容的提问来源于stack exchange,提问作者Yustina Ivanova

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.28 19:52:44