[英]Fit table size with the page size in latex
我有許多列數不同的表格,這些表格應該適合頁面大小。 為此,我使用了類似於下面的代碼:
\begin{table}
\caption{Values}
\centering
\resizebox{\linewidth}{!}{
\begin{tabular}{!{\vrule}l!{\vrule}l!{\vrule}l!{\vrule}l!{\vrule}l!{\vrule}l}
\toprule
DS & Criterion1 & Criterion2 & Criterion3 & Criterion4 \\
\midrule
DS1 & V1 & V2 & V3 & V4 \\
\midrule
DS2 & V5 & V6 & V7 & V8 \\
\midrule
DS3 & V9 & V10 & V11 & V12 \\
\midrule
DS4 & V13 & V14 & V15 & V16 \\
\botrule
\end{tabular}
}
\end{table}
此代碼生成表,但顯示以下類型的錯誤:數組 arg 中的非法字符。 我不明白這個錯誤。
任何幫助將非常感激。
我建議編輯您的代碼:
\documentclass[10pt]{article}
\usepackage{tabularx,booktabs}
\begin{document}
\noindent
\begin{table}
\caption{Values}
\label{tab:n}
\centering
\begin{tabularx}{\textwidth}{*{5}{X}}
\toprule
DS & Criterion1 & Criterion2 & Criterion3 & Criterion4 \\
\midrule
DS1 & V1 & V2 & V3 & V4 \\
\midrule
DS2 & V5 & V6 & V7 & V8 \\
\midrule
DS3 & V9 & V10 & V11 & V12 \\
\midrule
DS4 & V13 & V14 & V15 & V16 \\
\bottomrule
\end{tabularx}
\end{table}
\end{document}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.