# 2 tables in document - error message 'Something's wrong--perhaps a missing \item. \end{tabularx}'

I have two tables in my document but when I compile I get the error message

Something's wrong--perhaps a missing \item. \end{tabularx}

When compiling the document with only one table there is no problem. When compiling document with both tables there is an error message but I can see both tables.

It looks like enumerate can cause problems. I have tried to follow suggestions from TEX link but with no success.

Can someone suggest a way to resolve the error please?

MWE:

\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\tabularxcolumn[1]{m{#1}}
\usepackage[usestackEOL]{stackengine}

\usepackage[table]{xcolor}

\usepackage{pdflscape,afterpage}

\AtBeginEnvironment{table}{%
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
\midrule
Evaluate the ease in which users can join projects
&   Access and account set up
&   \begin{enumerate}

\end{enumerate}     \\
Evaluate the ease in learning to map
&   Learning how to map
Contribute data
&   Contributing data by classifying maps
&   \begin{enumerate}

\end{enumerate}     \\
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}
\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}
\Xhline{0.25pt}
\endfoot
\Xhline{1pt}
\endlastfoot
\rowcolor{black}
\multicolumn{5}{l}{\textcolor{white}{\bfseries Task 1 - access and account set up}} \\
& TEXT.
& TEXT.
& TEXT.
& TEXT. \\
\Xhline{0.25pt}
& TEXT.
& TEXT.
& TEXT.
& TEXT. \\
\rowcolor{black}
\multicolumn{5}{l}{\textcolor{white}{\bfseries Task 2 - learning how to map}} \\*
& TEXT.
& TEXT.
& TEXT.
& TEXT. \\
\rowcolor{black}
\multicolumn{5}{l}{\textcolor{white}{\bfseries Task 3 - contributing data by classifying maps}} \\
& TEXT.
& TEXT.
& TEXT.
& TEXT. \\
\Xhline{0.25pt}
& TEXT.
& TEXT.
& TEXT.
& TEXT. \\
\Xhline{0.25pt}
& TEXT.
& TEXT.
& TEXT.
& TEXT. \\
\end{tabularx}%
\end{landscape}
\end{document}


• See tex.stackexchange.com/q/11541/15925 . You can not (easily) put an enumerate in a variable width column Apr 19, 2018 at 16:01
• @andrew: Thanks for the link. I tried the suggestions but no success. I may have been changing the wrong part of the code though. Are you able to advise, from my code, which section I should change please? Apr 20, 2018 at 17:05

It turns out my original diagnosis, blaming the X column for not being to take an enumerate was not correct. The problem is the ltablex package, and the solution is to issue its directive \keepXColumns. The following document is minimal demonstrating the problem; without the \keepXColumns macro, it produces the missing \item error that you report, with the macro, it compiles fine.

\documentclass{article}

\usepackage{ltablex}
\keepXColumns

\begin{document}

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

\end{document}


Without \keepXColumns, the package ltablex tries to convert X columns to l columns if there is enough space. This involves the package running some trial code, and that code does not fit well with an enumerate environment in the cell.

Adding \keepXColumns to your posted coded lets it compile fine. However, your code contains many packages loaded twice and is longer than needed. Here is a shorter version:

\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\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
\midrule
Evaluate the ease in which users can join projects
&   Access and account set up
&   \begin{enumerate}

\end{enumerate}     \\
Evaluate the ease in learning to map
&   Learning how to map
Contribute data
&   Contributing data by classifying maps
&   \begin{enumerate}

\end{enumerate}     \\
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}
\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}
\Xhline{0.25pt}
\endfoot
\Xhline{1pt}
\endlastfoot
\rowcolor{black}
\multicolumn{5}{l}{\textcolor{white}{\bfseries Task 1 - access and
account set up}} \\
& TEXT.
& TEXT.
& TEXT.
& TEXT. \\
\Xhline{0.25pt}
& TEXT.
& TEXT.
& TEXT.
& TEXT. \\
\rowcolor{black}
\multicolumn{5}{l}{\textcolor{white}{\bfseries Task 2 - learning how to map}} \\*
& TEXT.
& TEXT.
& TEXT.
& TEXT. \\
\rowcolor{black}
contributing data by classifying maps}} \\
& TEXT.
& TEXT.
& TEXT.
& TEXT. \\
\Xhline{0.25pt}
& TEXT.
& TEXT.
& TEXT.
& TEXT. \\
\Xhline{0.25pt}
& TEXT.
& TEXT.
& TEXT.
& TEXT. \\
\end{tabularx}
\end{landscape}

\end{document}

• color package removed, already covered by xcolor
• epstopdf package removed, loaded by graphicx if necessary anyway
• [main=british] specification rather than juts [british] for babel
• load geometry, booktabs, caption, makecell, pdflscape, afterpage only once

You should look at using newtxtext and newtxmath instead of mathptmx package; they offer better choices of glyphs with better spacing in mathematics and closer fit to the text fonts, and provide some more flexibility.

• Thanks! The code works perfectly and thanks for the additional advice! Apr 21, 2018 at 15:18
• Perfect, thank you very much! Nov 19, 2021 at 23:07