在 LaTeX 中生成表格 - 错误

在 LaTeX 中生成表格 - 错误

我想在 LaTeX 中生成如下所示的表格(仅包含顶部、中间和底部!规则)并且没有单元格分隔符。这是我的 MWE。我收到很多错误。这里的问题是什么?

\documentclass[12pt]{article}
\usepackage{booktabs}
\begin{document}
\begin{tabular}{CCC}
\toprule
Parameters & Linux & Windows
\midrule
Number of users & Linux have a plus point that many users can be logged into the system\\ simultaneously.SSH (Secure Shell security) is used in this process.ThisProcessor’s capability is distributed amongst the users. In this way various users can access the resources at the same time. & There are many windows operating systems considered as single user and multi user. Windows XP, 7 are single user. Multi user comprises of Windows NT.There can be many users logged in the operating system but only one can use it at a time.
\bottomrule
\end{tabular}
\end{document}

在此处输入图片描述

答案1

这是修正后的代码。我已在其中注释了更改。

\documentclass[12pt]{article}
\usepackage{booktabs}
\usepackage{ragged2e}
\usepackage{array}
\newcolumntype{L}{>{\RaggedRight\arraybackslash}p{\dimexpr0.33\textwidth-2\tabcolsep\relax}}
\begin{document}
\noindent
\begin{tabular}{LLL}
\toprule
Parameters & Linux & Windows\\  %% missing \\
\midrule
Number of users & Linux have a plus point that many users can be logged into the system %% no need of \\
                  simultaneously.SSH (Secure Shell security)is used in this process. This Processor’s 
                  capability is distributed amongst the users.In this way various users can access the 
                  resources at the same time. 
                  & There are many windows operating systems 
                  considered as single user and multi user. Windows XP, 7 are single user. 
                  Multi user comprises of Windows NT.There can be many users logged in the 
                  operating system but only one can use it at a time. \\ %% missing \\
\bottomrule
\end{tabular}
\end{document}

在此处输入图片描述

答案2

OP 使用了 [CCC],但该符号未定义,且\\在行尾缺失。对于单元格中的换行符,您需要\newline

或者使用tabularxX列。表格宽度可以由用户确定,X列就像一个段落设置,它将根据表格的宽度自动确定其列宽。

在此处输入图片描述

代码

\documentclass[12pt]{article}
\usepackage[margin=1cm]{geometry}
\usepackage{booktabs,array}
\usepackage{tabularx}
\begin{document}

\begin{tabularx}{0.8\textwidth}{XXX}
\toprule
Parameters & Linux & Windows\\
\midrule
Number of users & Linux have a plus point that many users can be logged into the system\newline simultaneously.SSH (Secure Shell security) is used in this process.ThisProcessor's capability is distributed amongst the users. In this way various users can access the resources at the same time. & There are many windows operating systems considered as single user and multi user. Windows XP, 7 are single user. Multi user comprises of Windows NT.There can be many users logged in the operating system but only one can use it at a time.\\
\bottomrule
\end{tabularx}
\end{document}

相关内容