我想将最后一行的列合并为一列。怎么做?当我有长句子时,即使我使用 \newline,它也不会转到下一行。有人能帮我添加一行这样的行吗...
\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}
答案1
- 对于最后两行,您需要形成多列单元格。在“经典”表中,使用 @cabohah 答案中的建议,或按照下面的建议使用
tabullaray
包语法(参见下面的两个 MWE) - 不清楚最后两行的内容应该是什么。
- 请编辑您的问题并澄清这一点。
因此,以下 MWE 大多与主题无关,建议如何简化表格代码并使表格更美观。在这种情况下,对于您的表格,我将使用:
tabularray
包而不是tabularx
for 表(它启用简单的插入语法并制作美观的列表)enumitem
包而不是paralist
表格中更好的格式列表
\documentclass{article}
%---------------- show page layout. don't use in a real document!
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%
%\usepackage{newtxtext, newtxmath} % ?
%\usepackage{microtype} % ?
\usepackage{enumitem}
\usepackage{ragged2e}
\usepackage{tabularray}
\UseTblrLibrary{varwidth}
\begin{document}
\begin{table}[htp]
\centering
\caption{ Comparison between ST-Kriging, Bayesian inference, and ANNs.}
\label{tab:2}
\setlist[itemize]{nosep, leftmargin=*}
\footnotesize
\begin{tblr}{hlines, vlines,
colsep = 4pt,
colspec = {Q[l, font=\bfseries] *{3}{X[cmd=\RaggedRight]}},
measure = vbox,
row{1} = {font=\bfseries, m, cmd=\Centering},
rowsep = 5pt,
stretch = -1,
hspan=minimal,
cell{Y,Z}{1} = {c=4}{font=\normalfont} % define multi column cells in the last two rows
}
& {Bayesian\\ Inferences}
& ST-Kriging
& ANNs \\
%
{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}
\\
{Performance\\ Evaluation}
& Provides a posterior probability distribution with confidence interval.
& Ensure linear unbiased predictors.
& Epoch with the lowest sum of squared error.
\\
Weaknesses
& Very computationally intensive due to choosing the proper prior distribution.
& \begin{itemize}
\item Missing value causes error in unmatched dimensions.
\item Can not handle large datasets.
\item Require normal distribution.
\end{itemize}
& Require intensive data training, and this might lead to an overfitting problem.
\\
Strengths
& \begin{itemize}
\item Handle large and small data.
\item Handle missing values.
\item Prior knowledge about uncertain input is not required.
\end{itemize}
& \begin{itemize}
\item Handle small data.
\item Computational efficiency.
\end{itemize}
& \begin{itemize}
\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{itemize}
\\
{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{itemize}
\item Decrease the number of layers of the network.
\item Use iterative methods to stop the training process such as gradient descent.
\end{itemize}
\\
Penultimate table row has merged cells of all columns. It is unclear what is contents of this row.
& & & \\
Last row has merged cells. It is unclear what is contents of this row.
& & & \\
\end{tblr}
\end{table}
\end{document}
(红线表示页面布局。您可以考虑使用该geometry
包来更改它)
附录:
如果要使表格看起来更专业,我会删除大部分表格规则。对于使用,我会使用包中定义的规则booktabs
(由库加载booktabs
):
\documentclass{article}
%---------------- show page layout. don't use in a real document!
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%
\usepackage{lipsum}% For dummy text. Don't use in a real document
\renewcommand{\textfraction}{0.07} % allow minimal text w. figs
%\usepackage{newtxtext, newtxmath} % ?
\usepackage{microtype} % used for better inter words spacing
\usepackage{enumitem}
\usepackage{ragged2e}
\usepackage{tabularray}
\UseTblrLibrary{booktabs, % load the package of the same name
varwidth}
\begin{document}
\begin{table}[ht]
\centering
\caption{Comparison between ST-Kriging, Bayesian inference, and ANNs.}
\label{tab:2}
\setlist[itemize]{nosep, leftmargin=*}
\footnotesize
\begin{tblr}{colsep = 4pt,
colspec = {@{} Q[l, font=\bfseries] *{3}{X[cmd=\RaggedRight]} @{}},
measure = vbox,
row{1} = {font=\bfseries, m, cmd=\Centering},
row{2-Z}= {rowsep = 5pt},
stretch = -1,
hspan=minimal,
cell{Y,Z}{1} = {c=4}{font=\normalfont}
}
\toprule
& {Bayesian\\ Inferences}
& ST-Kriging
& ANNs \\
\midrule
{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}
\\
{Performance\\ Evaluation}
& Provides a posterior probability distribution with confidence interval.
& Ensure linear unbiased predictors.
& Epoch with the lowest sum of squared error.
\\
Weaknesses
& Very computationally intensive due to choosing the proper prior distribution.
& \begin{itemize}
\item Missing value causes error in unmatched dimensions.
\item Can not handle large datasets.
\item Require normal distribution.
\end{itemize}
& Require intensive data training, and this might lead to an overfitting problem.
\\
Strengths
& \begin{itemize}
\item Handle large and small data.
\item Handle missing values.
\item Prior knowledge about uncertain input is not required.
\end{itemize}
& \begin{itemize}
\item Handle small data.
\item Computational efficiency.
\end{itemize}
& \begin{itemize}
\item Handle big 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{itemize}
\\
{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{itemize}
\item Decrease the number of layers of the network.
\item Use iterative methods to stop the training process such as gradient descent.
\end{itemize}
\\
Penultimate table row contain the cell composed from merged cells from all columns. It is unclear what is contents of this row. Therefore in it is temporary used just dummy text filler:
\lipsum[66]
& & & \\
Last row has merged cells too. The contents of this row is unknown.
& & & \\
\bottomrule
\end{tblr}
\end{table}
\lipsum[66]
\end{document}
答案2
我不确定你期望什么。要合并一行中的四列tabularx
,你可以使用\multicolumn{4}{|p{\dimexpr\hsize-2\tabcolsep-2\arrayrulewidth\relax}|}{…}
,例如
\documentclass{article}
\usepackage{tabularx}
\usepackage{caption}% Because of using \caption above the tabular.
\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
\multicolumn{4}{|p{\dimexpr\hsize-2\tabcolsep-2\arrayrulewidth\relax}|}{%
\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}