\usepackage{booktabs} 给出错误

\usepackage{booktabs} 给出错误
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{hyperref}
\usepackage[margin=1in]{geometry} % full-width
    \topskip        =   20pt
    \parskip        =   10pt
    \parindent      =   0 pt
    \baselineskip   =   15pt
\usepackage{pdflscape}
\usepackage{amssymb, amsfonts, amsmath}
\usepackage{bm}
\usepackage{booktabs}
\usepackage{setspace}  % line spacing
\onehalfspacing
\usepackage{graphicx}
\usepackage{adjustbox}
\usepackage{rotating}  % for sidewaystable

\usepackage{threeparttable}    
\usepackage{dcolumn}    % aligning decimals
    \newcolumntype{d}[1]{D{.}{.}{#1}}

\let\estinput=\input % define a new input command so that we can still flatten the document

\newcommand{\estauto}[3]{
        \vspace{.75ex}{
            %\textsymbols% Note the added command here
            \begin{tabular}{l*{#2}{#3}}
            \toprule
            \estinput{#1}
            \bottomrule
            \addlinespace[.75ex]
            \end{tabular}
            }
        }

\newcommand{\sym}[1]{\rlap{#1}}
\usepackage{hyperref}
\usepackage{tabulary}

\title{Project Name}
\author{X Y Z}
\date{September 2021}

\begin{document}
\maketitle


\section*{Summary Statistics (Tables)}
\subsection*{Consent}
\begin{table}[!htbp]
    \centering
    \caption{caption}
    \label{tab:meetattend}
    \estauto{xyz.tex}{8}{c}\\
    \small{\textit{Notes:}}
\end{table}
\end{document}

我为之前的帖子道歉。我对论坛和 latex 还很陌生,这是我第一次发帖。我在项目中有一个名为 xyz.tex 的文件,如下所示:

            &\multicolumn{8}{c}{var name}                                                               \\
            &           N&        Mean&          SD&         Min&     10th p.&      Median&     90th p.&         Max\\
\midrule
x     &         a&       b&       c&           0&           1&           1&           1&           1\\
y &         120&       0.825&       0.382&           0&           0&           1&           1&           1\\
z     &         243&       0.778&       0.417&           0&           0&           1&           1&           1\\

我在 overlead 上编译 pdf 时遇到错误,但当我删除 \usepackage{booktabs} 时,pdf 呈现了,但表格没有线条等。我不确定如何粘贴错误。我不确定为什么会发生这种情况。任何帮助都值得感激。

答案1

尝试

\RequirePackage{filecontents}
    \begin{filecontents}{xyz.txt}
    & \multicolumn{8}{c}{var name} \\
    \cmidrule(l){2-9}
    & N     & Mean  & SD    & Min   & 10th p.   & Median & 90th p.  & Max   \\
    \midrule
x   & a     & b     & c     & 0     & 1         & 1      & 1        & 1     \\
y   & 120   & 0.825 & 0.382 & 0     & 0         & 1      & 1        & 1     \\
z   & 243   & 0.778 & 0.417 & 0     & 0         & 1      & 1        & 1     
    \end{filecontents}
    
\documentclass{article}
\usepackage[margin=1in]{geometry} 
\usepackage{pdflscape}
\usepackage{amsmath, amssymb}
\usepackage{bm}
\usepackage{setspace}  % line spacing
\onehalfspacing
\usepackage{graphicx}
\usepackage{adjustbox}
\usepackage{rotating}  % for sidewaystable

\usepackage{booktabs}
\usepackage{dcolumn}    % aligning decimals
    \newcolumntype{d}[1]{D{.}{.}{#1}}
\usepackage{threeparttable}

\let\estinput=\input % define a new input command so that we can still flatten the document

\newcommand{\estauto}[3]{
    \begin{tabular}{l*{#2}{#3}}
    \toprule
    \estinput{#1}  \\
    \bottomrule
    \end{tabular}
                        }

\newcommand{\sym}[1]{\rlap{#1}}
\usepackage{tabulary}
\usepackage{hyperref}

\title{Project Name}
\author{X Y Z}
\date{September 2021}

\begin{document}
\maketitle

\section*{Summary Statistics (Tables)}
\subsection*{Consent}
\begin{table}[!htbp]
    \centering
    \caption{caption}
    \label{tab:meetattend}
\estauto{xyz.txt}{8}{c}     \\ % <--- added \\

    \small{\textit{Notes:}}
\end{table}
\end{document}

与您的 MWE 相比,差异在于:

  • 餐桌如何摆放
  • 如何将故事插入文档中

编译结果为:

在此处输入图片描述

相关内容