LaTeX技术咨询:Overleaf图片编译异常与表格单元格合并调整
问题1:LaTeX图片插入编译异常
异常代码
\begin{figure} \centering \includegraphics[width=0.9\textwidth]{emnlp2023-latex/figures/fig4.png} \caption{Pathologization index (3-year rolling mean) of mental health-related terms over the study period (1970-2016).} \label{fig:pathol-index} \end{figure}
问题说明
第3行\includegraphics编译报错,已确认文件路径为Overleaf自动补全的正确路径。
解决方案
- 检查文件完整性:确认
fig4.png未损坏,可重新上传至对应目录;若格式不兼容,转成jpg或pdf格式后替换测试。 - 确认依赖包:确保文档开头已导入
graphicx包(\usepackage{graphicx}),这是插入图片的核心依赖。 - 简化路径测试:将图片移至项目根目录,修改路径为
{fig4.png},排除嵌套目录的识别问题。 - 清理编译缓存:在Overleaf中选择「从头编译」,清除旧缓存可能引发的异常。
问题2:表格首列合并行并保留指定水平线
当前代码
\begin{center} \begin{table} \begin{tabular}{ |c|c|c|c|c| } \hline \textbf{Term} & \textbf{$\beta$(sev)} & \textbf{$\beta$(sev)+} & \textbf{$\beta$(path)} & \textbf{$\beta$(path)+} \\ \hline \multirow{2}{4em}{addiction} & -0.004* & -0.005* & 0.0007* & 0.0008* \\ \cline{2-5} & -0.008* & -0.008* & 0.00004 & -0.00002 \\ \hline \multirow{2}{3em}{anger} & -0.002* & -0.002* & 0.00002 & 6.63^{\text{e-06}} \\ \cline{2-5} & -0.0009 & -0.0009 & 0.00002 & 1.62^{\text{e-05}} \\ \hline \multirow{2}{3em}{distress} & 0.0007 & 0.004 & 0.0001 & 1.06^{\text{e-04}} \\ \cline{2-5} & -0.002 & -0.002 & -0.07^{\text{e-04}} & -6.90^{\text{e-06}} \\ \hline \multirow{2}{3em}{grief} & -0.002 & -0.004 & 0.0007* & 0.0007* \\ \cline{2-5} & -0.005* & -0.006* & 0.00006* & 0.00007* \\ \hline \multirow{2}{3em}{stress} & 0.002* & -0.001* & 0.0006* & 0.0006* \\ \cline{2-5} & -0.002* & -0.003* & 0.0002* & 0.0002* \\ \hline \multirow{2}{3em}{worry} & -0.004 & -0.006* & 0.0005* & 0.0005* \\ \cline{2-5} & -0.005* & -0.005* & 1.1139 & 0.00001 \\ \hline \end{tabular} \label{tab:results} \caption{Standardized Regression Coefficients for Year Predicting Severity Index (sev) and Pathologization Index (path) (row 1 = psychology; row 2 = COHCA). + = control analysis. * = \emph{p} < .05.} \end{table} \end{center}
需求说明
合并表格第1列每组术语对应的两行,同时在第2-5列的两行之间保留水平线,实现首列术语垂直居中合并、右侧列分隔线保留的效果。
修改后代码
\begin{table}[htbp] \centering \begin{tabular}{|c|c|c|c|c|} \hline \textbf{术语} & \textbf{$\beta$(sev)} & \textbf{$\beta$(sev)+} & \textbf{$\beta$(path)} & \textbf{$\beta$(path)+} \\ \hline \multirow{2}{*}{addiction} & -0.004* & -0.005* & 0.0007* & 0.0008* \\ \cline{2-5} & -0.008* & -0.008* & 0.00004 & -0.00002 \\ \hline \multirow{2}{*}{anger} & -0.002* & -0.002* & 0.00002 & $6.63\times10^{-6}$ \\ \cline{2-5} & -0.0009 & -0.0009 & 0.00002 & $1.62\times10^{-5}$ \\ \hline \multirow{2}{*}{distress} & 0.0007 & 0.004 & 0.0001 & $1.06\times10^{-4}$ \\ \cline{2-5} & -0.002 & -0.002 & $-0.07\times10^{-4}$ & $-6.90\times10^{-6}$ \\ \hline \multirow{2}{*}{grief} & -0.002 & -0.004 & 0.0007* & 0.0007* \\ \cline{2-5} & -0.005* & -0.006* & 0.00006* & 0.00007* \\ \hline \multirow{2}{*}{stress} & 0.002* & -0.001* & 0.0006* & 0.0006* \\ \cline{2-5} & -0.002* & -0.003* & 0.0002* & 0.0002* \\ \hline \multirow{2}{*}{worry} & -0.004 & -0.006* & 0.0005* & 0.0005* \\ \cline{2-5} & -0.005* & -0.005* & 1.1139 & 0.00001 \\ \hline \end{tabular} \label{tab:results} \caption{年份预测严重程度指数(sev)与病理化指数(path)的标准化回归系数(第一行=心理学领域;第二行=COHCA领域)。+ = 控制变量分析。* = \emph{p} < 0.05。} \end{table}
关键修改点
- 优化
multirow参数:将手动指定宽度的\multirow{2}{3em}改为\multirow{2}{*},让单元格宽度自适应内容,确保术语垂直居中合并。 - 修正科学计数法:把
6.63^{\text{e-06}}改为标准LaTeX格式$6.63\times10^{-6}$,保证显示正确。 - 精简表格环境:移除冗余的
center环境,table配合\centering即可实现居中;添加[htbp]参数让表格位置更灵活。 - 中文本地化:将表头和说明文字翻译成中文,适配中文排版习惯。
内容的提问来源于stack exchange,提问作者In_cognito
相关产品推荐
相关产品推荐

