我编写了下表:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[]{booktabs}
\title{table}
\author{subham.soni007 }
\date{March 2015}
\begin{document}
\begin{table}[h]
\begin{tabular}{@{}lll@{}}
\toprule
\multicolumn{1}{c}{\textbf{PARAMETER}} & \multicolumn{1}{c}{\textbf{EXISTING SYSTEM}} & \multicolumn{1}{c}{\textbf{PROPOSED SYSTEM}} \\ \midrule
\textbf{Type} & Content-Based & Service-Based \\
\textbf{User’s Context} & \begin{tabular}[c]{@{}l@{}}The dialogue does not change \\ according to user’s context\end{tabular} & \begin{tabular}[c]{@{}l@{}}The dialogue changes according \\ to user’s context and needs\end{tabular} \\
\textbf{\begin{tabular}[c]{@{}l@{}}Failure\\ Recovery\end{tabular}} & \begin{tabular}[c]{@{}l@{}}User is not notified \\ about the failure\end{tabular} & \begin{tabular}[c]{@{}l@{}}The session is maintained, next time\\ when the user calls\end{tabular} \\
\textbf{\begin{tabular}[c]{@{}l@{}}Number\\ of Dialogues\end{tabular}} & Fixed & Variable \\
\textbf{\begin{tabular}[c]{@{}l@{}}Use of Domain-Specific\\ Knowledge\end{tabular}} & \begin{tabular}[c]{@{}l@{}}Does\\ not use\end{tabular} & Uses domain-specific knowledge \\ \bottomrule
\end{tabular}
\end{table}
\end{document}
当我在 WinEdt 中编译时,出现错误,在 \begin{tabular}{@{}lll@{}} 附近缺少的数字被视为零。但是当我使用 sharelatex 编译时,一切都正常。问题是什么?
答案1
我建议使用这个更简单的代码:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[]{booktabs}
\setlength\defaultaddspace{1.25ex}
\usepackage{ragged2e}
\usepackage{array, tabularx}
\renewcommand{\tabularxcolumn}[1]{>{\RaggedRight\arraybackslash} m{#1}}
\newcolumntype{Y}{ >{\bfseries\RaggedRight\hsize=0.9\hsize}X}
\newcolumntype{Z}{ >{\RaggedRight\hsize=1.1\hsize}X}
\usepackage{makecell}
\renewcommand\theadalign{{p{5cm}}c}
\renewcommand\theadfont{\bfseries}
\title{table}
\author{subham.soni007 }
\date{March 2015}
\begin{document}
\begin{table}[h]
\setlength\tabcolsep{4pt}%
\begin{tabularx}{\linewidth}{@{\,}>{\bfseries}YXZ@{\,}}
\toprule
\thead{PARAMETER} & \thead{EXISTING SYSTEM} & \thead{PROPOSED SYSTEM} \\
\midrule
Type & Content-Based & Service-Based \\
\addlinespace
User’s Context & The dialogue does not change according to user’s context & The dialogue changes according to user’s context and needs \\
\addlinespace
Failure Recovery & User is not notified about the failure & The session is maintained, next time when the user calls \\
\addlinespace
Number\break of Dialogues & Fixed & Variable \\
\addlinespace
Use of Domain-Specific Knowledge
& Does not use & Uses domain-specific knowledge \\
\bottomrule
\end{tabularx}
\end{table}
\end{document}
答案2
不要使用全大写的标题和粗体字体为了提供视觉强调,我会专注于优化表格的结构,以提高其可读性和可理解性。为此,通常最好避免重复材料,并将重要信息移到表格的标题行和最左侧的列中。
这是您的桌子前后的外观对比。
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{booktabs,ragged2e,tabularx}
\newcolumntype{L}{>{\RaggedRight\arraybackslash}X}
\usepackage{xcolor} % just for this example
\begin{document}
\noindent
\textcolor{red}{\texttt{after}}
\begin{table}[h]
\begin{tabularx}{\textwidth}{@{} LLL @{}}
\toprule
Parameter & Existing System & Proposed System \\
\midrule
Type & Content-based & Service-based \\ \addlinespace
Dialogue changes with user's context and needs & No & Yes \\ \addlinespace
Failure recovery & User is not notified about the failure
& Session is maintained, next time when the user calls \\ \addlinespace
Number of dialogues & Fixed & Variable \\ \addlinespace
Use of domain-specific knowledge & No & Yes \\
\bottomrule
\end{tabularx}
\end{table}
\bigskip\noindent
\textcolor{red}{\texttt{before}} (width of text block is exceeded massively)
\begin{table}[h]
\begin{tabular}{@{}lll@{}}
\toprule
\multicolumn{1}{c}{\textbf{PARAMETER}} & \multicolumn{1}{c}{\textbf{EXISTING SYSTEM}} & \multicolumn{1}{c}{\textbf{PROPOSED SYSTEM}} \\ \midrule
\textbf{Type} & Content-Based & Service-Based \\
\textbf{User’s Context} & \begin{tabular}[c]{@{}l@{}}The dialogue does not change \\ according to user’s context\end{tabular} & \begin{tabular}[c]{@{}l@{}}The dialogue changes according \\ to user’s context and needs\end{tabular} \\
\textbf{\begin{tabular}[c]{@{}l@{}}Failure\\ Recovery\end{tabular}} & \begin{tabular}[c]{@{}l@{}}User is not notified \\ about the failure\end{tabular} & \begin{tabular}[c]{@{}l@{}}The session is maintained, next time\\ when the user calls\end{tabular} \\
\textbf{\begin{tabular}[c]{@{}l@{}}Number\\ of Dialogues\end{tabular}} & Fixed & Variable \\
\textbf{\begin{tabular}[c]{@{}l@{}}Use of Domain-Specific\\ Knowledge\end{tabular}} & \begin{tabular}[c]{@{}l@{}}Does\\ not use\end{tabular} & Uses domain-specific knowledge \\ \bottomrule
\end{tabular}
\end{table}
\end{document}