0

I used table.generator website to generate my latex table but it always shows me this error: extra alignment tab has been changed to 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}

The table that supposed to be displayed enter image description here

Where is the problem in my script, please?

PS: I included the package as demanded by the generator

5
  • 1
    You have to change collumn with &, so: \textbf{Log} & \textbf{Structure} & \textbf{Collector}
    – Sigur
    Commented Jan 20, 2020 at 14:41
  • Question Edited: they already exist in my script, I just forget them when I was wiring this question Commented Jan 20, 2020 at 14:45
  • 1
    I can not reproduce the error here. Everything is fine. I'm using updated TL2019 on Linux.
    – Sigur
    Commented Jan 20, 2020 at 15:07
  • I am preparing a journal research article and the problem is that this code worked fine in Elsevier template, but it does not in IET (research community) template, I don't know why! What do you think it can be missing in the second template (package, etc.)? Commented Jan 20, 2020 at 15:14
  • Sorry, I have no idea about IET template. Try to edit your code and insert a minial working example, so we can test exactly you are doing.
    – Sigur
    Commented Jan 20, 2020 at 15:15

2 Answers 2

1

Like this? I added some vertical padding to the cells with the cellspace package, and defined a new column type based on X to have a lighter code:

\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} 

enter image description here

0

enter image description here

This may point you in the right direction-- delete the line \usepackage{showframe} to stop seeing the page frame

The MWE

\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}
2
  • 2
    I'm not sure if this is an answer since the OP code has no problem, except when using that IET template, as mentioned in comments.
    – Sigur
    Commented Jan 20, 2020 at 15:37
  • since the OP code is from a table generator better to simplify
    – js bibra
    Commented Jan 20, 2020 at 15:38

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .