[Tex/LaTex] Error: Something’s wrong–perhaps a missing \item. \end{tabularx}

liststables

Please, I've tried to apply the solutions in this website to solve this issue but I've got nothing.

I literally do not know how can I solve it.

Please, any help will be highly appreciated it.

    %% ----------------------------------------------------------------
%% Thesis.tex -- MAIN FILE (the one that you compile with LaTeX)
%% ---------------------------------------------------------------- 

% Set up the document

\documentclass[a4paper, 11pt, arial, oneside]{Thesis}   % Use the "Thesis" style, based on the ECS Thesis style by Steve Gunn

\usepackage{charter}
\usepackage[scaled=0.92]{helvet}
%\usepackage [T1] {fontenc}
%\renewcommand\familydefault{phv}



%\graphicspath{{figs/}}  % Location of the graphics files (set up for graphics to be in PDF format)

% Include any extra LaTeX packages required
\usepackage[square, numbers, comma, sort&compress]{natbib}  % Use the "Natbib" style for the references in the Bibliography
\usepackage{verbatim}  % Needed for the "comment" environment to make LaTeX comments
\usepackage{vector}  % Allows "\bvec{}" and "\buvec{}" for "blackboard" style bold vectors in maths
%\hypersetup{urlcolor=blue, colorlinks=true}  % Colours hyperlinks in blue, but this can be distracting if there are many links.

\usepackage[toc,page]{appendix}


\usepackage{graphicx}
\usepackage{romannum}
\usepackage{enumerate}

