我正在尝试制作一个表格。以下是表格的示例。但我得到了数组中的非法字符错误。我已经搜索了所有相关问题,但没有找到任何解决方案。我做错了什么?
\begin{table*}[!ht]
\centering
\caption{Predictor Name and Data Source}
\label{data}
\resizebox{\textwidth}{!}{%
\begin{tabular}{|l|l|l|1|}
\hline
\textbf{Type} & \textbf{Predictor Name} & \textbf{Acronym} & \textbf{Data Source} \\ \hline
\multirow{9}{*}{Predictor} & Company Id & COMID & Lankabd.com \\
\cline{2-4}
& Lower Price & LOWPRCP & Household Size \\
\cline{2-4}
& High Price & HIPRC & Male Literacy \\
\cline{2-4}
& Average Price & AVGPRC & Low Land \\
\cline{2-4}
& Weighted Average Price & WTAVGPRC & Low Land \\
\cline{2-4}
& Trade Number & TRDNO & Low Land \\
\cline{2-4}
& Trade Volume & TRDVOL & Low Land \\
\cline{2-4}
& Issued Share & ISSUEDSHARE & Low Land \\
\cline{2-4}
& Turn Over & TURNOVER & Households \\
\hline
\end{tabular}%
}
\end{table*}
答案1
获得宽度等于文本块宽度的表格的更好方法是使用tabular*
环境。
我还建议您通过去掉所有垂直线并使用更少但间距适当的水平线,让您的表格看起来更加“开放”。
\documentclass{article}
\usepackage{graphicx,multirow,booktabs,caption}
\captionsetup{skip=0.333\baselineskip}
\begin{document}
\begin{table*}[!ht]
\centering
\caption{Original form}
\label{data}
\resizebox{\textwidth}{!}{%
\begin{tabular}{|l|l|l|l|}
\hline
\textbf{Type} & \textbf{Predictor Name} & \textbf{Acronym} & \textbf{Data Source} \\ \hline
\multirow{9}{*}{Predictor} & Company Id & COMID & Lankabd.com \\
\cline{2-4}
& Lower Price & LOWPRCP & Household Size \\
\cline{2-4}
& High Price & HIPRC & Male Literacy \\
\cline{2-4}
& Average Price & AVGPRC & Low Land \\
\cline{2-4}
& Weighted Average Price & WTAVGPRC & Low Land \\
\cline{2-4}
& Trade Number & TRDNO & Low Land \\
\cline{2-4}
& Trade Volume & TRDVOL & Low Land \\
\cline{2-4}
& Issued Share & ISSUEDSHARE & Low Land \\
\cline{2-4}
& Turn Over & TURNOVER & Households \\
\hline
\end{tabular}%
}
\end{table*}
\begin{table*}[!ht]
\caption{Proposed new look: No \texttt{\string\resizebox}, no vertical rules, \& fewer but well-spaced horizontal rules}
\label{take-two}
\setlength\tabcolsep{0pt}
\begin{tabular*}{\textwidth}{@{\extracolsep{\fill}}llll}
\toprule
\textbf{Type} & \textbf{Predictor Name} & \textbf{Acronym} & \textbf{Data Source} \\
\midrule
Predictor
& Company Id & COMID & Lankabd.com \\
& Lower Price & LOWPRCP & Household Size \\
& High Price & HIPRC & Male Literacy \\
\addlinespace
& Average Price & AVGPRC & Low Land \\
& Weighted Average Price & WTAVGPRC & Low Land \\
& Trade Number & TRDNO & Low Land \\
\addlinespace
& Trade Volume & TRDVOL & Low Land \\
& Issued Share & ISSUEDSHARE & Low Land \\
& Turn Over & TURNOVER & Households \\
\bottomrule
\end{tabular*}
\end{table*}
\end{document}