表格缺失 { 已插入。救命!

表格缺失 { 已插入。救命!

我是 Latex 新手,有一个表总是出错。我收到的消息是“缺少 } 插入”。我认为错误发生在第 300-322 行之间,因为我运行的代码没有星号(即 $0.44^{***}$),并且运行正常。是我缺少包还是我编码有误?

谢谢

\documentclass{article}

\usepackage{longtable,lscape,booktabs}

\begin{document}

% Table generated by Excel2LaTeX from sheet 'Sheet5'
\begin{landscape}
\begin{table}[h]\centering
   \caption{MNL Model with Grouped Disposal as DV}
   \scalebox{0.8}{
\begin{tabular}{lccccccccccc}
\cmidrule{2-12}          & \multicolumn{3}{c}{\textbf{Recycle vs. Trash }} &       & \multicolumn{3}{c}{\textbf{Recycle vs. Store }} &       & \multicolumn{3}{c}{\textbf{Store vs Trash }} \\
\cmidrule{2-12}          & \multicolumn{1}{c}{I} & \multicolumn{1}{c}{II} & \multicolumn{1}{c}{III} &       & \multicolumn{1}{c}{IV} & \multicolumn{1}{c}{V} & \multicolumn{1}{c}{VI} &       & \multicolumn{1}{c}{VII} & \multicolumn{1}{c}{VIII} & \multicolumn{1}{c}{IX} \\
          & \multicolumn{1}{c}{Coef.} & \multicolumn{1}{c}{Std. Error} & \multicolumn{1}{c}{Odds ratio} &       & \multicolumn{1}{c}{Coef.} & \multicolumn{1}{c}{Std. Error} & \multicolumn{1}{c}{Odds ratio} &       & \multicolumn{1}{c}{Coef.} & \multicolumn{1}{c}{Std. Error} & \multicolumn{1}{c}{Odds ratio} \\
\cmidrule{2-12}    1. EPR: Yes & $0.44^{*}$  & 0.21  & 1.55  &       & 0.06  & 0.18  & 1.06  &       & 0.38  & 0.24  & 1.46 \\
    1. LEGALAWARENESS: Yes & 0.07  & 0.22  & 1.07  &       & -$0.34^{*}$ & 0.16  & 0.71  &       & 0.41  & 0.25  & 1.50 \\
    1. LOCTAWARENESS: Maybe & $1.37^{***}$  & 0.23  & 3.92  &       & 1.17  & 0.19  & 3.92  &       & 0.20  & 0.28  & 1.22 \\
    2. LOCTAWARENESS: Yes & $1.67^{***}$  & 0.26  & 5.30  &       & $1.48^{***}$  & 0.20  & 4.41  &       & 0.18  & 0.30  & 1.20 \\
    2. IMPORTANCE: Not very & -0.08 & 0.66  & 0.95  &       & -0.65 & 0.95  & 0.52  &       & 0.56  & 0.88  & 1.76 \\
    3. IMPORTANCE: Neutral & $1.03^{^}$  & 0.58  & 2.80  &       & 0.25  & 0.87  & 1.28  &       & 0.78  & 0.82  & 2.18 \\
    4. IMPORTANCE: Somewhat Important & $1.95^{**}$  & 0.57  & 7.06  &       & -0.32 & 0.84  & 0.73  &       & $2.28^{**}$  & 0.80  & 9.74 \\
    5. IMPORTANCE: Very Important & $2.34^{***}$  & 0.57  & 10.41 &       & 0.02  & 0.85  & 10.41 &       & $2.32^{**}$  & 0.81  & 10.17 \\
    1. INFOSOURCE: General & 0.41  & 0.34  & 1.51  &       & $1.19^{***}$  & 0.31  & 3.30  &       & -$0.78^{*}$ & 0.40  & 0.46 \\
    2. INFOSOURCE: Government & $0.76^{*}$  & 0.36  & 2.14  &       & $1.08^{***}$  & 0.30  & 2.94  &       & -0.32 & 0.40  & 0.73 \\
    3. INFOSOURCE: Retailer Manufacturer & 0.55  & 0.39  & 1.74  &       & $0.77^{**}$  & 0.34  & 2.66  &       & -0.42 & 0.46  & 0.65 \\
    4. INFOSOURCE: Non Profit & $0.77^{*}$  & 0.38  & 2.16  &       & $1.09^{***}$  & 0.32  & 2.98  &       & -0.32 & 0.44  & 0.73 \\
    1. PREVENT: Too Expensive & -1.19 & 0.77  & 0.31  &       & -0.60 & 0.47  & 0.55  &       & -0.59 & 0.89  & 0.55 \\
    2. PREVENT: Inconvenient Location & -$1.73^{*}$ & 0.74  & 0.18  &       & -$1.06^{*}$ & 0.45  & 0.35  &       & -0.67 & 0.86  & 0.51 \\
    3. PREVENT: Unable to Transport & -1.13 & 0.75  & 0.32  &       & -0.22 & 0.47  & 0.81  &       & -0.91 & 0.88  & 0.40 \\
    4. PREVENT: Unaware of Location & -$1.57^{*}$ & 0.73  & 0.21  &       & -$0.87^{*}$ & 0.46  & 0.42  &       & -0.70 & 0.86  & 0.50 \\
    1. RURAL: Yes & -0.23 & 0.19  & 0.78  &       & -$0.37^{**}$ & 0.15  & 0.69  &       & 0.14  & 0.22  & 1.16 \\
    2. AGE: 36-45 & 0.35  & 0.29  & 1.43  &       & 0.05  & 0.20  & 2.95  &       & 0.31  & 0.32  & 0.58 \\
    3. AGE: 46-55 & 0.00  & 0.25  & 0.98  &       & $0.94^{***}$  & 0.23  & 2.55  &       & -$0.94^{**}$ & 0.31  & 0.39 \\
    4. AGE: 56-65 & 0.44  & 0.28  & 1.49  &       & $1.09^{***}$  & 0.24  & 2.95  &       & -$0.65^{*}$ & 0.33  & 0.52 \\
    5. AGE: 66+ & $0.60^{^}$  & 0.34  & 1.82  &       & $1.14^{***}$  & 0.29  & 3.13  &       & -0.54 & 0.41  & 0.58 \\
    2. DISTANCE: 1-5 miles & $0.61^{**}$  & 0.23  & 1.83  &       & 0.45  & 0.28  & 1.57  &       & -$0.47^{**}$ & 0.41  & 0.62 \\
    3. DISTANCE: 6-10 miles & 0.38  & 0.25  & 1.46  &       & 0.33  & 0.27  & 1.39  &       & 0.25  & 0.40  & 1.29 \\
    4. DISTANCE: 11-20 miles & $0.02^{^}$  & 0.34  & 1.02  &       & 0.54  & 0.29  & 1.42  &       & -0.19 & 0.42  & 0.83 \\
    \bottomrule
     \midrule
\textit{***p $<$ .001, ** p $<$.01, *p$<$.05, $^\wedge$ p$<$.1} &       &       &       &       &       &       &       &       &       &       &       &       &       &  \\
\end{tabular}}}
  \label{tab:results}%
