如何绘制垂直线表格

如何绘制垂直线表格

我在这里搜索,表格中的垂直线,它暗示了类似的东西:

 \begin{tabular}{cc|ccc|ccc}

在此处输入图片描述

我在用:

\toprule
 & & \multicolumn{5}{>{\centering\arraybackslash}p{8em}}{\textbf{Bootstrap}} \\
\cmidrule{4-8}

但不合适。

我希望得到以下内容: 在此处输入图片描述

我的 MWE:

\documentclass[12pt,oneside]{book}

\usepackage[showframe]{geometry}
\usepackage{amsmath}
\usepackage{ragged2e}
\usepackage{makecell, multirow, tabularx}
\renewcommand\theadfont{\small\bfseries} % for bold in table using \small
\renewcommand\theadgape{}
\usepackage[svgnames, table]{xcolor}
\usepackage{hhline, boldline}
\usepackage{seqsplit, caption} %for table spacing to second row
\usepackage{booktabs, ragged2e} % Use booktabs rules and get rid of vertical rules, ragged2e to ragged text
\usepackage{siunitx} %for table spacing to second row
\usepackage{threeparttable} %to add footnote below table
\usepackage{tabulary}
\usepackage{graphicx}

\begin{document}

\begin{table}[h!]
\centering
% \begin{center}
    %\begin{tabularx}{\textwidth}{@{}M*{6}{N}@{}}
\begin{tabularx}{\textwidth}{>{\RaggedRight\arraybackslash}cXcccccc}
\toprule
 & & \multicolumn{5}{>{\centering\arraybackslash}p{8em}}{\textbf{Bootstrap}} \\
\cmidrule{4-8}
    & 
    &  \multirow{4.5}{*}{\textbf{Mean}} 
    &  \multirow{4.5}{*}{\textbf{Bias}} 
    & \multirow{4.5}{*}{\makecell{\textbf{Std.}\\ \textbf{Error}}}  
    & \multirow{4.5}{*}{\makecell{\textbf{Sig.}\\ \textbf{(2-tailed)}}}
    & \multicolumn{2}{>{\centering\arraybackslash}p{8em}}{\textbf{95\% Confidence Interval of the Difference}}  
    \\
\cmidrule{7-8}  %\cmidrule(lr){3-4}
     & & & & & & \multicolumn{1}{c}{\textbf{Lower}} &  \multicolumn{1}{c}{\textbf{Upper}} \\
\midrule
    Pair 1 
    & \textit{Testing example dataset} (AA) - \textit{Testing puree Example Dataset} (BB) 
    & 44.76\% 
    &  0.19\%  
    & 4.35 
    & 0.001 
    & 36.67\% 
    & 53.33\%\\
    \bottomrule
    \end{tabularx}
\end{table}

\end{document} 

答案1

我不会添加垂直线,而是使用适当的\cmidrule

在此处输入图片描述

\documentclass[12pt,oneside]{book}
\usepackage[showframe]{geometry}
\usepackage{ragged2e}
\usepackage{booktabs, makecell, multirow, tabularx, tabulary}
\renewcommand\theadfont{\small\bfseries} % for bold in table using \small
\renewcommand\theadgape{}
\newcolumntype{L}{>{\RaggedRight}X}
\usepackage{threeparttable} %to add footnote below table
 \usepackage[svgnames, table]{xcolor}
\usepackage[skip=1ex]{caption} %for table spacing to second row
\usepackage{siunitx} %for table spacing to second row

    \begin{document}
        \begin{table}[ht]
\sisetup{round-mode = places,
         round-precision=2,
         detect-weight
         }
\setlength\tabcolsep{3pt}
    \begin{threeparttable}
\caption{Bootstrap for paired Samples Test}
\label{tab:blabla}
        \begin{tabularx}{\linewidth}
                {@{} l L *{3}{S[table-format=2.2,table-space-text-post={\,\%}]}
                              S[table-format=1.3]
                         *{2}{S[table-format=2.2,table-space-text-post={\,\%}]}
                 @{}}
        \toprule
        &   &               & \multicolumn{5}{c}{Bootstrap}                                 \\
        \cmidrule{4-8}
        &   &               &               &               &       & \multicolumn{2}{c}{\thead{\SI{95}{\%} Confidence\\ Interval}}                       \\
        \cmidrule{7-8}
        &   & {Mean}        & {Bias}        & {\thead{SE\tnote{a}}} & {\thead{STT\tnote{b}}}
                                                                    & {\thead{Lower}}
                                                                        & {\thead{Upper}}   \\
        \midrule
Pair 1  & Testing example dataset (BB) - Testing Example Dataset (AA)
            & 12.34567\%    & 12.34567\%    & 12.34567\%    & 1.234 & 12.34567\%    & 12.34567\%    \cr
        \bottomrule
    \end{tabularx}
\begin{tablenotes}[para, flushleft]
\item[a]    SE: Standard Error
\item[b]    STT: Signal (Two Tailed)
\end{tablenotes}
    \end{threeparttable}
        \end{table}
\end{document}

(MWE 基于我的答案

但是,如果你坚持要这样做:

在此处输入图片描述

\documentclass[12pt,oneside]{book}
\usepackage[showframe]{geometry}
\usepackage{ragged2e}
\usepackage{booktabs, makecell, multirow, tabularx, tabulary}
\renewcommand\theadfont{\small\bfseries} % for bold in table using \small
\renewcommand\theadgape{}
\newcolumntype{L}{>{\RaggedRight}X}
\usepackage{threeparttable} %to add footnote below table
 \usepackage[svgnames, table]{xcolor}
\usepackage[skip=1ex]{caption} %for table spacing to second row
\usepackage{siunitx} %for table spacing to second row

    \begin{document}
        \begin{table}[ht]
\sisetup{round-mode = places,
         round-precision=2,
         detect-weight
         }
\setlength\tabcolsep{3pt}
    \begin{threeparttable}
\caption{Bootstrap for paired Samples Test}
\label{tab:blabla}
        \begin{tabularx}{\linewidth}
                {@{} l L *{3}{S[table-format=2.2,table-space-text-post={\,\%}]|}
                              S[table-format=1.3]|
                              S[table-format=2.2,table-space-text-post={\,\%}]|
                              S[table-format=2.2,table-space-text-post={\,\%}] 
                 @{}}
        \hline
        &   &               & \multicolumn{5}{|c}{Bootstrap}                                 \\
        \cline{4-8}
        &   &               &               &               &       & \multicolumn{2}{c}{\thead{\SI{95}{\%} Confidence\\ Interval}}                       \\
        \cline{7-8}
        &   & {Mean}        & {Bias}        & {\thead{SE\tnote{a}}} & {\thead{STT\tnote{b}}}
                                                                    & {\thead{Lower}}
                                                                        & {\thead{Upper}}   \\
        \hline
Pair 1  & Testing example dataset (BB) - Testing Example Dataset (AA)
            & 12.34567\%    & 12.34567\%    & 12.34567\%    & 1.234 & 12.34567\%    & 12.34567\%    \cr
        \hline
    \end{tabularx}
\begin{tablenotes}[para, flushleft]
\item[a]    SE: Standard Error
\item[b]    STT: Signal (Two Tailed)
\end{tablenotes}
    \end{threeparttable}
        \end{table}
\end{document}

相关内容