Overleaf LaTeX表格报错:Missing $ inserted等问题排查求助
问题原因与解决方案
错误根源
LaTeX中,上标符号^、下标符号_是数学模式专属命令,只能在数学环境(用$...$包裹)里使用。你表格里的AP^{50}、AR^{50}、ACID$_p$这类写法,直接放在文本模式的表格单元格中,LaTeX无法解析,就会触发「Missing $ inserted」「Extra }, or forgotten $」这类报错。之前只替换^没用,是因为还有_的问题,而且正确处理方式不是替换符号,而是给这些内容加上数学环境包裹。
解决步骤
- 给所有包含
^或_的内容添加$...$包裹,比如把AP^{50}改成$AP^{50}$,ACID$_p$改成$ACID_p$ - 优化
\resizebox与\centering的顺序:\centering应放在\resizebox外面,否则表格无法正确居中(这不是报错原因,但能修正排版问题)
修正后的完整代码
\begin{table}[h] \caption{The first scenario: supervised learning versus normal self-supervised learning approach for learning features for a pose estimation downstream task. There is no intermediate stage in this approach.}\label{tab2} \centering \resizebox{\textwidth}{!}{ \begin{tabular}{|l|l|l|c|c|c|c|c|c|c|c|c|c|l|} \hline Model & Datasets &Status &AP &$AP^{50}$ & $AP^{75}$&$AP^{M}$ &$AP^{L}$& AR& $AR^{50}$& $AR^{75}$& $AR^{M}$ &$AR^{L}$&Epochs\\ \hline \multirow{2}{*}{ResNet-50}&$ACID_p$& Sup & \textbf{0.4455}&\textbf{1.0} & \textbf{0.3307}& -1.0& \textbf{0.4455}&\textbf{0.4867} &\textbf{1.0}& \textbf{0.4667}& -1.0&\textbf{0.4867}& 120\\ &ImageNet& Self-Sup &0.37962 & 0.80528& 0.17327& -1.0& 0.37962&0.42 &0.86667& 0.2& -1.0&0.42 & 590\\ \hline \multirow{2}{*}{HRNet-W32}&$ACID_p$ & Sup& \textbf{0.4228} & \textbf{1.0}& \textbf{0.3187}& -1.0& \textbf{0.4228}&\textbf{0.520} &\textbf{1.0}& \textbf{0.5333}& -1.0& \textbf{0.520}& 120\\ &ImageNet & Self-Sup& 0.3832 & 0.7958& 0.2911&-1.0&0.3832 &0.4200 &0.8667&0.3333 &-1.0 & 0.4200& 450\\ \hline \end{tabular} } \end{table}
内容的提问来源于stack exchange,提问作者Alaa Alshubbak
相关产品推荐
相关产品推荐

