尝试将我的 tex 文件转换为回归表 - (注意:我是初学者)

尝试将我的 tex 文件转换为回归表 - (注意:我是初学者)

我将一些回归表保存为 tex 文件。然后当我尝试将其保存为 pdf 时,它最终被损坏了。然后当我尝试排版时,它显示:“!LaTeX 错误:环境表未定义。”

这是我的 tex 文件:

\begin{table}[htbp]\centering
\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}
\caption{Logistic regression table\label{tab1}}
\begin{tabular}{l*{4}{c}}
\hline\hline
            &\multicolumn{1}{c}{(1)}&\multicolumn{1}{c}{(2)}&\multicolumn{1}{c}{(3)}&\multicolumn{1}{c}{(4)}\\
            &\multicolumn{1}{c}{undereducated}&\multicolumn{1}{c}{undereducated}&\multicolumn{1}{c}{undereducated}&\multicolumn{1}{c}{undereducated}\\
\hline
undereducated&                     &                     &                     &                     \\
0.isco1d    &           0         &           0         &           0         &                     \\
            &         (.)         &         (.)         &         (.)         &                     \\
[1em]
Manager  &       4.117\sym{***}&       4.218\sym{***}&       4.181\sym{***}&                     \\
            &     (34.39)         &     (34.13)         &     (33.74)         &                     \\
[1em]
Professional  &       3.035\sym{***}&       2.408\sym{***}&       2.440\sym{***}&                     \\
            &     (27.27)         &     (20.49)         &     (20.74)         &                     \\
[1em]
Technician and associated professionals  &       5.513\sym{***}&       5.516\sym{***}&       5.608\sym{***}&                     \\
            &     (48.93)         &     (47.13)         &     (47.74)         &                     \\
[1em]
Clerical support workers  &      -2.061\sym{***}&      -2.061\sym{***}&      -2.018\sym{***}&                     \\
            &     (-4.47)         &     (-4.47)         &     (-4.38)         &                     \\
[1em]
Service and sales workers  &      -0.735\sym{***}&      -0.735\sym{***}&      -0.686\sym{***}&                     \\
            &     (-4.48)         &     (-4.48)         &     (-4.18)         &                     \\
[1em]
Agricultural, forestry workers  &       2.185\sym{***}&       2.185\sym{***}&       1.983\sym{***}&                     \\
            &     (19.53)         &     (19.53)         &     (17.65)         &                     \\
[1em]
Craft and related trades occupations  &      0.0605         &      0.0605         &      0.0367         &                     \\
            &      (0.46)         &      (0.46)         &      (0.28)         &                     \\
[1em]
Plant and machine operators  &      -0.463\sym{**} &      -0.463\sym{**} &      -0.438\sym{**} &                     \\
            &     (-2.87)         &     (-2.87)         &     (-2.72)         &                     \\
[1em]
Elementary Occupations  &           0         &           0         &           0         &                     \\
            &         (.)         &         (.)         &         (.)         &                     \\
[1em]
female\_mgr  &                     &      -0.355\sym{**} &      -0.269\sym{*}  &                     \\
            &                     &     (-3.19)         &     (-2.39)         &                     \\
[1em]
female\_prof &                     &       0.954\sym{***}&       0.990\sym{***}&                     \\
            &                     &     (18.55)         &     (19.13)         &                     \\
[1em]
female\_tech &                     &    -0.00610         &    0.000279         &                     \\
            &                     &     (-0.11)         &      (0.00)         &                     \\
[1em]
age         &                     &                     &      0.0270\sym{***}&      0.0309\sym{***}\\
            &                     &                     &     (22.69)         &      (9.41)         \\
[1em]
regions     &                     &                     &     -0.0340\sym{***}&     -0.0386\sym{***}\\
            &                     &                     &     (-5.41)         &     (-3.44)         \\
[1em]
Generic Programs  &                     &                     &                     &           0         \\
            &                     &                     &                     &         (.)         \\
[1em]
Education &                     &                     &                     &       1.208\sym{***}\\
            &                     &                     &                     &      (9.25)         \\
[1em]
Arts & Humanities &                     &                     &                     &      -0.219         \\
            &                     &                     &                     &     (-1.50)         \\
