刪除 LaTeX longtable 中兩個單元格之間的垂直線

刪除 LaTeX longtable 中兩個單元格之間的垂直線

我在 LaTeX 中使用此程式碼來製作表格:

\begin{center}
\begin{longtable}{|c|p{0.08\linewidth}|p{0.08\linewidth}|}
    \hline
    \multirow{3}{*}{Text O}
    & \multicolumn{2}{c|}{\multirow{2}{*}{Text S}}\\
    &&\\
    \cline{2-3}
    &P&P\\ \hline
    1&2&3\\ \hline
    4&5&6\\ \hline
 \end{longtable}
 \end{center}

在此輸入影像描述

如何擦除第 2 列和第 3 列之間的垂直線(文字 S 儲存格中的垂直線)?

謝謝 :)

答案1

修復格式的一種方法是替換行

&&\\

& \multicolumn{2}{c|}{} \\

即,用 替換第二個&符號\multicolumn{2}{c|}{}


完整的最小工作範例微量元素,它也 (a) 擺脫了不必要的和適得其反的center包裝器,以及 (b) 使用\endhead\endlastfoot指令為longtable材料提供一些結構:

在此輸入影像描述

\documentclass{article} % or some other suitable document class
\usepackage{longtable,multirow}

\begin{document}

\begin{longtable}{ | c | *{2}{p{0.08\linewidth}|} }

% table header
    \hline
    \multirow{3}{*}{Text O}
      & \multicolumn{2}{c|}{\multirow{2}{*}{Text S}} \\
      & \multicolumn{2}{c|}{} \\ \cline{2-3}
      & P & P \\ \hline
    \endhead

    \hline
    \endlastfoot
      
% body of table

    1 & 2 & 3 \\ \hline
    4 & 5 & 6 \\ 

\end{longtable}

\end{document}

相關內容