我的表格以前可以正常工作,但突然出现错误,说当我在表格中更改某些输入时,我放错了 \noalign。
有人可以帮我看一下代码吗?
例如:
\documentclass{article}
\usepackage{tabularx}
\usepackage{booktabs}
\usepackage{multirow}
\usepackage{ragged2e}
\newcolumntype{L}{ >{\RaggedRight}X }
\usepackage{siunitx}
\usepackage{makecell}
\renewcommand\theadfont{\normalfont\bfseries}
\setlength\parindent{0pt}
\newcolumntype{Y}{ >{\Centering}X}
\usepackage[justification=centering]{caption}
\setlength\parindent{0pt}
\newcolumntype{L}{>{\RaggedRight\arraybackslash}X}
\newcolumntype{C}{>{\Centering\arraybackslash}X}
\renewcommand\theadfont{\normalfont\bfseries}
\newcommand\mc[1]{\multicolumn{2}{c}{#1}}
\setlength\parindent{0pt}
\begin{document}
\begin{tabularx}{\textwidth}{@{} lYYYYYY @{}}
\toprule
\thead[lc]{Category }& \thead{Strategies}& {\thead{Annualized \\ Mean}} & {\thead{Annualized \\ Volatility}} & {\thead{Skew}} & {\thead{kurtosis}} & {\thead{Sharpe \\ Ratio}}
\midrule
\multirow{2}{*}{ Momentum } & TSMOM(1,1) & 3.18 & 3.84 & -0.26 & 20.06 & 0.00 \\
& TSMOM(3,3) & 11.85 & 7.76 & -1.96 & 24.72 & 0.00 \\ \addlinespace
\multirow{5}{*}{ Size } & Top Decile & 12.70 & 9.26 & 1.44 & 1.44 & 15.80 \\
& 9\textsuperscript{th} Decile & 0.11 & 8.49 & 0.49 & 12.73 & 0.00\\
& Bottom Decile & 0 & 1.00 & 1.00 \\
& 2\textsuperscript{nd} Decile & 0 & 0.23 & 1.00\\
& Top minus Bottom & 0 & 1.00 & 1.00\\
\addlinespace
\multirow{7}{*}{ Value } & Top Decile & 0 & 1.00 & 1.00\\
& Bottom Decile & 0 & 1.00 & 1.00 \\
& Top Minus Lowest (Decile) & 0 & 1.00 & 1.00 \\
& Top 30\textsuperscript{th} Percentile & 0 & 1.00 & 1.00 \\
& Mid 40\textsuperscript{th} Percentile & 0 & 0.29 & 1.00 \\
& Bottom 30\textsuperscript{th} Percentile & 0 & 1.00 & 1.00 \\
& Highest Minus Lowest 30\textsuperscript{th} & 0 & 1.00 & 1.00 \\
\bottomrule
\end{tabularx}
\end{document}
任何建议都值得感激。
谢谢
答案1
您的问题只是简单的输入错误。错误消息明确表明\midrule
您没有命令end of line
。
无论如何,这个问题已经通过注释解决了,我建议你再检查一下你的序言。其中你有很多重复的定义,有些也是错误的。所以,看看我对你的代码的清理:
\documentclass{article}
\usepackage{booktabs,makecell,multirow,tabularx}
\usepackage{ragged2e}
\renewcommand\theadfont{\normalfont\bfseries}
%\newcolumntype{L}{>{\RaggedRight}X }% duplicate, wrong, missing \arraybackslash
\newcolumntype{L}{>{\RaggedRight\arraybackslash}X}
\newcolumntype{C}{>{\Centering\arraybackslash}X}
%\newcolumntype{Y}{>{\Centering}X}% duplicate, wrong, missing \arraybackslash,
%\renewcommand\theadfont{\bfseries}% default settings is ok
\newcommand\mc[1]{\multicolumn{2}{c}{#1}}
%\setlength\parindent{0pt}% duplicate
%\setlength\parindent{0pt}% duplicate
\setlength\parindent{0pt}
\usepackage[justification=centering]{caption}
\usepackage{siunitx}
\usepackage[margin=30mm,showframe]{geometry}% added for better column layout
\begin{document}
\setlength{\tabcolsep}{4pt}
\begin{tabularx}{\textwidth}{@{} l L *{5}{S[table-format=3.3]} @{}}
\toprule
\thead[b]{Category}
& {\thead[b]{Strategies}}
& {\thead[b]{Annualized \\ Mean}}
& {\thead[b]{Annualized \\ Volatility}}
& {\thead[b]{Skew}}
& {\thead[b]{Kurtosis}}
& {\thead[b]{Sharpe \\ Ratio}} \\
\midrule
\multirow{2}{*}{ Momentum } & TSMOM(1,1) & 3.18 & 3.84 & -0.26 & 20.06 & 0.00 \\
& TSMOM(3,3) & 11.85 & 7.76 & -1.96 & 24.72 & 0.00 \\ \addlinespace
\multirow{5}{*}{ Size } & Top Decile & 12.70 & 9.26 & 1.44 & 1.44 & 15.80 \\
& 9\textsuperscript{th} Decile & 0.11 & 8.49 & 0.49 & 12.73 & 0.00\\
& Bottom Decile & 0 & 1.00 & 1.00 \\
& 2\textsuperscript{nd} Decile & 0 & 0.23 & 1.00\\
& Top minus Bottom & 0 & 1.00 & 1.00\\
\addlinespace
\multirow{7}{*}{ Value } & Top Decile & 0 & 1.00 & 1.00\\
& Bottom Decile & 0 & 1.00 & 1.00 \\
& Top Minus Lowest (Decile) & 0 & 1.00 & 1.00 \\
& Top 30\textsuperscript{th} Percentile & 0 & 1.00 & 1.00 \\
& Mid 40\textsuperscript{th} Percentile & 0 & 0.29 & 1.00 \\
& Bottom 30\textsuperscript{th} Percentile & 0 & 1.00 & 1.00 \\
& Highest Minus Lowest 30\textsuperscript{th} & 0 & 1.00 & 1.00 \\
\bottomrule
\end{tabularx}
\end{document}