[1em]
Social sciences, journalism and information &                     &                     &                     &      0.0161         \\
            &                     &                     &                     &      (0.14)         \\
[1em]
Business, administration and law &                     &                     &                     &      -0.404\sym{***}\\
            &                     &                     &                     &     (-3.70)         \\
[1em]
Natural sciences, mathematics and statistics &                     &                     &                     &      -0.479\sym{***}\\
            &                     &                     &                     &     (-3.36)         \\
[1em]
ICT &                     &                     &                     &      -0.119         \\
            &                     &                     &                     &     (-0.70)         \\
[1em]
Engineering, manufacturing and construction &                     &                     &                     &      -0.335\sym{***}\\
            &                     &                     &                     &     (-3.66)         \\
[1em]
Agriculture, forestry, fishery and veterinary sciences &                     &                     &                     &       0.299\sym{*}  \\
            &                     &                     &                     &      (2.09)         \\
[1em]
Health and welfare &                     &                     &                     &       2.608\sym{***}\\
            &                     &                     &                     &     (28.88)         \\
[1em]
Services&                     &                     &                     &      0.0161         \\
            &                     &                     &                     &      (0.12)         \\
[1em]
Unknown&                     &                     &                     &      -0.929         \\
            &                     &                     &                     &     (-1.58)         \\
[1em]
\_cons      &      -4.662\sym{***}&      -4.662\sym{***}&      -5.724\sym{***}&      -3.876\sym{***}\\
            &    (-42.78)         &    (-42.78)         &    (-46.01)         &    (-32.74)         \\
\hline
\(N\)       &      101394         &      101394         &      101394         &       36005         \\
\hline\hline
\multicolumn{5}{l}{\footnotesize \textit{t} statistics in parentheses}\\
\multicolumn{5}{l}{\footnotesize \sym{*} \(p<0.05\), \sym{**} \(p<0.01\), \sym{***} \(p<0.001\)}\\
\end{tabular}
\end{table}

我对此真的很陌生,所以如果能得到任何帮助,我将不胜感激。如果我违反了提问的任何准则,请道歉并告诉我如何解决。提前致谢!

最好的,M.卡马尔

答案1

在以下示例中,我添加了缺失的 documentclass 以及 和\begin{document}\end{document}我加载了geometry包以便获得较小的边距,并加载了longtable包以允许在表格内分页。为了使表格变窄(因为它超出了文本宽度),我使用了固定宽度p类型的列,允许在第一列中自动换行。为了使第一列的内容左对齐,我使用了 包 array>{\raggedright\arraybackslash}

\documentclass{article}
\usepackage{geometry}
\usepackage{longtable}
\usepackage{array}
\begin{document}


\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}

\begin{longtable}{>{\raggedright\arraybackslash}p{4cm}*{4}{c}}
\caption{Logistic regression table\label{tab1}}\\
\hline\hline
            &\multicolumn{1}{c}{(1)}&\multicolumn{1}{c}{(2)}&\multicolumn{1}{c}{(3)}&\multicolumn{1}{c}{(4)}\\
            &\multicolumn{1}{c}{undereducated}&\multicolumn{1}{c}{undereducated}&\multicolumn{1}{c}{undereducated}&\multicolumn{1}{c}{undereducated}\\
\hline \endhead
undereducated&                     &                     &                     &                     \\
0.isco1d    &           0         &           0         &           0         &                     \\
            &         (.)         &         (.)         &         (.)         &                     \\
[1em]
Manager  &       4.117\sym{***}&       4.218\sym{***}&       4.181\sym{***}&                     \\
            &     (34.39)         &     (34.13)         &     (33.74)         &                     \\
[1em]
Professional  &       3.035\sym{***}&       2.408\sym{***}&       2.440\sym{***}&                     \\
            &     (27.27)         &     (20.49)         &     (20.74)         &                     \\
[1em]
Technician and associated professionals  &       5.513\sym{***}&       5.516\sym{***}&       5.608\sym{***}&                     \\
            &     (48.93)         &     (47.13)         &     (47.74)         &                     \\
[1em]
Clerical support workers  &      -2.061\sym{***}&      -2.061\sym{***}&      -2.018\sym{***}&                     \\
            &     (-4.47)         &     (-4.47)         &     (-4.38)         &                     \\
