Reputation: 383
I'm new to LaTex and I'm trying to create a table with items, but I'm having issues with closing the table borders. When I add "|" to the {tabularx}, I get a new column that I don't want. I tried to follow different LaTex examples, but I'm stuck on how to close my table: My code is
\documentclass{article}
\usepackage{tabularx}
\usepackage{paralist}
\makeatother
\begin{document}
\begin{table}[!b]
\centering
\caption{ Comparison between ST-Kriging, Bayesian inference, and ANNs.}
\label{tab:2}
\renewcommand{\arraystretch}{1.5}
\scriptsize
\begin{tabularx}{\textwidth} {|p{2.3cm}|p{3.5cm}|p{3.5cm}|p{3.5cm}}
\hline
\textbf{} & \textbf{Bayesian Inferences} & \textbf{ST-Kriging} & \textbf{ANNs} \\ \hline
\textbf{Computational Complexity} & NP-hard \cite{ref-satria2020spatial} & $O(N^2)$ & $O(i\times o\times n + n\times o)$ or $O(n \times o \times (i+1))$ for training a single epoch. \cite{ref-taylor1995freeway} \\ \hline
\textbf{Performance Evaluation } & Provides a posterior probability distribution with confidence interval. &
Ensure linear unbiased predictors. & Epoch with the lowest sum of squared error.\\ \hline
\textbf{Weaknesses} & Very computationally intensive due to choosing the proper prior distribution.
&
\begin{compactitem}
\item Missing value causes error in unmatched dimensions.
\item Can not handle large datasets.
\item Require normal distribution.
\end{compactitem}
&
Require intensive data training, and this might lead to an overfitting problem. \\ \hline
\textbf{Strengths }
&
\begin{compactitem}
\item Handle large and small data.
\item Handle missing values.
\item Prior knowledge about uncertain input is not required.
\end{compactitem}
&
\begin{itemize}
\item Handle small data.
\item Computational efficiency.
\end{itemize}
&
\begin{compactitem}
\item Handle big data and small data.
\item Accommodate missing values without a separate estimation step [108]
\item Computational efficiency due to the parallelity feature.
\item Prior knowledge about uncertain input is not required.
\end{compactitem}
\\ \hline
\textbf{Overcoming the Limitation}
&
Use uninformative prior to reduce the computational time, however, it can affect the prediction accuracy negatively.
&
Remove observations that include missing values.
&
\begin{compactitem}
\item Decrease the number of layers of the network.
\item Use iterative methods to stop the training process such as gradient descent.
\end{compactitem}
\\ \hline
\end{tabularx}
\end{table}
\end{document}
The table will look like this:
I believe that the issue is with this line, but I can't find a way to fix it:
\begin{tabularx}{\textwidth} {|p{2.3cm}|p{3.5cm}|p{3.5cm}|p{3.5cm}}
If I add "|" it will create another column instead of closing the table. Any thoughts on what could be the issue? I used "tabular" here instead of "tabularx" and I had no issue, but because I wanted to reduce the space between the list indented text, therefore I had to switch to "tabularx".
Upvotes: 2
Views: 3125
Reputation: 2617
If you use tabularx
one of the column should be X
which adapts its width to a remaining available width.
Your table is quite wordy and due to number of columns there doesn't seem to be enough space for long texts. You could consider rotating a table and use a pageheight as an available space for a width of the table.
While correcting your table, I have also made a few adjustments:
booktabs
\documentclass{article}
\usepackage{tabularx}
\usepackage{calc}
\usepackage{paralist}
%% Added packages
\usepackage{booktabs} % For improved rules
\usepackage{caption} % For extra space between table and caption
\usepackage{rotating} % For sidewaystable
\usepackage{ragged2e} % Improves typesetting in
\usepackage{microtype} % in narrow environments
\usepackage{geometry}
\captionsetup[table]{position=top,skip=3pt,font=normalsize}
%% END Added packages
\setdefaultleftmargin{0em}{}{}{}{}{}
\begin{document}
\newgeometry{top=1in,bottom=1in}
\begin{sidewaystable}
\RaggedLeft
\setlength\tabcolsep{4pt}
\newcommand\xstrut[1][1]{%
\rule[-0.35\normalbaselineskip*\real{#1}]{0pt}{#1\normalbaselineskip}}
\newcommand\xthead[1]{\normalsize\textbf{#1}}
\renewcommand{\arraystretch}{1.25}
\centering
\caption{Comparison between ST-Kriging, Bayesian inference, and ANNs.}
\label{tab:2}
\footnotesize
\begin{tabularx}{0.9\textwidth} {p{3cm}XXX}
\specialrule{\heavyrulewidth}{0pt}{0pt}
\xstrut[2.2]
& \xthead{Bayesian Inferences}
& \xthead{ST-Kriging}
& \xthead{ANNs} \\
\midrule[\heavyrulewidth]
\textbf{Computational Complexity}
& NP-hard \cite{ref-satria2020spatial}
& $O(N^2)$
& $O(i\times o\times n + n\times o)$ or $O(n \times o \times (i+1))$\newline for training a single epoch. \cite{ref-taylor1995freeway} \\
\midrule
\textbf{Performance Evaluation}
& Provides a posterior probability distribution with confidence interval.
& Ensure linear unbiased predictors.
& Epoch with the lowest sum of squared error. \\
\midrule
\textbf{Weaknesses}
& Very computationally intensive due to choosing the proper prior distribution.
& \begin{compactitem}
\item Missing value causes error in unmatched dimensions.
\item Can not handle large datasets.
\item Require normal distribution.
\end{compactitem}
& Require intensive data training, and this might lead to an overfitting problem. \\
\midrule
\textbf{Strengths }
&
\begin{compactitem}
\item Handle large and small data.
\item Handle missing values.
\item Prior knowledge about uncertain input is not required.
\end{compactitem}
&
\begin{itemize}
\item Handle small data.
\item Computational efficiency.
\end{itemize}
&
\begin{compactitem}
\item Handle big data and small data.
\item Accommodate missing values without a separate estimation step [108]
\item Computational efficiency due to the parallelity feature.
\item Prior knowledge about uncertain input is not required.
\end{compactitem} \\
\midrule
\textbf{Overcoming the Limitation}
&
Use uninformative prior to reduce the computational time, however, it can affect the prediction accuracy negatively.
&
Remove observations that include missing values.
&
\begin{compactitem}
\item Decrease the number of layers of the network.
\item Use iterative methods to stop the training process such as gradient descent.
\end{compactitem} \\
\bottomrule
\end{tabularx}
\end{sidewaystable}
\restoregeometry
\end{document}
Upvotes: 0
Reputation: 38977
The problem is that when one sums up all your manually defined columns widths, they are larger than the available \textwidth
. As you are using a tabularx
environment, you could instead use X
columns and latex will automatically calculate a suitable width:
\documentclass{article}
\usepackage{tabularx}
\usepackage{paralist}
\makeatother
\begin{document}
\begin{table}[!b]
\centering
\caption{ Comparison between ST-Kriging, Bayesian inference, and ANNs.}
\label{tab:2}
\renewcommand{\arraystretch}{1.5}
\scriptsize
\begin{tabularx}{\textwidth}{|X|X|X|X|}
\hline
\textbf{} & \textbf{Bayesian Inferences} & \textbf{ST-Kriging} & \textbf{ANNs} \\ \hline
\textbf{Computational Complexity} & NP-hard \cite{ref-satria2020spatial} & $O(N^2)$ & $O(i\times o\times n + n\times o)$ or $O(n \times o \times (i+1))$ for training a single epoch. \cite{ref-taylor1995freeway} \\ \hline
\textbf{Performance Evaluation } & Provides a posterior probability distribution with confidence interval. &
Ensure linear unbiased predictors. & Epoch with the lowest sum of squared error.\\ \hline
\textbf{Weaknesses} & Very computationally intensive due to choosing the proper prior distribution.
&
\begin{compactitem}
\item Missing value causes error in unmatched dimensions.
\item Can not handle large datasets.
\item Require normal distribution.
\end{compactitem}
&
Require intensive data training, and this might lead to an overfitting problem. \\ \hline
\textbf{Strengths }
&
\begin{compactitem}
\item Handle large and small data.
\item Handle missing values.
\item Prior knowledge about uncertain input is not required.
\end{compactitem}
&
\begin{itemize}
\item Handle small data.
\item Computational efficiency.
\end{itemize}
&
\begin{compactitem}
\item Handle big data and small data.
\item Accommodate missing values without a separate estimation step [108]
\item Computational efficiency due to the parallelity feature.
\item Prior knowledge about uncertain input is not required.
\end{compactitem}
\\ \hline
\textbf{Overcoming the Limitation}
&
Use uninformative prior to reduce the computational time, however, it can affect the prediction accuracy negatively.
&
Remove observations that include missing values.
&
\begin{compactitem}
\item Decrease the number of layers of the network.
\item Use iterative methods to stop the training process such as gradient descent.
\end{compactitem}
\\ \hline
\end{tabularx}
\end{table}
\end{document}
Upvotes: 2