避免 tabularx 中的粗規則

避免 tabularx 中的粗規則

這是我的桌子:

\documentclass{article}
\usepackage{tabularx}
\begin{document}


\noindent
\begin{tabularx}{\linewidth}{@{}|p{3.5cm}|X|X|}
some text & \multicolumn{2}{|c|}{some text} \\
\end{tabularx}

\end{document}

呈現為

有粗線的桌子

有沒有辦法在不刪除其中一個管道符號的情況下擺脫中間較粗的規則|在表格序言中或多列命令中?

答案1

我將提供一個替代解決方案,tblr其環境為tabularray包裹。首先,它會建立一個跨越兩個欄位的正確多列儲存格X。其次,透過使用\SetCell命令,我們不需要擔心單元格邊界。

\documentclass{article}
\usepackage{tabularray}
\begin{document}

\noindent
\begin{tblr}{@{}|t{3.5cm}|X|X|}
some text & \SetCell[c=2]{c} some text & \\
\end{tblr}

\end{document}

在此輸入影像描述

答案2

{NiceTabular}這是of 的替代方案nicematrix。在該環境中,該命令\Block垂直和水平合併單元格,且規則(例如|在序言中指定)是不是繪製在塊中。

\documentclass{article}
\usepackage{nicematrix}
\begin{document}

\noindent
\begin{NiceTabular}{|p{3.5cm}|X|X|}
some text & \Block{1-2}{some text} & \\
\end{NiceTabular}

\end{document}

您需要多次編譯(因為nicematrix在背景使用 PGF/Tikz 節點)。

上述程式碼的輸出

相關內容