我想在表格中添加一条垂直线,这是我的代码。这是一篇使用模板的论文,可以看到 这里带有完整源代码。在我的 latex 实现中
\documentclass[twoside,mtp]{iiitg}
\usepackage{makecell,tabularx} % for 'tabularx' env. and 'X' col. type
\renewcommand\theadfont{\normalsize}
\begin{table}[ht]
\centering
\begin{tabularx}{\textwidth}{|@{} X | @{}X | @{}X |}
\hline
\thead{Algorithm} & \thead{Pros} & \thead{Cons} \\ \hline
\multirow{2}{*}{1. K Nearest Neighbour: K-NN } & Very easy to understand
Good for creating models that include non standard data types such as
text & Large Storage requirements
Computationally Expensive
Sensitive to the choice of the similarity function for comparing instances \\ \hline
Local Outlier Factor(LOF) & 3 & 5 \\ \hline
1 & 3 & 5 \\ \hline
\end{tabularx}
\caption{Anomaly Detection Algorithms comparison}
\label{tab:my_label}
\end{table}
答案1
您可以使用方括号中的选项来获得所需的间距等结果
[label={}, wide = 0pt, leftmargin = *, nosep, itemsep = 0pt, before = \vspace*{\baselineskip}, after =\vspace*{\baselineskip} ]
\documentclass{article}
\usepackage{multirow}
\usepackage[shortlabels]{enumitem}
\usepackage{makecell,tabularx} % for 'tabularx' env. and 'X' col. type
\renewcommand\theadfont{\normalsize}
\begin{document}
\begin{table}[ht]
\centering
\begin{tabularx}{\textwidth}{|X |X | X |}
\hline
\thead{Algorithm} & \thead{Pros} & \thead{Cons} \\ \hline
\begin{enumerate}[label={}, wide = 0pt, leftmargin = *, nosep, itemsep = 0pt, before = \vspace*{\baselineskip}, after =\vspace*{\baselineskip} ]
\item K Nearest Neighbour
\item K-NN
\end{enumerate} &
\begin{enumerate}
\item Very easy to understand
\item Good for creating models that include non standard data types such as
text
\end{enumerate} &
\begin{enumerate}
\item Large Storage requirements
\item Computationally Expensive
\item Sensitive to the choice of the similarity function for comparing instances
\end{enumerate} \\ \hline
\end{tabularx}
\caption{Anomaly Detection Algorithms comparison}
\label{tab:my_label}
\end{table}
\end{document}