![在 tabularx{} 中添加垂直线](https://linux22.com/image/434490/%E5%9C%A8%20tabularx%7B%7D%20%E4%B8%AD%E6%B7%BB%E5%8A%A0%E5%9E%82%E7%9B%B4%E7%BA%BF.png)
我有一个如下所示的表格,它在 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}