[Tex/LaTex] tabularx “Missing number, treated as zero” error

tablestabularx

error: ! Missing number, treated as zero.

}
l.16 \begin{tabularx}{\textwidth}
{x x x x}

MWE:

\documentclass[12pt,a4paper,fleqn]{book}
%
\usepackage{subfiles}
\usepackage{thesis_style}

  \title{hfvj}
  \author{fgikf}
  \date{}

   \begin{document}

\begin{table}[h]
\caption{nice and looooooooooooooooong caption}
\begin{center}
\begin{threeparttable}
\begin{tabularx}{\textwidth}{XXXX}
Reference  & hi;& glt;& flfl \\
\citet{TM83}  & rlkul $\delta^ugil$ and $\delta^{13}C$  & Winter season  & -0.5  ($\delta^ugil$)  \\
      &       &       &   0.6 {($\delta^{49}Ca$)}  \\
\citet{BMM94}  & $\delta^ugil$  & January  & -0.44 \\
\citet{BMM94}  & $\delta^ugil$  & vsdewfwgrggbr & 0.44 \\
\citet{TM83} & YRO KJL & rwegfwEFGWER GWEGFLNN FDSLNFLNFL FLNF NFSDNFNF  & 0.44-0.57\tnote{*}  \\
\citet{BMM94} & jo\rq{}h;hk; & mhljk;lyi; & 0.43-0.80\tnote{*}  \\
\end{tabularx}%
\begin{tablenotes}
\item[*]dSGhl;i\rq{}iupf,hjl \\ \item[**] fdhfg
\end{tablenotes}
\end{threeparttable}
\end{center}
\label{precirec-table1}
\end{table}  
  \end{document}

the very complicated custom style file:

\ProvidesPackage{thesis_style}
%
%%% PAGE DIMENSIONS AND SETTINGS
\usepackage{geometry} % to change the page dimensions
\geometry{a4paper} % or letterpaper (US) or a5paper or....
\geometry{top=1.0in, bottom=1.5in, left=1in, right=1in}
%%spacing between lines
\setlength{\parskip}{0.2cm plus1mm minus1mm}%space between paragraphs
\usepackage[nodisplayskipstretch]{setspace}%option for removing space before and after equations
\doublespacing
% Activate to begin paragraphs with an empty line rather than an indent\usepackage[parfill]{parskip} 
%
%%%%
%%%%GRAPHICS, FLOATS, SYMBOLS AND MATHS
% support the \includegraphics command and options
\usepackage{graphicx} 
%\usepackage{booktabs} % for much better looking tables
\usepackage{floatrow}%for side captions
\usepackage[utf8]{inputenc}%for proper characters
% for rotating floats
\usepackage{lscape}
%for subfigures and tables
\usepackage[font=small,labelfont=bf]{caption}
\usepackage[font=footnotesize]{subfig}
\usepackage[para,online,flushleft]{threeparttable}
%for long tables
\usepackage{longtable}
\usepackage{amsmath,amssymb}
%%
%\usepackage[hyphens]{url}%url wrapping
%\PassOptionsToPackage{hyphens}{url}
\usepackage[allcolors=blue,colorlinks=true]{hyperref}%no boxes for links
\usepackage[noabbrev,capitalize]{cleveref}%automatic table /figure before refs
\creflabelformat{equation}{#2\textup{#1}#3}%remove brackets around eq nos
%%%
\usepackage[osf,sc]{mathpazo} %for upright math
\usepackage{eulervm}
\usepackage{gensymb}
\usepackage{wasysym} %for per mil sign
\usepackage{array} % for better arrays (eg matrices) in maths
\usepackage{paralist} % very flexible & customisable lists (eg. enumerate/itemize, etc.)
\usepackage{verbatim} % adds environment for commenting out blocks of text & for better verbatim
\usepackage{subfig} % make it possible to include more than one captioned figure/table in a single float
\usepackage[version=3]{mhchem} % for upright CO2 etc
\usepackage{wrapfig}%text wrapped figures/tables
%%%%%
%%%%%FONT SETTINGS
\usepackage{calligra}%For cursive font
\usepackage[T1]{fontenc}
\usepackage{titlesec, blindtext, color}
\definecolor{brown}{rgb}{0.5, 0.2, 0.0}
\definecolor{cornellred}{rgb}{0.7, 0.11, 0.11}
\definecolor{brown_w}{rgb}{0.65, 0.16, 0.16}
%\titleformat{\chapter}[hang]{\Large\bfseries}{\thechapter\hsp\textcolor{gray75}{|}\hsp}{0pt}{\Large\bfseries}
\titleformat{\chapter}[hang]{\normalfont\Large\bfseries}{\chaptertitlename\ \thechapter:}{1em}{} 
\titlespacing*{\chapter}{0pt}{0pt}{5pt}
\titlespacing*{\section}{0pt}{0pt}{5pt}
%to stop starting new chapter in new page
\usepackage{atbegshi,etoolbox}
%% Get underlining for headings right
\usepackage[normalem]{ulem}
%%% HEADERS & FOOTERS
\usepackage{fancyhdr} % This should be set AFTER setting up the page geometry
\setlength{\headheight}{50pt} 
\pagestyle{fancy} % options: empty , plain , fancy
\fancyhead{}
\renewcommand{\headrulewidth}{1pt} % customise the layout...
\renewcommand{\footrulewidth}{1pt}
\lhead{\slshape\nouppercase{\leftmark}}\chead{}\rhead{}
\lfoot{}\cfoot{}\rfoot{\thepage}
%
\def\bibfont{\footnotesize} %to decrease font size of the bibliography
%%%
%%% ToC (table of contents) APPEARANCE
\usepackage[nottoc,notlof,notlot]{tocbibind} % Put the bibliography in the ToC
%%%%
\setcounter{tocdepth}{4}
\renewcommand{\bibname}{References}
%%%%%%%
%
\usepackage[colon,authoryear]{natbib}
%
%mytilde
\newcommand{\mytilde}{\raise.17ex\hbox{$\scriptstyle\mathtt{\sim}$}} %around tilde

Best Answer

I've managed to make the code compilable but there are still some things that could be improved.

\documentclass{book}

\usepackage{tabularx}
\usepackage{booktabs}
\usepackage{thesis_style}

\newcommand*\something{$\delta^{u}gil$}


\begin{document}

Text before the table.

\begin{table}[h]
\centering
\begin{threeparttable}
\begin{tabularx}{\textwidth}{XXXX}
\toprule
Reference & some text                           & some text     & some text                     \\
TM83      & \something\ and $\delta\ce{^{13}C}$ & Winter season & $-0.5$ (\something)           \\
          &                                     &               & $ 0.6$ ($\delta\ce{^{49}Ca}$) \\
BMM94     & \something                          & January       & $-0.44$                       \\
BMM94     & \something                          & some text     & $ 0.44$                       \\
TM83      & some text                           & some text     & $ 0.44$--$0.57$\tnote{*}      \\
BMM94     & some text                           & some text     & $ 0.43$--$0.80$\tnote{**}     \\
\bottomrule
\end{tabularx}
\begin{tablenotes}
\item[*]  some text \\
\item[**] some text
\end{tablenotes}
\end{threeparttable}
\end{table}

Text after the table.

\end{document}

output