\end{table}%
\end{landscape}
\end{document}

答案1

然后 tex 报告错误

l.21     3. IMPORTANCE: Neutral & $1.03^{^}

我猜你是故意的^{*}

然后 tex 报告

! Extra alignment tab has been changed to \cr.
l.42 ... &       &       &       &       &       &

&因为该行中有太多内容。

然后它运行没有错误,但标记很差(最好只是手写表格而不是生成它)

\documentclass{article}

\usepackage{longtable,lscape,booktabs}

\begin{document}

% Table generated by Excel2LaTeX from sheet 'Sheet5'
\begin{landscape}
\begin{table}[h]\centering
   \caption{MNL Model with Grouped Disposal as DV}
   \scalebox{0.8}{
\begin{tabular}{lccccccccccc}
\cmidrule{2-12}          & \multicolumn{3}{c}{\textbf{Recycle vs. Trash }} &       & \multicolumn{3}{c}{\textbf{Recycle vs. Store }} &       & \multicolumn{3}{c}{\textbf{Store vs Trash }} \\
\cmidrule{2-12}          & \multicolumn{1}{c}{I} & \multicolumn{1}{c}{II} & \multicolumn{1}{c}{III} &       & \multicolumn{1}{c}{IV} & \multicolumn{1}{c}{V} & \multicolumn{1}{c}{VI} &       & \multicolumn{1}{c}{VII} & \multicolumn{1}{c}{VIII} & \multicolumn{1}{c}{IX} \\
          & \multicolumn{1}{c}{Coef.} & \multicolumn{1}{c}{Std. Error} & \multicolumn{1}{c}{Odds ratio} &       & \multicolumn{1}{c}{Coef.} & \multicolumn{1}{c}{Std. Error} & \multicolumn{1}{c}{Odds ratio} &       & \multicolumn{1}{c}{Coef.} & \multicolumn{1}{c}{Std. Error} & \multicolumn{1}{c}{Odds ratio} \\
\cmidrule{2-12}    1. EPR: Yes & $0.44^{*}$  & 0.21  & 1.55  &       & 0.06  & 0.18  & 1.06  &       & 0.38  & 0.24  & 1.46 \\
    1. LEGALAWARENESS: Yes & 0.07  & 0.22  & 1.07  &       & -$0.34^{*}$ & 0.16  & 0.71  &       & 0.41  & 0.25  & 1.50 \\
    1. LOCTAWARENESS: Maybe & $1.37^{***}$  & 0.23  & 3.92  &       & 1.17  & 0.19  & 3.92  &       & 0.20  & 0.28  & 1.22 \\
    2. LOCTAWARENESS: Yes & $1.67^{***}$  & 0.26  & 5.30  &       & $1.48^{***}$  & 0.20  & 4.41  &       & 0.18  & 0.30  & 1.20 \\
    2. IMPORTANCE: Not very & -0.08 & 0.66  & 0.95  &       & -0.65 & 0.95  & 0.52  &       & 0.56  & 0.88  & 1.76 \\
    3. IMPORTANCE: Neutral & $1.03^{*}$  & 0.58  & 2.80  &       & 0.25  & 0.87  & 1.28  &       & 0.78  & 0.82  & 2.18 \\
    4. IMPORTANCE: Somewhat Important & $1.95^{**}$  & 0.57  & 7.06  &       & -0.32 & 0.84  & 0.73  &       & $2.28^{**}$  & 0.80  & 9.74 \\
    5. IMPORTANCE: Very Important & $2.34^{***}$  & 0.57  & 10.41 &       & 0.02  & 0.85  & 10.41 &       & $2.32^{**}$  & 0.81  & 10.17 \\
    1. INFOSOURCE: General & 0.41  & 0.34  & 1.51  &       & $1.19^{***}$  & 0.31  & 3.30  &       & -$0.78^{*}$ & 0.40  & 0.46 \\
    2. INFOSOURCE: Government & $0.76^{*}$  & 0.36  & 2.14  &       & $1.08^{***}$  & 0.30  & 2.94  &       & -0.32 & 0.40  & 0.73 \\
    3. INFOSOURCE: Retailer Manufacturer & 0.55  & 0.39  & 1.74  &       & $0.77^{**}$  & 0.34  & 2.66  &       & -0.42 & 0.46  & 0.65 \\
    4. INFOSOURCE: Non Profit & $0.77^{*}$  & 0.38  & 2.16  &       & $1.09^{***}$  & 0.32  & 2.98  &       & -0.32 & 0.44  & 0.73 \\
    1. PREVENT: Too Expensive & -1.19 & 0.77  & 0.31  &       & -0.60 & 0.47  & 0.55  &       & -0.59 & 0.89  & 0.55 \\
    2. PREVENT: Inconvenient Location & -$1.73^{*}$ & 0.74  & 0.18  &       & -$1.06^{*}$ & 0.45  & 0.35  &       & -0.67 & 0.86  & 0.51 \\
    3. PREVENT: Unable to Transport & -1.13 & 0.75  & 0.32  &       & -0.22 & 0.47  & 0.81  &       & -0.91 & 0.88  & 0.40 \\
    4. PREVENT: Unaware of Location & -$1.57^{*}$ & 0.73  & 0.21  &       & -$0.87^{*}$ & 0.46  & 0.42  &       & -0.70 & 0.86  & 0.50 \\
    1. RURAL: Yes & -0.23 & 0.19  & 0.78  &       & -$0.37^{**}$ & 0.15  & 0.69  &       & 0.14  & 0.22  & 1.16 \\
    2. AGE: 36-45 & 0.35  & 0.29  & 1.43  &       & 0.05  & 0.20  & 2.95  &       & 0.31  & 0.32  & 0.58 \\
    3. AGE: 46-55 & 0.00  & 0.25  & 0.98  &       & $0.94^{***}$  & 0.23  & 2.55  &       & -$0.94^{**}$ & 0.31  & 0.39 \\
    4. AGE: 56-65 & 0.44  & 0.28  & 1.49  &       & $1.09^{***}$  & 0.24  & 2.95  &       & -$0.65^{*}$ & 0.33  & 0.52 \\
    5. AGE: 66+ & $0.60^{*}$  & 0.34  & 1.82  &       & $1.14^{***}$  & 0.29  & 3.13  &       & -0.54 & 0.41  & 0.58 \\
    2. DISTANCE: 1-5 miles & $0.61^{**}$  & 0.23  & 1.83  &       & 0.45  & 0.28  & 1.57  &       & -$0.47^{**}$ & 0.41  & 0.62 \\
    3. DISTANCE: 6-10 miles & 0.38  & 0.25  & 1.46  &       & 0.33  & 0.27  & 1.39  &       & 0.25  & 0.40  & 1.29 \\
    4. DISTANCE: 11-20 miles & $0.02^{*}$  & 0.34  & 1.02  &       & 0.54  & 0.29  & 1.42  &       & -0.19 & 0.42  & 0.83 \\
    \bottomrule
     \midrule
\textit{***p $<$ .001, ** p $<$.01, *p$<$.05, $^\wedge$ p$<$.1} &       &       &       &       &       &       &       &       &       &       &     \\
\end{tabular}}
  \label{tab:results}%
