多个编译错误

多个编译错误

我对 LaTeX 非常陌生,但我使用 R 中的 Stargazer 包来获取此代码,但是我收到以下错误:

  1. 第 1 行:缺少 \begin{document}
  2. 第 56 行:\begin{document} 以 \end{table} 结束
  3. 第 56 行: ! 额外 \endgroup
  4. 第 57 行:字体大小命令 \normalsize 未定义:
     \begin{tabular}{@{\extracolsep{5pt}}lcccc} 
        \\[-1.8ex]\hline 
        \hline \\[-1.8ex] 
         & \multicolumn{4}{c}{\textit{Dependent variable:}} \\ 
        \cline{2-5} 
        \\[-1.8ex] & \multicolumn{4}{c}{SCAM\_DUMMY} \\ 
        \\[-1.8ex] & (1) & (2) & (3) & (4)\\ 
        \hline \\[-1.8ex] 
         LMPOS\_RATIO &  & $-$44.593$^{*}$ &  &  \\ 
          &  & (25.461) &  &  \\ 
          & & & & \\ 
         DICTION\_CERTAINTY\_RATIO &  &  & 6.088 &  \\ 
          &  &  & (7.727) &  \\ 
          & & & & \\ 
         Flesch &  &  &  & 0.004 \\ 
          &  &  &  & (0.013) \\ 
          & & & & \\ 
         PRE\_ICO\_DUMMY & 0.325 & 0.324 & 0.328 & 0.329 \\ 
          & (0.219) & (0.219) & (0.219) & (0.219) \\ 
          & & & & \\ 
         log\_TeamCount & 0.194 & 0.221 & 0.206 & 0.201 \\ 
          & (0.187) & (0.187) & (0.188) & (0.188) \\ 
          & & & & \\ 
         SOFTHARDCAPS\_DUMMY & 0.087 & 0.086 & 0.082 & 0.084 \\ 
          & (0.250) & (0.251) & (0.251) & (0.251) \\ 
          & & & & \\ 
         HinesTaxHaven & $-$0.111 & $-$0.098 & $-$0.111 & $-$0.104 \\ 
          & (0.239) & (0.240) & (0.239) & (0.240) \\ 
          & & & & \\ 
         QUARTER\_DUMMYQUARTER\_DUMMY))1 & $-$0.113 & $-$0.108 & $-$0.122 & $-$0.117 \\ 
          & (0.301) & (0.301) & (0.301) & (0.301) \\ 
          & & & & \\ 
         QUARTER\_DUMMYQUARTER\_DUMMY))2 & $-$0.538$^{*}$ & $-$0.527 & $-$0.535$^{*}$ & $-$0.535$^{*}$ \\ 
          & (0.324) & (0.325) & (0.324) & (0.324) \\ 
          & & & & \\ 
         QUARTER\_DUMMYQUARTER\_DUMMY))3 & 0.092 & 0.075 & 0.094 & 0.094 \\ 
          & (0.327) & (0.328) & (0.327) & (0.327) \\ 
          & & & & \\ 
         QUARTER\_DUMMYQUARTER\_DUMMY))4 &  &  &  &  \\ 
          &  &  &  &  \\ 
          & & & & \\ 
         Whitepaper\_Length & 0.0001$^{**}$ & 0.0001$^{**}$ & 0.0001$^{**}$ & 0.0001$^{**}$ \\ 
          & (0.00003) & (0.00003) & (0.00003) & (0.00003) \\ 
          & & & & \\ 
         Constant & $-$3.502$^{***}$ & $-$3.000$^{***}$ & $-$4.051$^{***}$ & $-$3.691$^{***}$ \\ 
          & (0.472) & (0.548) & (0.846) & (0.719) \\ 
          & & & & \\ 
        \hline \\[-1.8ex] 
        Observations & 1,355 & 1,355 & 1,355 & 1,355 \\ 
        Log Likelihood & $-$340.629 & $-$339.063 & $-$340.306 & $-$340.567 \\ 
        Akaike Inf. Crit. & 699.258 & 698.126 & 700.613 & 701.135 \\ 
        \hline 
        \hline \\[-1.8ex] 
        \textit{Note:}  & \multicolumn{4}{r}{$^{*}$p$<$0.1; $^{**}$p$<$0.05; $^{***}$p$<$0.01} \\ 
        \end{tabular} 
        \end{table}
        \end{document}

答案1

在 LaTeX 中,您的文档必须首先声明\documentclass您所写内容的类型。它是文章、书籍、报告、图表还是任何您想要的(几乎)类型?

