错误:出现问题 - 可能缺少 \item。\end{tabularx}

错误:出现问题 - 可能缺少 \item。\end{tabularx}

请问,我已尝试使用此网站上的解决方案来解决这个问题,但没有得到任何结果。

我实在不知道该如何解决这个问题。

如有任何帮助,我们将不胜感激。

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

答案1

仅当列具有段落式说明符(p, m, b, X等等)时,您才可以在表格单元格中拥有列表环境。问题出在最后一列,它不在段落模式下。

我简化了表格的代码,定义了一个L列类型,大致就是X输入一个列类型特别指定在进入单元格时逐项列出,在离开单元格时结束逐项列出,因此您只需键入项目。

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

在此处输入图片描述

相关内容