表格中的垂直线不匹配

表格中的垂直线不匹配

我想用垂直线排版下表,但有些线不匹配。

\documentclass{article}
\usepackage{multirow}
\usepackage{changepage}
\usepackage{array}
\usepackage{romannum}
\usepackage{rotating}
\usepackage{calc}
\usepackage{amsmath}
\usepackage{makecell}
\usepackage{nicematrix}
\usepackage{tabu}
\newcolumntype{P}[1]{>{\centering\arraybackslash}p{#1}}
\newcolumntype{M}[1]{>{\centering\arraybackslash}m{#1}}

\begin{document}
%\begin{table}[h!]
\begin{sidewaystable}[h!]
%\begin{adjustwidth}{-4.5cm}{}
    
\begin{tabular}{|c|c|c|c|c|c|c|}
     
\hline
\multicolumn{7}{|l|}{My name is Tam Sam Insti}\\
\multicolumn{7}{|l|}{}
\\
\hline
\multicolumn{4}{|l|}{} & \multicolumn{2}{l|}{\multirow{2}{4cm}{}} &\\
\multicolumn{4}{|l|}{aarival} & \multicolumn{2}{l|}{\multirow{2}{4cm}{Departure}} &  \\ \cline{1-4}
\multicolumn{4}{|l|}{} & \multicolumn{2}{l|}{\multirow{2}{4cm}{}} & \\




\multicolumn{2}{|l}{Train Number} & \multicolumn{2}{|l|}{Station }&&&  \\ \cline{1-6}
\multicolumn{2}{|l|}{} & \multicolumn{2}{l|}{} &&&\\ 


&&&&&& \multirow{2}{4.1cm}{}\\
9.00 & 10.00 & 11.00 &12.00&13.00&14.00& \multirow{2}{4.1cm}{9.00} \\
&&&&&&\\
&&&&&& \multirow{2}{4.1cm}{}\\
\hline
&&&&&&\\

papri& nain & good & mrth & monday & tuesday & saturday \\
&&&&&&\\
\hline
 \end{tabular}
  
%\end{adjustwidth}
%\end{table}
\end{sidewaystable}
\end{document}

在此处输入图片描述

答案1

您想要以不同方式对齐的“列车号”和“车站”之间的线是否是?

在此处输入图片描述

\documentclass{article}
\usepackage{multirow}
\usepackage{changepage}
\usepackage{array}
\usepackage{romannum}
\usepackage{rotating}
\usepackage{calc}
\usepackage{amsmath}
\usepackage{makecell}
\usepackage{nicematrix}
\usepackage{tabu}
\newcolumntype{P}[1]{>{\centering\arraybackslash}p{#1}}
\newcolumntype{M}[1]{>{\centering\arraybackslash}m{#1}}

\begin{document}
    %\begin{table}[h!]
    \begin{sidewaystable}[h!]
        %\begin{adjustwidth}{-4.5cm}{}
        
        \begin{tabular}{|c|c|c|c|c|c|c|}
            
            \hline
            \multicolumn{7}{|l|}{My name is Tam Sam Insti}\\
            \multicolumn{7}{|l|}{}
            \\
            \hline
            \multicolumn{4}{|l|}{} & \multicolumn{2}{l|}{\multirow{2}{4cm}{}} &\\
            \multicolumn{4}{|l|}{aarival} & \multicolumn{2}{l|}{\multirow{2}{4cm}{Departure}} &  \\ \cline{1-4}
            \multicolumn{4}{|l|}{} & \multicolumn{2}{l|}{\multirow{2}{4cm}{}} & \\
            
            
            
            
            \multicolumn{2}{|l|}{Train Number} & \multicolumn{2}{l|}{Station }&\multicolumn{2}{l|}{}&  \\ \cline{1-6}
            &&& &&&\\ 
            
            
            &&&&&& \multirow{2}{4.1cm}{}\\
            9.00 & 10.00 & 11.00 &12.00&13.00&14.00& \multirow{2}{4.1cm}{9.00} \\
            &&&&&&\\
            &&&&&& \multirow{2}{4.1cm}{}\\
            \hline
            &&&&&&\\
            
            papri& nain & good & mrth & monday & tuesday & saturday \\
            &&&&&&\\
            \hline
        \end{tabular}
        
        %\end{adjustwidth}
        %\end{table}
    \end{sidewaystable}
\end{document}

答案2

你的问题是什么,这完全清楚。所以我主要尝试清理你的代码,尝试(基于猜测)做出更合乎逻辑的布局:

\documentclass{article}
\usepackage[strict]{changepage}
\usepackage{rotating}
\usepackage{array, makecell, multirow, tabularx}
\newcolumntype{C}{>{\centering\arraybackslash}X}
\NewExpandableDocumentCommand\mcl{O{|c|}m}{\multicolumn{#1}{|l|}{#2}}
\NewExpandableDocumentCommand\mcll{O{|c|}m}{\multicolumn{#1}{l|}{#2}}

%---------------- Show page layout. Don't use in a real document!
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%

\begin{document}
    \begin{adjustwidth}{}{-\dimexpr\marginparwidth+\marginparsep}
    \setcellgapes{7pt}
    \makegapedcells
\begin{tabularx}{\linewidth}{|*{4}{>{\centering}p{4em}|}C|C|C|}
    \Xhline{1.2pt}
\mcl[7]{My name: \textbf{Tam Sam Insti}}           \\
    \hline
\mcl[4]{Arival}         & \mcll[2]{Departure}    &           \\
    \cline{1-6}
\mcl[2]{Train Number}   & \mcll[2]{Station}      &   &   &   \\ 
    \cline{1-6}
9.00 & 10.00 & 11.00 & 12.00 & 13.00 & 14.00 & 9.00         \\
    \hline
papri& nain & good & mrth & monday & tuesday & saturday \\
    \Xhline{1.2pt}
    \end{tabularx}
    \end{adjustwidth}
\end{document}

现在给出:

在此处输入图片描述

(红线表示页面布局)

答案3

这是一个{NiceTabular}使用 的解决方案nicematrix

 \documentclass{article}
 \usepackage{nicematrix}
 \usepackage{rotating}

 \begin{document}

 \renewcommand{\arraystretch}{1.4}
 \begin{sidewaystable}
 \begin{NiceTabular}{*{4}{c}ccw{c}{4cm}}[hvlines]
 \Block[l]{1-*}{My name is Tam Sam Insti} \\
 \Block[l]{1-4}{aarival} &&&& \Block[l]{2-2}{Departure} && \Block{3-1}{}\\
 \Block[l]{1-2}{Train number} && \Block[l]{1-2}{Station} \\
 \rule[-5mm]{0pt}{10mm}%
 9.00 & 10.00 & 11.00 & 12.00 & 13.00 & 14.00 & \Block[l]{1-1}{9.00}  \\
 papri & nain & good & mrth & monday & thesday & saturday 
 \end{NiceTabular}
 \end{sidewaystable}

 \end{document}

上述代码的输出

答案4

在此处输入图片描述

\documentclass{article}
\usepackage{multirow}
\usepackage{booktabs}
%\usepackage{changepage}
%\usepackage{array}
%\usepackage{romannum}
%\usepackage{rotating}
%\usepackage{calc}
%\usepackage{amsmath}
%\usepackage{makecell}
%\usepackage{nicematrix}
%\usepackage{tabu}
%\newcolumntype{P}[1]{>{\centering\arraybackslash}p{#1}}
%\newcolumntype{M}[1]{>{\centering\arraybackslash}m{#1}}

\begin{document}
    \begin{table}[h!]
        \begin{tabular}{ccccccc}
            \toprule
            \multicolumn{7}{l}{My name is Tam Sam Insti}\\
            \midrule
            \multicolumn{4}{l}{Arrival} & \multicolumn{3}{l}{Departure}  \\ \cmidrule{1-6}
            \multicolumn{4}{l}{Train Number} & \multicolumn{3}{l}{Station }  \\ \cmidrule{1-6}
            9.00 & 10.00 & 11.00 &12.00&13.00&14.00&  \\
            \midrule
            &&&&&&\multirow{1.4}{*}{9.00}\\\midrule
            papri& nain & good & mrth & monday & tuesday & saturday \\
            \bottomrule
        \end{tabular}
    \end{table}
\end{document}

编辑垂直线

更改以下行

    \multicolumn{4}{l|}{Train Number} & \multicolumn{3}{l}{Station }  \\ \cline{1-6}

在此处输入图片描述

相关内容