如何解决此错误(缺少$)

如何解决此错误(缺少$)

我想在 LaTeX 中创建这个表格:

在此处输入图片描述

并收到此错误:

错误:!缺少插入的 $。

我无法更改很多 tabularx 内容,因为它在模板中。我该如何解决此错误?我的代码:

<inserted text> 
                $
l.120 \end{tabularx}

\begin{table}[h]

\tbl{Mechanical properties of cortical bone obtained from tensile testing and small punch test}

\small\addtolength{\tabcolsep}{5pt}

\begin{tabularx}{\textwidth}{@{}lll@{}}

\hline\noalign{\smallskip}

Location & Elastic modulus (\textit{E})  & Stiffness (\textit{k})  \\
& GPa & N/mm\\

\noalign{\smallskip}\hline\noalign{\smallskip}

Upper & 12.47 \pm $0.79^{b}$ & 309.27\pm $19.266^{b}$\\

Middle & 15.54\pm $1.45^{a,b}$ & 517.76\pm$22.241^{a,b}$\\

Lower & 9.48 $\pm$ 0.63 & 235.84\pm17.477\\

Overall & 12.49\pm 2.67  & 356.91\pm123.91\\

ANOVA & p \textless 0.05 & p \textless 0.05\\

\noalign{\smallskip}\hline

\end{tabularx} %line 120.

$^a$Indicates a statistically significant difference compared with upper location of  bovine femur (p \textless 0.05).\\

$^b$Indicates a statistically significant difference compared with lower  location of bovine  femur (p \textless 0.05).

\end{table}

答案1

我已修复您的代码,使其不再出现错误。您仍需添加表格线。正如评论所述,您的主要问题是代码\pm

\documentclass{amsart}
\usepackage{tabularx}
\begin{document}
\begin{table}[h]
\caption{Mechanical properties of cortical bone obtained from tensile testing and small punch test}
\small\addtolength{\tabcolsep}{5pt}
\begin{tabularx}{\textwidth}{@{}lll@{}}
\hline\noalign{\smallskip}
Location & Elastic modulus (\textit{E})  & Stiffness (\textit{k})  \\
& GPa & N/mm\\
\noalign{\smallskip}\hline\noalign{\smallskip}
Upper & $12.47 \pm 0.79^{b}$ & $309.27\pm 19.266^{b}$\\
Middle & $15.54\pm 1.45^{a,b}$ & $517.76\pm22.241^{a,b}$\\
Lower & $9.48 \pm 0.63$ & $235.84\pm17.477$\\
Overall & $12.49\pm 2.67$  & $356.91\pm123.91$\\
ANOVA & p \textless 0.05 & p \textless 0.05\\
\noalign{\smallskip}\hline
\end{tabularx} %line 120.
$^a$Indicates a statistically significant difference compared with upper location of  bovine femur (p \textless 0.05).\\
$^b$Indicates a statistically significant difference compared with lower  location of bovine  femur (p \textless 0.05).
\end{table}
\end{document}

产量:

在此处输入图片描述

答案2

您的表格设计让我印象深刻threeparttable,所以我建议使用它。有了它,您可以在表格末尾简单地添加表格注释。使用siunitx包可以非常方便地写下带有给定不确定性的数字,使用规则booktabs可以使表格更美观:

\documentclass{article}
\usepackage{caption}
\usepackage[table]{xcolor}
\usepackage{booktabs, tabularx, threeparttable}
\usepackage{siunitx}

\begin{document}
\blindtext
    \begin{table}
    \centering
    \renewcommand\arraystretch{1.2}
    \sisetup{separate-uncertainty,
             table-space-text-post=\textsuperscript{a,b}}
\begin{threeparttable}
    \caption{Mechanical properties of cortical bone obtained from tensile testing and small punch test}
\addtolength{\tabcolsep}{5pt}
\begin{tabularx}{0.8\linewidth}{X
                                S[table-format=2.2 (3)]
                                S[table-format=3.3 (5)]}
    \toprule
Location& {Elastic modulus (\textit{E})}    & {Stiffness (\textit{k})} \\
        & {GPa}                             & {N/mm}\\
    \midrule
Upper   & 12.47\pm 0.79\textsuperscript{b}  & 309.27\pm  19.266\textsuperscript{b}\\
Middle  & 15.54\pm 1.45\textsuperscript{a,b}& 517.76\pm  22.241\textsuperscript{a,b}\\
Lower   &  9.48\pm 0.63                     & 235.84\pm  17.477\\
ANOVA   & {$p < 0.05$}                      & {$p < 0.05$}\\
    \bottomrule
\end{tabularx} %line 120.
    \begin{tablenotes}\tiny\smallskip\raggedright
\item[a] Indicates a statistically significant difference compared with upper location of  bovine femur $(p < 0.05)$..
\item[b] Indicates a statistically significant difference compared with lower  location of bovine  femur $(p < 0.05)$.
    \end{tablenotes}
    \end{threeparttable}
    \end{table}
\blindtext
\end{document}

我将表格宽度缩小至0.8\linewidth。如果您希望其宽度相等\textwidth,则仅使用\linewidth

在此处输入图片描述

编辑:\textless最好使用而不是。现在,在(虚拟)文本中,表格的可见位置已<添加。\blindtext

相关内容