而且很多时候,在开始编写之前,你会声明一些包来帮助你编写。这就是通过\usepackage

当你开始书写时,告诉 LaTeX 这是\begin{document}。然后你写的内容就会出现在你的纸上。但是如果你必须告诉文档从哪里开始,你也必须告诉它从哪里结束。这是 LaTeX 中环境的结构:

\begin{document}
...
\end{document}

你写的是表格的结构,它是文档内部的内容。因此 LaTeX 会警告缺少一些重要内容:documentclass 和标记,用于指出文档的开始和结束位置。

以下是制作所需表格的完整代码:

\documentclass{article}
\usepackage[margin=2cm]{geometry}

\begin{document}
    \begin{tabular}{@{\extracolsep{5pt}}lcccc} 
        \\[-1.8ex]\hline 
        \hline \\[-1.8ex] 
         & \multicolumn{4}{c}{\textit{Dependent variable:}} \\ 
        \cline{2-5} 
        \\[-1.8ex] & \multicolumn{4}{c}{SCAM\_DUMMY} \\ 
        \\[-1.8ex] & (1) & (2) & (3) & (4)\\ 
        \hline \\[-1.8ex] 
         LMPOS\_RATIO &  & $-$44.593$^{*}$ &  &  \\ 
          &  & (25.461) &  &  \\ 
          & & & & \\ 
         DICTION\_CERTAINTY\_RATIO &  &  & 6.088 &  \\ 
          &  &  & (7.727) &  \\ 
          & & & & \\ 
         Flesch &  &  &  & 0.004 \\ 
          &  &  &  & (0.013) \\ 
          & & & & \\ 
         PRE\_ICO\_DUMMY & 0.325 & 0.324 & 0.328 & 0.329 \\ 
          & (0.219) & (0.219) & (0.219) & (0.219) \\ 
          & & & & \\ 
         log\_TeamCount & 0.194 & 0.221 & 0.206 & 0.201 \\ 
          & (0.187) & (0.187) & (0.188) & (0.188) \\ 
          & & & & \\ 
         SOFTHARDCAPS\_DUMMY & 0.087 & 0.086 & 0.082 & 0.084 \\ 
          & (0.250) & (0.251) & (0.251) & (0.251) \\ 
          & & & & \\ 
         HinesTaxHaven & $-$0.111 & $-$0.098 & $-$0.111 & $-$0.104 \\ 
          & (0.239) & (0.240) & (0.239) & (0.240) \\ 
          & & & & \\ 
         QUARTER\_DUMMYQUARTER\_DUMMY))1 & $-$0.113 & $-$0.108 & $-$0.122 & $-$0.117 \\ 
          & (0.301) & (0.301) & (0.301) & (0.301) \\ 
          & & & & \\ 
         QUARTER\_DUMMYQUARTER\_DUMMY))2 & $-$0.538$^{*}$ & $-$0.527 & $-$0.535$^{*}$ & $-$0.535$^{*}$ \\ 
          & (0.324) & (0.325) & (0.324) & (0.324) \\ 
          & & & & \\ 
         QUARTER\_DUMMYQUARTER\_DUMMY))3 & 0.092 & 0.075 & 0.094 & 0.094 \\ 
          & (0.327) & (0.328) & (0.327) & (0.327) \\ 
          & & & & \\ 
         QUARTER\_DUMMYQUARTER\_DUMMY))4 &  &  &  &  \\ 
          &  &  &  &  \\ 
          & & & & \\ 
         Whitepaper\_Length & 0.0001$^{**}$ & 0.0001$^{**}$ & 0.0001$^{**}$ & 0.0001$^{**}$ \\ 
          & (0.00003) & (0.00003) & (0.00003) & (0.00003) \\ 
          & & & & \\ 
         Constant & $-$3.502$^{***}$ & $-$3.000$^{***}$ & $-$4.051$^{***}$ & $-$3.691$^{***}$ \\ 
          & (0.472) & (0.548) & (0.846) & (0.719) \\ 
          & & & & \\ 
        \hline \\[-1.8ex] 
        Observations & 1,355 & 1,355 & 1,355 & 1,355 \\ 
        Log Likelihood & $-$340.629 & $-$339.063 & $-$340.306 & $-$340.567 \\ 
        Akaike Inf. Crit. & 699.258 & 698.126 & 700.613 & 701.135 \\ 
        \hline 
        \hline \\[-1.8ex] 
        \textit{Note:}  & \multicolumn{4}{r}{$^{*}$p$<$0.1; $^{**}$p$<$0.05; $^{***}$p$<$0.01} \\ 
        \end{tabular}
    \end{document}

