如何在向 table 单元格添加换行符时连接垂直线

How to join the vertical lines while adding newline to table cells

我的代码如下:

\begin{table*}[!htbp]
\centering
\begin{tabular}{ |c|c|c|c|c|c|c| } 
 \hline
 Models &  Architecture & Val & Test Acc (FF)  & Test Acc (BD) & Test Acc\ \hline 
 VisualBert  & Single Cross-Modal Transformer & 51.0\% & 50.8\% &  51.1\% & 50.5\% \\ \hline
 VilBert & One Single Modal Transformer \ & (Language) \ & + one cross-modal transformer \ & (with restricted attention pattern) & 51.2\% & 50.9\% & 51.2\% &  52.6\% \\ \hline
 LXMERT & Two Single Modal Transformer \ & (Vision and Language) \ & + one cross-modal transformer \ & (with restricted attention pattern) & 53.8\% & 52.2\%  & 51.0\%& 52.9\% \\ \hline
 Unicoder-VL & Single Cross-Modal Transformer & 53.8\% & 52.2\%  & 51.0\%& 52.9\% \\ \hline
 CLIP & Base Model: ResNet50 + \ & masked self-attention transformer \ & or \ & ViT + text transformer & 53.8\% & 52.2\%  & 51.0\%& 52.9\% \\ \hline
 SLIP & ViT/B-16 and L-16 + \ & text transformer from CLIP & 53.8\% & 52.2\%  & 51.0\%& 52.9\% \\\hline
\end{tabular}
\caption{Model performance on Bongard LOGO on a reduced resolution. The test accuracy is reported on different dataset splits, including free-form shape test set (FF), basic shape test set (BA), combinatorial abstract shape test set (CM), and novel abstract shape test set (NV)}
\label{tab:baseline}
\end{table*}

但这是我的输出:

如何完成垂直线并将第一列文本打印为底部对齐? 请帮忙!谢谢!

前言:

不要在 table 中使用垂直线。

(查看 https://wiert.files.wordpress.com/2014/04/zy8dkpa.gif 以获得专业外观的一些提示 tables)


\ 不会在您的单元格中添加换行符,它会在您的 table 中添加全新的行,您必须确保 table 的每一行都有相同数量的细胞。不要过早地用 \ 结束该行,而是在必要时添加空单元格:

\documentclass{article}

\begin{document}

\begin{table*}[!htbp]
\centering
\begin{tabular}{ |c|c|c|c|c|c|c| } 
 \hline
 Models &  Architecture & Val & Test Acc (FF)  & Test Acc (BD) & Test Acc\\hline 
 VisualBert  & Single Cross-Modal Transformer & 51.0\% & 50.8\% &  51.1\% & 50.5\% \ \hline
  & One Single Modal Transformer &&&& \ & (Language) &&&& \ & + one cross-modal transformer &&&& \ VilBert & (with restricted attention pattern) & 51.2\% & 50.9\% & 51.2\% &  52.6\%  \ \hline
\end{tabular}
\caption{Model performance on Bongard LOGO on a reduced resolution. The test accuracy is reported on different dataset splits, including free-form shape test set (FF), basic shape test set (BA), combinatorial abstract shape test set (CM), and novel abstract shape test set (NV)}
\label{tab:baseline}
\end{table*}

\end{document}

话虽这么说,手动添加换行符似乎不必要地乏味。我建议让乳胶为你换行。使用 tabularray 包特别容易:

\documentclass{article}

\usepackage{tabularray}

\usepackage[hmargin=2cm]{geometry}

\begin{document}

\begin{table*}[!htbp]
\centering
\begin{tblr}{ |c|X[valign=b,halign=c]|c|c|c|c|c| } 
 \hline
 Models &  Architecture & Val & Test Acc (FF)  & Test Acc (BD) & Test Acc\\hline 
 VisualBert  & Single Cross-Modal Transformer & 51.0\% & 50.8\% &  51.1\% & 50.5\% \ \hline
 VilBert & One Single Modal Transformer (Language) + one cross-modal transformer (with restricted attention pattern) & 51.2\% & 50.9\% & 51.2\% &  52.6\%  \ \hline
\end{tblr}
\caption{Model performance on Bongard LOGO on a reduced resolution. The test accuracy is reported on different dataset splits, including free-form shape test set (FF), basic shape test set (BA), combinatorial abstract shape test set (CM), and novel abstract shape test set (NV)}
\label{tab:baseline}
\end{table*}

\end{document}