移除第5张图片后LaTeX表格无法编译的解决方法咨询
解决LaTeX表格无第5张图片时的编译问题
你的问题是取消注释第5张图片代码后编译失败,现在需要在不添加该图片的前提下让代码正常编译——核心原因是第5行的Frame列单元格仅包含注释,无实际内容,导致LaTeX无法正确解析段落类型列(m{4cm})。以下是两种可行的解决方式:
方法1:添加空占位符
在注释掉图片代码的单元格中加入\mbox{},确保单元格有合法内容:
\begin{table}[ht] \centering \begin{tabular}{c m{4cm} m{7cm}} \# & Frame & Text \\ \midrule 1 & \includegraphics[width=4cm]{images/fig_asynchrony_a.png} & \textit{se pone \underline{el tomate} en una hoja con} (en. “you put [the tomato] in a pot”)\\ \midrule 2 & \includegraphics[width=4cm]{images/fig_asynchrony_b.png} & \textit{con} (en. “with”) \\ \midrule 3 & \includegraphics[width=4cm]{images/fig_asynchrony_c.png} & \textit{agua} (en. “water”) \\ \midrule 4 & \includegraphics[width=4cm]{images/fig_asynchrony_d.png} & \textit{y ahí} (en. “and there”) \\ \midrule 5 & %\includegraphics[width=4cm]{images/fig_asynchrony_e.png} \mbox{} & \textit{se pone} (en. “and it is set”) \\ \bottomrule \end{tabular} \caption{Slight asynchrony of iconic gesture, SBLG} \label{tab:asynchrony} \end{table}
方法2:添加占位保持行高一致
如果希望第5行的高度和其他带图片的行保持一致,可以使用\phantom命令模拟图片的占位:
\begin{table}[ht] \centering \begin{tabular}{c m{4cm} m{7cm}} \# & Frame & Text \\ \midrule 1 & \includegraphics[width=4cm]{images/fig_asynchrony_a.png} & \textit{se pone \underline{el tomate} en una hoja con} (en. “you put [the tomato] in a pot”)\\ \midrule 2 & \includegraphics[width=4cm]{images/fig_asynchrony_b.png} & \textit{con} (en. “with”) \\ \midrule 3 & \includegraphics[width=4cm]{images/fig_asynchrony_c.png} & \textit{agua} (en. “water”) \\ \midrule 4 & \includegraphics[width=4cm]{images/fig_asynchrony_d.png} & \textit{y ahí} (en. “and there”) \\ \midrule 5 & %\includegraphics[width=4cm]{images/fig_asynchrony_e.png} \phantom{\includegraphics[width=4cm]{images/fig_asynchrony_e.png}} & \textit{se pone} (en. “and it is set”) \\ \bottomrule \end{tabular} \caption{Slight asynchrony of iconic gesture, SBLG} \label{tab:asynchrony} \end{table}
补充说明
- 从
\midrule、\bottomrule判断你已使用booktabs包,以上两种方法均兼容该包。 - 若取消注释第5张图片后仍编译失败,大概率是图片路径错误或文件缺失,可检查
images/fig_asynchrony_e.png是否存在、路径是否正确。
内容的提问来源于stack exchange,提问作者cambar
相关产品推荐
相关产品推荐

