文档中有 2 个表格 - 错误消息“出现问题 - 可能缺少 \item。\end{tabularx}”

文档中有 2 个表格 - 错误消息“出现问题 - 可能缺少 \item。\end{tabularx}”

我的文档中有两个表格,但编译时出现错误消息

出了点问题——可能缺少 \item。\end{tabularx}

编译仅包含一个表的文档时没有问题。编译包含两个表的文档时出现错误消息,但我可以看到两个表。

看起来enumerate可能会引起问题。我尝试遵循以下建议:TEX 链接但没有成功。

有人可以建议一种解决该错误的方法吗?

梅威瑟:

\documentclass[a4paper,12pt]{article}
\usepackage{color}
\usepackage{graphicx, epstopdf}
\usepackage[british]{babel}
%\usepackage{gensymb}
\usepackage[section]{placeins}%Allows you to permanently fix figures. 
\usepackage{titleps}%fancy page borders? 
\usepackage[left=2.5cm, right=2.5cm, top=3.5cm, bottom=3.5cm]{geometry}%this changes the page geometry i.e. margins left, right, top and bottom
%\usepackage{caption}
\usepackage{microtype}
\usepackage{setspace}
\usepackage{amsmath}
\usepackage{SIunits}
\usepackage{mathptmx}
\usepackage{tabularx}
\usepackage{booktabs,caption, makecell}
\usepackage{pdflscape,afterpage}
\onehalfspacing

\usepackage{geometry}
\usepackage{booktabs, makecell, ltablex}
\usepackage{caption}

