# tabularx affecting table numbering

I have just found that using tabularx disrupts normal numbering of tables (please see picture). According to Tex link this can be due to the \caption command being outside of the tabularx environment. However, when I rectify this, I get error messages on compilation.

MWE:

\documentclass[a4paper,12pt]{article}
\usepackage{graphicx}
\usepackage[main=british]{babel}
%\usepackage{gensymb}
\usepackage[section]{placeins}%Allows you to permanently fix figures.
\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{mathptmx}
%\usepackage{newtxmath}
\usepackage{titleps,microtype,setspace,amsmath,SIunits,tabularx}
\usepackage{booktabs,caption, makecell,ltablex}
\usepackage{pdflscape,afterpage}
\usepackage[backend=bibtex, citestyle=ieee, bibstyle=ieee]{biblatex}
\onehalfspacing

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

\usepackage[table]{xcolor}

\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
&   Task 1:  Access and account set up
&   \begin{enumerate}
\item   Text.

Text.
\item Join the project.
\end{enumerate}     \\
Evaluate the ease in learning to map
&   Task 2:  Learning how to map
Contribute data
&   Task 3: Contributing data by classifying maps
&   \begin{enumerate}
\item Begin mapping.
\item Text.
Text.
\item Review maps classified.
\end{enumerate}     \\
Evaluate if the user likes using the application and whether they like using it
& -- & --                   \\
\bottomrule
\vspace{-18mm}%needed otherwise the table gets lost between pagebreaks.
\end{tabularx}
\end{table}

\begin{table}[ht]
\caption{Cognitive walkthrough - evaluation questions}
\setlength\tabcolsep{3pt}
\centering
\small
\hspace*{-18mm}%
\begin{tabular}{ p{30mm} p{80mm} }
\toprule
Question & Description \\ [0.5ex]
\midrule
1 & Is the effect of the current action the same as the user's goals \\
2 & Is the action visible? \\
3 & Will the user recognise the action as the right one? \\
4 & Will the user understand the feedback? \\
\bottomrule
\end{tabular}%
\hspace*{-12mm}%
\end{table}

\end{document}

Picture - wrong numbering of tables

• ltablex enables the longtable feature for tabularx, so ultimately tabularx is now a longtable. Move \caption inside \begin{tabularx} and put a \endfirsthead after that, also remove the table environment` for this – user31729 Apr 23 '18 at 18:12
• note that it is not tabularx that does this, if you load the tabularx package rather than ltablex then you get the correct numbering. ltablex has rather a lot of features like this unfortunately. – David Carlisle Apr 23 '18 at 19:15
• Thanks @ChristianHupfer and @David. Your advice works perfectly. One follow up query - by removing the table environment, I lose the original text spacing, which makes my table much bigger. How do I preserve the formatting and solve the table numbering issue at the same time? – Kevin Apr 23 '18 at 20:18

This is a feature of ltablex which turns tabularx into longtable even if a longtable makes no sense in that context, such as inside a table environment.

For the example posted you could simply use

\usepackage{tabularx}