[1em]
Service and sales workers  &      -0.735\sym{***}&      -0.735\sym{***}&      -0.686\sym{***}&                     \\
            &     (-4.48)         &     (-4.48)         &     (-4.18)         &                     \\
[1em]
Agricultural, forestry workers  &       2.185\sym{***}&       2.185\sym{***}&       1.983\sym{***}&                     \\
            &     (19.53)         &     (19.53)         &     (17.65)         &                     \\
[1em]
Craft and related trades occupations  &      0.0605         &      0.0605         &      0.0367         &                     \\
            &      (0.46)         &      (0.46)         &      (0.28)         &                     \\
[1em]
Plant and machine operators  &      -0.463\sym{**} &      -0.463\sym{**} &      -0.438\sym{**} &                     \\
            &     (-2.87)         &     (-2.87)         &     (-2.72)         &                     \\
[1em]
Elementary Occupations  &           0         &           0         &           0         &                     \\
            &         (.)         &         (.)         &         (.)         &                     \\
[1em]
female\_mgr  &                     &      -0.355\sym{**} &      -0.269\sym{*}  &                     \\
            &                     &     (-3.19)         &     (-2.39)         &                     \\
[1em]
female\_prof &                     &       0.954\sym{***}&       0.990\sym{***}&                     \\
            &                     &     (18.55)         &     (19.13)         &                     \\
[1em]
female\_tech &                     &    -0.00610         &    0.000279         &                     \\
            &                     &     (-0.11)         &      (0.00)         &                     \\
[1em]
age         &                     &                     &      0.0270\sym{***}&      0.0309\sym{***}\\
            &                     &                     &     (22.69)         &      (9.41)         \\
[1em]
regions     &                     &                     &     -0.0340\sym{***}&     -0.0386\sym{***}\\
            &                     &                     &     (-5.41)         &     (-3.44)         \\
[1em]
Generic Programs  &                     &                     &                     &           0         \\
            &                     &                     &                     &         (.)         \\
[1em]
Education &                     &                     &                     &       1.208\sym{***}\\
            &                     &                     &                     &      (9.25)         \\
[1em]
Arts \& Humanities &               &                          &                     &      -0.219         \\
            &                     &                     &                     &     (-1.50)         \\
[1em]
Social sciences, journalism and information &                     &                     &                     &      0.0161         \\
            &                     &                     &                     &      (0.14)         \\
[1em]
Business, administration and law &                     &                     &                     &      -0.404\sym{***}\\
            &                     &                     &                     &     (-3.70)         \\
[1em]
Natural sciences, mathematics and statistics &                     &                     &                     &      -0.479\sym{***}\\
            &                     &                     &                     &     (-3.36)         \\
[1em]
ICT &                     &                     &                     &      -0.119         \\
            &                     &                     &                     &     (-0.70)         \\
[1em]
Engineering, manufacturing and construction &                     &                     &                     &      -0.335\sym{***}\\
            &                     &                     &                     &     (-3.66)         \\
[1em]
Agriculture, forestry, fishery and veterinary sciences &                     &                     &                     &       0.299\sym{*}  \\
            &                     &                     &                     &      (2.09)         \\
[1em]
Health and welfare &                     &                     &                     &       2.608\sym{***}\\
            &                     &                     &                     &     (28.88)         \\
[1em]
Services&                     &                     &                     &      0.0161         \\
            &                     &                     &                     &      (0.12)         \\
[1em]
Unknown&                     &                     &                     &      -0.929         \\
            &                     &                     &                     &     (-1.58)         \\
[1em]
\_cons      &      -4.662\sym{***}&      -4.662\sym{***}&      -5.724\sym{***}&      -3.876\sym{***}\\
            &    (-42.78)         &    (-42.78)         &    (-46.01)         &    (-32.74)         \\
\hline
\(N\)       &      101394         &      101394         &      101394         &       36005         \\
\hline\hline
\multicolumn{5}{l}{\footnotesize \textit{t} statistics in parentheses}\\
\multicolumn{5}{l}{\footnotesize \sym{*} \(p<0.05\), \sym{**} \(p<0.01\), \sym{***} \(p<0.001\)}\\
\end{longtable}


\end{document}

相关内容