花一些时间来分析结构。

  • 每个\begin{}命令必须与相应的\end{}命令匹配才能创建环境。
  • documentclass 是一篇文章。这是 LaTeX 中用于编写文章的标准类,但您可以根据需要进行更改。
  • 我已经添加了geometry包来增加边距,以便您的表格可以适合一页。(使用默认大小,它太大了)

我建议你在开始编写大型表格之前阅读一些关于使用 LaTeX 编写的文章。你可以开始这里

附录: 如果您只想要表格的图像,则可以使用standalonedocumentclass 来裁剪表格。

\documentclass{standalone}

\begin{document}
    \begin{tabular}{@{\extracolsep{5pt}}lcccc} 
        \\[-1.8ex]\hline 
        \hline \\[-1.8ex] 
         & \multicolumn{4}{c}{\textit{Dependent variable:}} \\ 
        \cline{2-5} 
        \\[-1.8ex] & \multicolumn{4}{c}{SCAM\_DUMMY} \\ 
        \\[-1.8ex] & (1) & (2) & (3) & (4)\\ 
        \hline \\[-1.8ex] 
         LMPOS\_RATIO &  & $-$44.593$^{*}$ &  &  \\ 
          &  & (25.461) &  &  \\ 
          & & & & \\ 
         DICTION\_CERTAINTY\_RATIO &  &  & 6.088 &  \\ 
          &  &  & (7.727) &  \\ 
          & & & & \\ 
         Flesch &  &  &  & 0.004 \\ 
          &  &  &  & (0.013) \\ 
          & & & & \\ 
         PRE\_ICO\_DUMMY & 0.325 & 0.324 & 0.328 & 0.329 \\ 
          & (0.219) & (0.219) & (0.219) & (0.219) \\ 
          & & & & \\ 
         log\_TeamCount & 0.194 & 0.221 & 0.206 & 0.201 \\ 
          & (0.187) & (0.187) & (0.188) & (0.188) \\ 
          & & & & \\ 
         SOFTHARDCAPS\_DUMMY & 0.087 & 0.086 & 0.082 & 0.084 \\ 
          & (0.250) & (0.251) & (0.251) & (0.251) \\ 
          & & & & \\ 
         HinesTaxHaven & $-$0.111 & $-$0.098 & $-$0.111 & $-$0.104 \\ 
          & (0.239) & (0.240) & (0.239) & (0.240) \\ 
          & & & & \\ 
         QUARTER\_DUMMYQUARTER\_DUMMY))1 & $-$0.113 & $-$0.108 & $-$0.122 & $-$0.117 \\ 
          & (0.301) & (0.301) & (0.301) & (0.301) \\ 
          & & & & \\ 
         QUARTER\_DUMMYQUARTER\_DUMMY))2 & $-$0.538$^{*}$ & $-$0.527 & $-$0.535$^{*}$ & $-$0.535$^{*}$ \\ 
          & (0.324) & (0.325) & (0.324) & (0.324) \\ 
          & & & & \\ 
         QUARTER\_DUMMYQUARTER\_DUMMY))3 & 0.092 & 0.075 & 0.094 & 0.094 \\ 
          & (0.327) & (0.328) & (0.327) & (0.327) \\ 
          & & & & \\ 
         QUARTER\_DUMMYQUARTER\_DUMMY))4 &  &  &  &  \\ 
          &  &  &  &  \\ 
          & & & & \\ 
         Whitepaper\_Length & 0.0001$^{**}$ & 0.0001$^{**}$ & 0.0001$^{**}$ & 0.0001$^{**}$ \\ 
          & (0.00003) & (0.00003) & (0.00003) & (0.00003) \\ 
          & & & & \\ 
         Constant & $-$3.502$^{***}$ & $-$3.000$^{***}$ & $-$4.051$^{***}$ & $-$3.691$^{***}$ \\ 
          & (0.472) & (0.548) & (0.846) & (0.719) \\ 
          & & & & \\ 
        \hline \\[-1.8ex] 
        Observations & 1,355 & 1,355 & 1,355 & 1,355 \\ 
        Log Likelihood & $-$340.629 & $-$339.063 & $-$340.306 & $-$340.567 \\ 
        Akaike Inf. Crit. & 699.258 & 698.126 & 700.613 & 701.135 \\ 
        \hline 
        \hline \\[-1.8ex] 
        \textit{Note:}  & \multicolumn{4}{r}{$^{*}$p$<$0.1; $^{**}$p$<$0.05; $^{***}$p$<$0.01} \\ 
        \end{tabular}
    \end{document}

相关内容