表格生成器:额外的对齐标签已更改为 cr

表格生成器:额外的对齐标签已更改为 cr

我使用 table.generator 网站生成我的乳胶表,但它总是显示此错误:额外的对齐标签已更改为 cr

% Please add the following required packages to your document preamble:
% \usepackage{multirow}
\begin{table}[]
    \begin{tabular}{|l|l|l|}
    \hline
    \textbf{Log} &
    \textbf{Structure} &
    \textbf{Collector}
    \\ \hline
    \begin{tabular}[c]{@{}l@{}}User Control \\ Log\end{tabular}  & 
    \begin{tabular}[c]{@{}l@{}}Command ID, Controlled Device, \\ Control 
    Action, 
    Timestamp\end{tabular} & \begin{tabular}[c]{@{}l@{}}Control Log \\ 
    Collector\end{tabular}                  \\ \hline
    \begin{tabular}[c]{@{}l@{}}User Activity \\ Log\end{tabular} & Activity, 
    Start Time, End Time                                                                      
    & \multirow{2}{*}{\begin{tabular}[c]{@{}l@{}}Sensory Logs \\ 
    Collector\end{tabular}} \\ \cline{1-2}
    \begin{tabular}[c]{@{}l@{}}SHS States \\ Log\end{tabular}    & 
    \begin{tabular}[c]{@{}l@{}}Timestamp, State of Devicei, …, \\ State of 
    Devicen\end{tabular}         &                                                                                    
    \\ \hline
    \end{tabular}
\end{table}

应该显示的表格 在此处输入图片描述

请问我的脚本哪里出了问题?

PS:我按照生成器的要求包含了该包

答案1

像这样?我用包给单元格添加了一些垂直填充,并根据更轻的代码cellspace定义了一种新的列类型:X

\documentclass[11pt]{article}
\usepackage{caption, tabularx, cellspace}
\setlength{\cellspacetoplimit}{8pt}
\setlength{\cellspacebottomlimit}{8pt}
\addparagraphcolumntypes{X}
\usepackage{ragged2e}
\usepackage[table, svgnames]{xcolor}
\usepackage{multirow}
\newcolumntype{L}{>{\RaggedRight\arraybackslash}S{X}}

\begin{document}

\begin{table}
\setlength{\fboxsep}{0pt}
\fcolorbox{black}{WhiteSmoke}{\begin{tabularx}{\textwidth}{|>{\hsize =0.65 \hsize}L|>{\hsize =1.7\hsize}L|>{\hsize =0.65 \hsize}L|}
\cellcolor{Khaki!80}\textbf{Log} & \textbf{Structure} & \textbf{Collector} \\\hline
User Control Log
                & Command ID, Controlled Device, Control Action, Timestamp
                & Control Log Collector \\ \hline
User Activity Log
                & Activity, Start Time, End Time
                & \multirow{2}{=} {Sensory Logs Collector}\\ \cline{1-2}
SHS States Log
                & Timestamp, State of Devicei, …, State of Devicen
                  \\
\end{tabularx}}
\end{table}

\end{document} 

在此处输入图片描述

答案2

在此处输入图片描述

这可能会为你指明正确的方向——删除该行\usepackage{showframe}以停止查看页面框架

数学家协会

\documentclass{article}
\usepackage{caption,tabularx,booktabs}
\usepackage[table]{xcolor}
\usepackage{showframe}
\usepackage{multirow}
\begin{document}
\begin{table}
\begin{tabularx}{\textwidth}{lXl}
\hline \rowcolor{green!20}
\textbf{Log} & \textbf{Structure} & \textbf{Collector} \\\hline
User Control Log  
                & Command ID, Controlled Device, Control Action, Timestamp  
                & Control Log Collector           \\ \hline\rowcolor{gray!20}
User Activity Log  
                & Activity, Start Time, End Time  
                &                                  \\ \rowcolor{red!20}
SHS States Log  
                & Timestamp, State of Devicei, …, State of Devicen   
                & \multirow{-2}{*} {Sensory Logs Collector}     \\ \hline
\end{tabularx}
\end{table}
\end{document}

相关内容