在表格中绘制垂直线和水平线

在表格中绘制垂直线和水平线

我被困在多列{2}上画水平线,还有一条垂直线

\documentclass[10pt]{article}
\usepackage{textcomp}
\usepackage[utf8]{inputenc}
\usepackage{fontspec}
\usepackage[british]{babel}
\usepackage{float}
 \usepackage{gensymb}
 \usepackage{tabularx,ragged2e,booktabs,caption}
  \usepackage{subfigure}
  \usepackage{multicol,tabularx,capt-of}
  \usepackage{multirow}
   \usepackage{makecell}

   \begin{document}

    \begin{table*}
    \centering
    \caption{Block generation intervals and block sizes}\label{tab1}
    \begin{tabular}{|c|c|c|c|c|c|c|c|c|c|c|c|c|}
        \hline
        \multirow{2}{*}{\thead{Block \\ Sizes}} & \multirow{2}{*}{\thead{Block Generation \\ Interval}}  & \multirow{2}{*}{\thead{Total \\ blocks}}  &  \multicolumn{2}{c}{\thead{Orphaned \\ blocks}}  &  \multicolumn{2}{c}{\thead{Genuine\\ blocks}}  & \multicolumn{2}{c}{\thead{Delay \\ (s)}}  & \multicolumn{2}{c}{\thead{Average bandwidth\\ (Kbps)}} & \multicolumn{2}{c}{\thead{Throughput \\ (transaction/sec.)}} \\ 

  & & & R & N & R & N & R & N & R & N & R & N  \\  \hline   
        \multirow{5}{*}{10 KB} & 5s & 1216.5 &  20.3 & 46.7 & 1196 & 1169.8 & 0.37 & 0.51 & 48.3 & 61.2 & 8.4 & 6.3 \\ 
     &  15s & 600.3 & 0.6 & 1.3 & 599.7 & 599 & 0.35  & 0.43 & 24.2 & 45.8 & 4.3 &  3.1  \\
     &  45s & 198.7 &  0 & 0.9 & 198.7 & 197.8  & 0.35  & 0.41 & 8.6 & 24.1 & 1.7 & 0.9  \\
     &  1m & 102.2 &  0 & 0.4 & 102.2 & 101.8 & 0.31  & 0.37 & 4.3 & 14.2 & 0.9 & 0.61 \\
     &  5m & 23.4 &  0 & 0 & 23.4 & 23.4 & 0.31  & 0.33 & 0.6 & 3.4 & 0.4 & 0.22 \\ \hline  

    \end{tabular}
  \end{table*}

 \end{document}

答案1

在此处输入图片描述

您需要|在列类型后添加\multicolumn: 。我还擅自将列类型\multicolumn{2}{c|}{....}替换为所有只有数字的列。现在数字在小数点处对齐。cS

\documentclass[british]{article}% default font size=10pt
\usepackage{geometry}
\usepackage{textcomp}
%\usepackage[utf8]{inputenc} % default coding in article
\usepackage{fontspec}
\usepackage{babel}
%\usepackage{float}
\usepackage{gensymb}
%\usepackage{subfigure} % obsolete
\usepackage[skip=1ex]{caption}% define \captionof too
\usepackage{ragged2e}
\usepackage{multicol}
\usepackage{booktabs, makecell, multirow, tabularx}
\renewcommand\theadfont{\small}
\renewcommand\theadgape{}
%
\usepackage{siunitx}
\usepackage{xparse}
\NewExpandableDocumentCommand\mcc{O{1}m}
    {\multicolumn{#1}{c|}{#2}}

\begin{document}
    \begin{table}[ht]
    \centering
    \small
    \setcellgapes{3pt}
    \makegapedcells
    \caption{Block generation intervals and block sizes}\label{tab1}
\begin{tabular}{|c|c|
                S[table-format=4.1]|S[table-format=2.1]|S[table-format=2.1]|
                S[table-format=4.1]|S[table-format=4.1]|
                S[table-format=1.2]|S[table-format=1.2]|
                S[table-format=2.1]|S[table-format=2.1]|
                S[table-format=1.1]|S[table-format=1.2]| 
                }
        \hline
\multirow{2}{*}{\thead{Block \\ Sizes}} 
    & {\multirow{2}{*}{\thead{BGI}}}%Block\\ Generation \\ Interval}}}  
        & {\multirow{2}{*}{\thead{Total \\ blocks}}}  
            & \mcc[2]{\thead{Orphaned \\ blocks}}  
                & \mcc[2]{\thead{Genuine\\ blocks}}  
                    & \mcc[2]{\thead{Delay \\ (s)}} 
                        & \mcc[2]{\thead{bandwidth\\ (kb/s)}}%Average\\  
                            & \mcc[2]{\thead{Throughput \\(trans./sec.)}} \\
    \cline{4-13}
&   &   & R & N & R & N & R & N & R & N & R & N  \\  \hline
\multirow{5}{*}{10 KB} 
& \SI{5}{s} & 1216.5 &  20.3 & 46.7 & 1196 & 1169.8 & 0.37 & 0.51 & 48.3 & 61.2 & 8.4 & 6.3 \\
& \SI{15}{s}&  600.3 & 0.6 & 1.3 & 599.7 & 599   & 0.35 & 0.43 & 24.2 & 45.8 & 4.3 & 3.1  \\
& \SI{45}{s}&  198.7 & 0   & 0.9 & 198.7 & 197.8 & 0.35 & 0.41 &  8.6 & 24.1 & 1.7 & 0.9  \\
& \SI{1}{m} &  102.2 & 0   & 0.4 & 102.2 & 101.8 & 0.31 & 0.37 &  4.3 & 14.2 & 0.9 & 0.61 \\
& \SI{5}{m} &   23.4 & 0   & 0   &  23.4 &  23.4 & 0.31 & 0.33 &  0.6 &  3.4 & 0.4 & 0.22 \\
    \hline
\multicolumn{13}{l}{BGI: Block Generation Interval}
\end{tabular}
  \end{table}
 \end{document}

相关内容