\end{table}%
\end{landscape}
\end{document}

关于标记的一些注释:

在表格上使用\scalebox只会强制字体大小与文档的其余部分不一致,最好避免这种情况并使用\small或需要的任何尺寸。

所有条目都应处于数学模式,使用-0.65产生的连字符对于减号来说太小且太低,您需要“$ -0.65$”

^{***}$应该是^{*{*}*}$,否则中间8将被视为中缀二元运算符并在两侧给予额外的空间。

6-10对于数字范围,应该是6--10n 破折号而不是连字符。

答案2

我会对您的表格进行编码,以便siunitx将列中的数字按小数点对齐,并threeparttable管理表格注释。我恢复了列间距和字体大小,并删除了命令\scalebox

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{geometry}
\usepackage{lscape}
\usepackage[table, svgnames]{xcolor}
\usepackage{tabularx, caption, makecell, hhline, booktabs, threeparttable}
\usepackage{siunitx}
\newcommand*\tss[1]{\,\textsuperscript{#1}}

\begin{document}

\begin{landscape}
  \begin{table}[h]\centering
    \footnotesize\setlength\tabcolsep{4pt}
    \setlength\extrarowheight{2pt}
    \sisetup{table-number-alignment=center, range-phrase=--}
    \begin{threeparttable}
      \caption{MNL Model with Grouped Disposal as DV}
      \begin{tabular}{@{}l@{}*{3}{S[table-format=-1.2, table-space-text-post=\tss{***}]S[table-format=1.2]S[table-format=2.2]}@{}}
        \cmidrule[\heavyrulewidth]{2-10} & \multicolumn{3}{c}{\textbf{Recycle vs. Trash }} & \multicolumn{3}{c}{\textbf{Recycle vs. Store }} & \multicolumn{3}{c}{\textbf{Store vs Trash }} \\
        \cmidrule(lr){2-4}\cmidrule(lr){5-7}\cmidrule(l){8-10} %
                                                        & { \makecell{I \\Coef.}} & {\makecell{II\\Std. Error}} & {\makecell{III\\Odds ratio}} & {\makecell{IV\\Coef.}} & {\makecell{V\\Std. Error}} & {\makecell{VI\\Odds ratio}} & {\makecell{VIII\\Coef.}} & {\makecell{IX\\Std. Error}} & {\makecell{X\\Odds ratio}} \\%
        \cmidrule[\lightrulewidth](l){2-10} 1. EPR: Yes & 0.44$ \tnote{*} $ & 0.21 & 1.55 & 0.06 & 0.18 & 1.06 & 0.38 & 0.24 & 1.46 \\
        1. LEGALAWARENESS: Yes & 0.07 & 0.22 & 1.07 & -0.34\tnote{*} & 0.16 & 0.71 & 0.41 & 0.25 & 1.50 \\
        1. LOCTAWARENESS: Maybe & 1.37\tnote{***} & 0.23 & 3.92 & 1.17 & 0.19 & 3.92 & 0.20 & 0.28 & 1.22 \\
        2. LOCTAWARENESS: Yes & 1.67\tnote{***} & 0.26 & 5.30 & 1.48\tnote{***} & 0.20 & 4.41 & 0.18 & 0.30 & 1.20 \\
        2. IMPORTANCE: Not very & -0.08 & 0.66 & 0.95 & -0.65 & 0.95 & 0.52 & 0.56 & 0.88 & 1.76 \\
        3. IMPORTANCE: Neutral & 1.03\tnote{$ ∧ $} & 0.58 & 2.80 & 0.25 & 0.87 & 1.28 & 0.78 & 0.82 & 2.18 \\
        4. IMPORTANCE: Somewhat Important & 1.95\tnote{**} & 0.57 & 7.06 & -0.32 & 0.84 & 0.73 & 2.28\tnote{**} & 0.80 & 9.74 \\
        5. IMPORTANCE: Very Important & 2.34\tnote{***} & 0.57 & 10.41 & 0.02 & 0.85 & 10.41 & 2.32\tnote{**} & 0.81 & 10.17 \\
        1. INFOSOURCE: General & 0.41 & 0.34 & 1.51 & 1.19\tnote{***} & 0.31 & 3.30 & -0.78\tnote{*} & 0.40 & 0.46 \\
        2. INFOSOURCE: Government & 0.76\tnote{*} & 0.36 & 2.14 & 1.08\tnote{***} & 0.30 & 2.94 & -0.32 & 0.40 & 0.73 \\
        3. INFOSOURCE: Retailer Manufacturer & 0.55 & 0.39 & 1.74 & 0.77\tnote{**} & 0.34 & 2.66 & -0.42 & 0.46 & 0.65 \\
        4. INFOSOURCE: Non Profit & 0.77\tnote{*} & 0.38 & 2.16 & 1.09\tnote{***} & 0.32 & 2.98 & -0.32 & 0.44 & 0.73 \\
        1. PREVENT: Too Expensive & -1.19 & 0.77 & 0.31 & -0.60 & 0.47 & 0.55 & -0.59 & 0.89 & 0.55 \\
        2. PREVENT: Inconvenient Location & -1.73\tnote{*} & 0.74 & 0.18 & -1.06\tnote{*} & 0.45 & 0.35 & -0.67 & 0.86 & 0.51 \\
        3. PREVENT: Unable to Transport & -1.13 & 0.75 & 0.32 & -0.22 & 0.47 & 0.81 & -0.91 & 0.88 & 0.40 \\
        4. PREVENT: Unaware of Location & -1.57\tnote{*} & 0.73 & 0.21 & -0.87\tnote{*} & 0.46 & 0.42 & -0.70 & 0.86 & 0.50 \\
        1. RURAL: Yes & -0.23 & 0.19 & 0.78 & -0.37\tnote{**} & 0.15 & 0.69 & 0.14 & 0.22 & 1.16 \\
        2. AGE: \numrange{36}{45} & 0.35 & 0.29 & 1.43 & 0.05 & 0.20 & 2.95 & 0.31 & 0.32 & 0.58 \\
        3. AGE: \numrange{46}{55} & 0.00 & 0.25 & 0.98 & 0.94\tnote{***} & 0.23 & 2.55 & -0.94\tnote{**} & 0.31 & 0.39 \\
        4. AGE: \numrange{56}{65} & 0.44 & 0.28 & 1.49 & 1.09\tnote{***} & 0.24 & 2.95 & -0.65\tnote{*} & 0.33 & 0.52 \\
        5. AGE: 66\,+ & 0.60\tnote{$ ∧ $} & 0.34 & 1.82 & 1.14\tnote{***} & 0.29 & 3.13 & -0.54 & 0.41 & 0.58 \\
        2. DISTANCE: \numrange{1}{5} miles & 0.61\tnote{**} & 0.23 & 1.83 & 0.45 & 0.28 & 1.57 & -0.47\tnote{**} & 0.41 & 0.62 \\
        3. DISTANCE: \numrange{6}{10} miles & 0.38 & 0.25 & 1.46 & 0.33 & 0.27 & 1.39 & 0.25 & 0.40 & 1.29 \\
        4. DISTANCE: \numrange{11}{20} miles & 0.02\tnote{$ ∧ $} & 0.34 & 1.02 & 0.54 & 0.29 & 1.42 & -0.19 & 0.42 & 0.83 \\
        \bottomrule
        \midrule
      \end{tabular}%}%}
      \label{tab:results}%
      \begin{tablenotes}[para]
        \item[***]$ p < .001 $,
        \item[**] $ p <.01 $,
        \item[*] $ p<.05 $,
        \item[$ ^ ∧ $] $ p<.1 $.
      \end{tablenotes}
    \end{threeparttable}
  \end{table}%
\end{landscape}

\end{document} 

在此处输入图片描述

相关内容