%\usepackage{booktabs}
%\usepackage[hmargin={30mm,25mm},vmargin=25mm]{geometry}
%\usepackage{array,ragged2e}
%\newcolumntype{R}[1]{>{\RaggedRight}p{#1}}

%\usepackage{enumitem}
%\usepackage{etoolbox}
%\AtBeginEnvironment{table}{%
%   \setlist[itemize]{  nosep,     % <-- new list setup
%       leftmargin = *,
%       before     = \vspace{-0.6\baselineskip},
%       after      = \vspace{-\baselineskip}
%   }
%}
%\usepackage{showframe}
%\usepackage{geometry}
\usepackage{ragged2e, tabularx}
\usepackage{array, booktabs, longtable}
\newcolumntype{R}[1]{>{\RaggedRight\hspace{0pt}}p{#1}}
\usepackage[skip=1ex,labelfont=bf,font=small]{caption}

\usepackage[shortlabels]{enumitem}
\usepackage{etoolbox}
\AtBeginEnvironment{longtable}{%
    \small                              % for better fit text into cells
    \setlength{\LTcapwidth}{\linewidth} % that caption width is equal table width
    \setlist[itemize]{  nosep,          % <-- new list setup
        leftmargin = *,
        before     = \vspace{-\baselineskip},
        after      = \vspace{-\baselineskip}
    }
}% end of AtBeginEnvironment

\AtBeginEnvironment{table}{%
    \setlist[itemize]{nosep,
        wide,%leftmargin = *,
        before     = \vspace{-\baselineskip},
        after      = \vspace{-\baselineskip}
    }
}% end of AtBeginEnvironment

\newcolumntype{L}{>{\RaggedRight\setlength\parskip{0.2\baselineskip}\arraybackslash}X}
\setlength\extrarowheight{1pt}

\usepackage[space]{grffile}
\usepackage{latexsym}
\usepackage{textcomp}
\usepackage{longtable}
\usepackage{multirow,booktabs}
\usepackage{amsfonts,amsmath,amssymb}
\usepackage{url}
\usepackage{hyperref}
\hypersetup{colorlinks=true,pdfborder={0 0 0},linkcolor=blue,urlcolor=blue,citecolor=red}
% You can conditionalize code for latexml or normal latex using this.
\newif\iflatexml\latexmlfalse
\providecommand{\tightlist}{\setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}%

\DeclareGraphicsExtensions{.pdf,.PDF,.png,.PNG,.jpg,.JPG,.jpeg,.JPEG}

%\usepackage[utf8]{inputenc}
\usepackage[british]{babel}


% correct bad hyphenation here
\hyphenation{op-tical net-works semi-conduc-tor}
\usepackage{siunitx} % For units
\newcommand\mmfeed[1]{\textcolor{red}{#1}}

\usepackage{xcolor}

\usepackage{caption}
\usepackage{subcaption}
\usepackage{lipsum}

\captionsetup[figure]{labelfont={bf,small},textfont={small}}
\captionsetup[subfloat]{labelfont={bf,small}, textfont={small}, subrefformat=parens} %<-----designing subcaption
\newcommand{\myfigref}[2]{~\ref{#1}.\subref{#2}}% <---- a new macro for referring to a subfigure
%    

%\newpage
%\bibliographystyle{plain}
%\bibliography{bibliografia}

% Change the text font
\renewcommand{\rmdefault}{phv} % Arial
\renewcommand{\sfdefault}{phv} % Arial
%



\usepackage{multirow}
\usepackage{cleveref}


% I added many usepackages
%% ----------------------------------------------------------------
\begin{document}

\begin{table}[htb]
    \caption{Parameter settings of the present study}
    \label{5.1}
    \centering
    %   \resizebox{\columnwidth}{!}{%
    \begin{tabularx}{\textwidth}{ p{6cm} p{5cm} c }
        %\hline
        \toprule
        \textbf{The image processing stage} & \textbf{Parameter} & \textbf{Value}  \\ 
        %\hline
        \midrule
        Post-processing of the shadow mask
        &           
        \begin{itemize}
            \item   Intensity threshold ($T_{I}$)
            \item   Ratio threshold ($T_{R}$)
            \item   Height threshold ($T_{height}$)
        \end{itemize}
        &       
        \begin{itemize}
            \item   Intensity threshold ($T_{I}$)
            \item   Ratio threshold ($T_{R}$)
            \item   Height threshold ($T_{height}$)
        \end{itemize}
        \\


        \bottomrule
    \end{tabularx}
    %   }

\end{table}

\end{document}

Best Answer

You can have a list environment in a table cell only if the column has a paragraph-like specifier (p, m, b, X and so on). The problem cmes from you last column, which is not in paragraph mode.

I simplified the code for your table, defining an L column type, which is, roughly, an X column type entering in an ad hoc itemize on entering a cell, and ending itemize on leaving the cell, so you only have to type the items.

    \documentclass{article}
    \usepackage{caption, tabularx, booktabs}
\usepackage[showframe]{geometry}
\usepackage{amsmath}
\usepackage{enumitem, ragged2e}

    \makeatletter
    \newcommand*{\compress}{\@minipagetrue}
    \makeatother
  \newcolumntype{L}{ >{\compress\itemize}X<{\enditemize}}

    \begin{document}

\begin{table}[! htb]
    \caption{Parameter settings of the present study}
    \label{5.1}
    \centering
\setlist[itemize]{wide=0pt, leftmargin=*, itemsep=0pt, after =\vspace*{-\dimexpr\baselineskip + \partopsep}}
        \begin{tabularx}{\linewidth}{ p{5cm}*{2}{>{\RaggedRight\arraybackslash}L}}
            \toprule
 \multicolumn{1}{c}{\bfseries The image processing stage} & \multicolumn{1}{c}{\bfseries Parameter} &\multicolumn{1}{c}{ \bfseries Value} \\
 \midrule
            Post-processing of the shadow mask
            &
                \item Intensity threshold ($T_{I}$)
                \item Ratio threshold ($T_{R}$)
                \item Height threshold ($T_\text{height}$)
            &
                \item Intensity threshold ($T_{I}$)
                \item Ratio threshold ($T_{R}$)
                \item Height threshold ($T_\text{height}$)
             \\
            \bottomrule
        \end{tabularx}
\end{table}

    \end{document} 

enter image description here

Related Question