在 tabularx{} 中添加垂直线

在 tabularx{} 中添加垂直线

我有一个如下所示的表格,它在 main.tex 中运行没有任何错误。我想添加一条垂直线,可能需要对线条进行一些修饰。非常感谢。我的桌子

\documentclass[11pt,authoryear,sort&compress]{report}
    \usepackage[pdftex]{graphicx}
    \usepackage{caption,tabularx,booktabs}
    
    \begin{document}
    \begin{table}[ht]
        \footnotesize
        %\scriptsize
        \centering 
        \begin{tabularx}{1\textwidth}{R*{6}{C}}
            %\begin{tabular}{ccc|cccc}
            \toprule
            & \multicolumn{2}{c}{Access} & \multicolumn{4}{c}{Type} \\
            \cline{2-7} \cline{3-7} \cline{4-7} \cline{5-7} \cline{6-7} \cline{7-7} 
            \toprule
            & 0 & 1 & Formal & Informal & Both & No Loan \\ 
            %\midrule
            \cline{2-7} \cline{3-7} \cline{4-7} \cline{5-7} \cline{6-7} \cline{7-7}  \\ %\midrule
            HR \textit{\text{(Urban = 1)}} & 18.72\% & 81.28\% &  &  &  & \\
            Education \textit{\text{(Above highschool = 1)}}  & 94.99\% & 5.01\% &  &  &  & \\
            CCP/no.CCP \textit{\text{(CCP= 1)}}  & 90.22\% & 9.78\%  &  &  &  & \\
            Gender \textit{\text{(Male = 1)}}   &  17.33\% & 82.67 &  &  &  & \\
            \bottomrule
            %\end{tabular}
        \end{tabularx}
        \caption{Chi test} 
        \label{tab:Chi.test}
    \end{table}
    \end{document}

答案1

framed希望和的组合float能帮助你满足要求,这里是MWE

\documentclass[11pt,authoryear,sort&compress]{report}
\usepackage{amsmath}
    \usepackage[pdftex]{graphicx}
    \usepackage{caption,tabularx,booktabs}
\usepackage{float,framed}
    
    \begin{document}
\begin{leftbar}
    \begin{table}[H]
        \footnotesize
        %\scriptsize
        \centering 
        \begin{tabularx}{1\textwidth}{r*{6}{c}}
            %\begin{tabular}{ccc|cccc}
            \toprule
            & \multicolumn{2}{c}{Access} & \multicolumn{4}{c}{Type} \\
            \cline{2-7} \cline{3-7} \cline{4-7} \cline{5-7} \cline{6-7} \cline{7-7} 
            \toprule
            & 0 & 1 & Formal & Informal & Both & No Loan \\ 
            %\midrule
            \cline{2-7} \cline{3-7} \cline{4-7} \cline{5-7} \cline{6-7} \cline{7-7}  \\ %\midrule
            HR \textit{\text{(Urban = 1)}} & 18.72\% & 81.28\% &  &  &  & \\
            Education \textit{\text{(Above highschool = 1)}}  & 94.99\% & 5.01\% &  &  &  & \\
            CCP/no.CCP \textit{\text{(CCP= 1)}}  & 90.22\% & 9.78\%  &  &  &  & \\
            Gender \textit{\text{(Male = 1)}}   &  17.33\% & 82.67 &  &  &  & \\
            \bottomrule
            %\end{tabular}
        \end{tabularx}
        \caption{Chi test} 
        \label{tab:Chi.test}
    \end{table}
\end{leftbar}
    \end{document}

相关内容