2

I'm stuck in drawing the horizontal line over multicol{2} with and also a vertical line

\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}
4
  • What's the reason for the combination of multirow and thead?
    – leandriis
    May 4, 2020 at 13:38
  • Thead is for heading and multirow for merging rows
    – Moody
    May 4, 2020 at 13:45
  • Sorry I entirely overlooked the multicolumn commands at the end of the row. Where exactly would you like to place the horizontal line? Probably you want to use \cline{4-13}?
    – leandriis
    May 4, 2020 at 13:55
  • For the missing vertical lines, you can try \multicolumn{2}{|c}
    – leandriis
    May 4, 2020 at 13:59

1 Answer 1

1

enter image description here

You need to ad | after column type in \multicolumn: \multicolumn{2}{c|}{....}. I also take liberty and replace c columns type with S in all columns, where you have only numbers. Now numbers are aligned at decimal points.

\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}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.