\renewcommand\theadfont{\small\bfseries}
\renewcommand\tabularxcolumn[1]{m{#1}}
\usepackage[usestackEOL]{stackengine}

\usepackage[table]{xcolor}

\usepackage{pdflscape,afterpage}

\usepackage{enumitem}   % <--- added
\usepackage{etoolbox}   % <--- added
\AtBeginEnvironment{table}{%
    \setlist[enumerate]{nosep,     % <--- added
        topsep     = 0pt,
        partopsep  = 0pt,
        leftmargin = *         ,
        before     = \vspace{-0.6\baselineskip},
        after      = \vspace{-\baselineskip}
}}

\begin{document}
    \begin{table}[ht]
        \caption{Cognitive walkthrough goals, tasks and actions}
        \label{table:comparison of techniques}
        \small
        \begin{tabularx}{\linewidth}{@{}
                X
                >{\centering\arraybackslash}X  % content of `X` column is now centered
                X
                @{}}
            \toprule
            \thead{\textbf{Goal}}& \thead{\textbf{Task}} & \thead{\textbf{Action}} \\
            \midrule
            Evaluate the ease in which users can join projects
            &   Access and account set up
            &   \begin{enumerate}
                \item   Teast A: Video provides a powerful way to help you prove your point.

                Test B: Video provides a powerful way to help you prove your point.
                \item Video provides a powerful way to help you prove your point.
            \end{enumerate}     \\
            \addlinespace
            Evaluate the ease in learning to map
            &   Learning how to map
            &   Read tutorial   \\
            \addlinespace
            Contribute data
            &   Contributing data by classifying maps
            &   \begin{enumerate}
                \item Video provides a powerful way to help you prove your point.
                \item Test A: Video provides a powerful way to help you prove your point.

                Test B: Video provides a powerful way to help you prove your point.
                \item Video provides a powerful way to help you prove your point.
            \end{enumerate}     \\
            \addlinespace
            Evaluate if the user likes using the application and whether they like using it
            & -- & --                   \\
            \bottomrule
        \end{tabularx}%
    \end{table}

\begin{landscape}% Landscape page
    \small
    \setlength\extrarowheight{2pt}
    \begin{tabularx}{\linewidth}{
            >{\columncolor{red!30}} l
            *{3}{X}X@{}
        }\caption{}
        %\label{table:comparison of techniques}
        \\
        \Xhline{1pt}
        \multicolumn{1}{c}{\cellcolor{red!30}}
        &\bfseries{Is the effect of the current action the same as the user's goals?}{\cellcolor{red!30}} &\bfseries{Is the action visible?}{\cellcolor{red!30}}
        & \bfseries{Will the user recognise the action as the right one?}{\cellcolor{red!30}} &\multicolumn{1}{>{\columncolor{red!30}[6pt][0pt]\bfseries}c@{}}{\Centerstack{Will the user understand \\ the feedback?}} \\
        \Xhline{0.25pt}
        \endfirsthead
        \Xhline{1pt}
        % \rowcolor{red!30}
        \multicolumn{1}{c}{\cellcolor{red!30}}
        &\bfseries{Is the effect of the current action the same as the user's goals?} &\bfseries{Is the action visible?}
        & \bfseries{Will the user recognise the action as the right one?} &\multicolumn{1}{>{\bfseries}c@{}}{\Centerstack{Will the user understand \\ the feedback?}} \\
        \Xhline{0.25pt}
        \endhead
        \Xhline{0.25pt}
        \endfoot
        \Xhline{1pt}
        \endlastfoot
        \rowcolor{black}
        \multicolumn{5}{l}{\textcolor{white}{\bfseries Task 1 - access and account set up}} \\
        Heading
        & TEXT. 
        & TEXT.   
        & TEXT. 
        & TEXT. \\
        \Xhline{0.25pt}
        Heading
        & TEXT. 
        & TEXT.   
        & TEXT. 
        & TEXT. \\
        \rowcolor{black}
        \multicolumn{5}{l}{\textcolor{white}{\bfseries Task 2 - learning how to map}} \\*
        Heading 
        & TEXT. 
        & TEXT.   
        & TEXT. 
        & TEXT. \\
        \rowcolor{black}
        \multicolumn{5}{l}{\textcolor{white}{\bfseries Task 3 - contributing data by classifying maps}} \\
        Heading
        & TEXT. 
        & TEXT.   
        & TEXT. 
        & TEXT. \\
        \Xhline{0.25pt}
        Heading
        & TEXT. 
        & TEXT.   
        & TEXT. 
        & TEXT. \\
        \Xhline{0.25pt}
        Heading
        & TEXT. 
        & TEXT.   
        & TEXT. 
        & TEXT. \\
    \end{tabularx}%
\end{landscape}
\end{document}

提前致谢!

答案1

事实证明,我最初的诊断是将X列归咎于未采用,enumerate这是不正确的。问题出在ltablex包上,解决方案是发出其指令\keepXColumns。以下文档是演示问题的最小文档;如果没有\keepXColumns宏,它会产生您报告的缺失\item错误,而使用宏,它可以很好地编译。

\documentclass{article}

\usepackage{ltablex}
\keepXColumns

\begin{document}

\begin{tabularx}{.9\textwidth}{X}
  \begin{enumerate}
  \item Test.
  \item Test.
  \end{enumerate}
\end{tabularx}

\end{document}

如果没有\keepXColumns,如果空间足够,包ltablex会尝试将X列转换为列。这需要包运行一些试验代码,而这些代码与单元中的环境l不太匹配。enumerate

添加\keepXColumns到您发布的代码中可以让它编译良好。但是,您的代码包含许多加载两次的包,并且比需要的长。这是一个较短的版本:

\documentclass[a4paper,12pt]{article}

\usepackage[main=british]{babel}
\usepackage{graphicx}
\usepackage[table]{xcolor}
\usepackage[section]{placeins}
\usepackage[left=2.5cm, right=2.5cm, top=3.5cm, bottom=3.5cm]{geometry}
\usepackage{titleps,microtype,setspace,amsmath,SIunits,tabularx}
\usepackage{mathptmx}
\usepackage{booktabs,caption,makecell,ltablex}
\usepackage{pdflscape,afterpage}
\onehalfspacing

\renewcommand\theadfont{\small\bfseries}
\renewcommand\tabularxcolumn[1]{m{#1}}
\usepackage[usestackEOL]{stackengine}

\usepackage{enumitem}
\usepackage{etoolbox}
\AtBeginEnvironment{table}{%
    \setlist[enumerate]{nosep,
        topsep     = 0pt,
        partopsep  = 0pt,
        leftmargin = *,
        before     = \vspace{-0.6\baselineskip},
        after      = \vspace{-\baselineskip}
}}

\keepXColumns

\begin{document}

\begin{table}[ht]
  \caption{Cognitive walkthrough goals, tasks and actions}
  \label{table:comparison of techniques}
  \small
  \begin{tabularx}{\linewidth}{@{}
    X
    >{\centering\arraybackslash}X  % content of `X` column is now centered
    X
    @{}}
    \toprule
    \thead{\textbf{Goal}}& \thead{\textbf{Task}} & \thead{\textbf{Action}} \\
    \midrule
    Evaluate the ease in which users can join projects
    &   Access and account set up
    &   \begin{enumerate}
    \item   Teast A: Video provides a powerful way to help you prove your point.

      Test B: Video provides a powerful way to help you prove your point.
    \item Video provides a powerful way to help you prove your point.
    \end{enumerate}     \\
    \addlinespace
    Evaluate the ease in learning to map
    &   Learning how to map
    &   Read tutorial   \\
    \addlinespace
    Contribute data
    &   Contributing data by classifying maps
    &   \begin{enumerate}
    \item Video provides a powerful way to help you prove your point.
    \item Test A: Video provides a powerful way to help you prove your point.

      Test B: Video provides a powerful way to help you prove your point.
    \item Video provides a powerful way to help you prove your point.
    \end{enumerate}     \\
    \addlinespace
    Evaluate if the user likes using the application and whether they like using it
    & -- & --                   \\
    \bottomrule
  \end{tabularx}
\end{table}

\begin{landscape}% Landscape page
  \small
  \setlength\extrarowheight{2pt}
  \begin{tabularx}{\linewidth}{
    >{\columncolor{red!30}} l
    *{3}{X}X@{}
    }\caption{}
    % \label{table:comparison of techniques}
    \\
    \Xhline{1pt}
    \multicolumn{1}{c}{\cellcolor{red!30}}
    &\bfseries{Is the effect of the current action the same as the
    user's goals?}{\cellcolor{red!30}} &\bfseries{Is the action
    visible?}{\cellcolor{red!30}}
    & \bfseries{Will the user recognise the action as the right
    one?}{\cellcolor{red!30}}
    &\multicolumn{1}{>{\columncolor{red!30}[6pt][0pt]\bfseries}c@{}}{\Centerstack{Will
    the user understand \\ the feedback?}} \\
    \Xhline{0.25pt}
    \endfirsthead
    \Xhline{1pt}
    % \rowcolor{red!30}
    \multicolumn{1}{c}{\cellcolor{red!30}}
    &\bfseries{Is the effect of the current action the same as the
    user's goals?} &\bfseries{Is the action visible?}
    & \bfseries{Will the user recognise the action as the right one?}
    &\multicolumn{1}{>{\bfseries}c@{}}{\Centerstack{Will the user
    understand \\ the feedback?}} \\
    \Xhline{0.25pt}
    \endhead
    \Xhline{0.25pt}
    \endfoot
    \Xhline{1pt}
    \endlastfoot
    \rowcolor{black}
    \multicolumn{5}{l}{\textcolor{white}{\bfseries Task 1 - access and
    account set up}} \\
    Heading
    & TEXT.
    & TEXT.
    & TEXT.
    & TEXT. \\
    \Xhline{0.25pt}
    Heading
    & TEXT.
    & TEXT.
    & TEXT.
    & TEXT. \\
    \rowcolor{black}
    \multicolumn{5}{l}{\textcolor{white}{\bfseries Task 2 - learning how to map}} \\*
    Heading
    & TEXT.
    & TEXT.
    & TEXT.
    & TEXT. \\
    \rowcolor{black}
    \multicolumn{5}{l}{\textcolor{white}{\bfseries Task 3 -
    contributing data by classifying maps}} \\
    Heading
    & TEXT.
    & TEXT.
    & TEXT.
    & TEXT. \\
    \Xhline{0.25pt}
    Heading
    & TEXT.
    & TEXT.
    & TEXT.
    & TEXT. \\
    \Xhline{0.25pt}
    Heading
    & TEXT.
    & TEXT.
    & TEXT.
    & TEXT. \\
  \end{tabularx}
\end{landscape}

\end{document}
  • color软件包被移除,已经被覆盖xcolor
  • epstopdfgraphicx无论如何,如果必要的话,软件包将被删除、加载
  • [main=british]规范而不是仅仅[british]为了babel
  • geometry仅加载booktabs一次captionmakecellpdflscapeafterpage

您应该考虑使用newtxtextnewtxmath而不是mathptmx包;它们提供更好的字形选择,在数学上具有更好的间距并且更贴合文本字体,并提供更多的灵活性。

相关内容