表格边框有问题 - 有些不完整

表格边框有问题 - 有些不完整

我又遇到了表格边框的问题。我想制作如下内容: 在此处输入图片描述

或者像这样: 在此处输入图片描述

但我一直得到这样的信息: 在此处输入图片描述

这些是我的命令:

    \begin{table}[ht!]
\renewcommand{\arraystretch}{1}
\small
\doublespacing
\begin{center}
    \caption{The Estimated Effect of Cultural Distance on Protectionism, Treatment Received}
    \begin{tabular}{c|c|c|}
    \cline{2-3}
    & \multicolumn{2}{c}{\textbf{Treatment Received}}\\ \cline{2-3}
    & All Respondents & Prejudiced Respondents\\ \cline{1-3}
    Culturally Foreign & 25.6 & 44.4\\ 
    Culturally Familiar & 20.0 & 19.0\\
    Difference & 5.6 & 25.4*\\
    (95\% Confidence Interval) & (-1.1 to 12.4) & (6.6 to 44.1)\\
    p-value & 0.101  & 0.009\\ \hline
\end{tabular}
\end{center}
\end{table}

答案1

尝试这个:

\begin{table}[ht!]
\renewcommand{\arraystretch}{1}
\small
\doublespacing
\begin{center}
\caption{The Estimated Effect of Cultural Distance on Protectionism, Treatment Received}
\begin{tabular}{c|c|c|}
\cline{2-3}
& \multicolumn{2}{c|}{\textbf{Treatment Received}}\\ \cline{2-3}
& All Respondents & Prejudiced Respondents\\ \cline{1-3}
\multicolumn{1}{|c|}{Culturally Foreign} & 25.6 & 44.4\\ 
\multicolumn{1}{|c|}{Culturally Familiar} & 20.0 & 19.0\\
\multicolumn{1}{|c|}{Difference} & 5.6 & 25.4*\\
\multicolumn{1}{|c|}{(95\% Confidence Interval)} & (-1.1 to 12.4) & (6.6 to 44.1)\\
\multicolumn{1}{|c|}{p-value} & 0.101  & 0.009\\ \hline
\end{tabular}
\end{center}
\end{table}

答案2

另一种解决方案和不同的外观可能会引起人们的兴趣:最后两列具有相同的(最小)宽度并且数据居中。

        \documentclass{scrartcl}%

        \usepackage[utf8]{inputenc}
        \usepackage{setspace}
        \usepackage{array}
        \usepackage{makecell}
        \newlength{\colwidth}
        \usepackage[svgnames]{xcolor}
        \usepackage{colortbl}

        \begin{document}

        \begin{table}[ht!]
        \doublespacing\centering
        \small\arrayrulecolor{SteelBlue}\arrayrulewidth = 1.2pt
        \settowidth{\colwidth}{Prejudiced Respondents}
        \caption{The Estimated Effect of Cultural Distance on Protectionism, Treatment Received}
        \begin{tabular}{r@{\color{SteelBlue}\enspace\vrule width 2pt\enspace}c @{\color{SteelBlue}\vrule width 1.2pt\ }c @{\color{SteelBlue}\vrule width 1.2pt}c}
        \multicolumn{1}{c}{}& \multicolumn{2}{c}{\textbf{Treatment Received}} & \\
        \multicolumn{1}{c@{\color{SteelBlue}\enspace\vrule width 2pt\enspace}}{} & \multicolumn{1}{c}{\makebox[\colwidth][c]{All Respondents}} & \multicolumn{1}{c}{Prejudiced Respondents}\\
        \cline{2-4}\\[-12pt]%{1.2pt}
        Culturally Foreign & 25.6 & 44.4\\
        Culturally Familiar & 20.0 & 19.0\\
        Difference & 5.6 & 25.4*\\
        (95\% Confidence Interval) & (-1.1 to 12.4) & (6.6 to 44.1)\\
        p-value & 0.101  & 0.009\\[6pt]% \cline{2-3}
        \end{tabular}
        \end{table}

        \begin{table}[ht!]
        \doublespacing\centering
        \small\arrayrulecolor{SteelBlue}\arrayrulewidth = 2pt
        \settowidth{\colwidth}{Prejudiced Respondents}
        \caption{The Estimated Effect of Cultural Distance on Protectionism, Treatment Received}
        \begin{tabular}{@{}r@{\color{SteelBlue}\enspace\vrule width 2pt\enspace}c @{\color{SteelBlue}\vrule width 1.2pt\ }c @{\color{SteelBlue}\vrule width 1.2pt}c}
        & \multicolumn{2}{c}{\textbf{Treatment Received}} &\\
        \multicolumn{1}{c@{\color{SteelBlue}\enspace\vrule width 2pt\enspace}}{} & \multicolumn{1}{c}{\makebox[\colwidth][c]{All Respondents}} & \multicolumn{1}{c}{Prejudiced Respondents}\\
        \hline\\[-12pt]%{1.2pt}{2-4}
        Culturally Foreign & 25.6 & 44.4\\
        Culturally Familiar & 20.0 & 19.0\\
        Difference & 5.6 & 25.4*\\
        (95\% Confidence Interval) & (-1.1 to 12.4) & (6.6 to 44.1)\\
        p-value & 0.101  & 0.009\\[6pt]% \cline{2-3}
        \end{tabular}
        \end{table}

    \end{document} 

在此处输入图片描述

答案3

{NiceTabular}供参考,这里有一种使用来创建表格的方法nicematrix

\documentclass{article}
\usepackage{caption}
\usepackage{nicematrix}

\begin{document}

\begin{table}[ht!]
\small
\centering
\renewcommand{\arraystretch}{1.4}
\begin{NiceTabular}{ccc}% 
  [
    hvlines,
    corners,
    caption = {The Estimated Effect of Cultural Distance on Protectionism, Treatment Received}
  ]
& \Block{1-2}{\textbf{Treatment Received}}\\ 
& All Respondents & Prejudiced Respondents\\ 
Culturally Foreign & $25.6$ & $44.4$ \\ 
Culturally Familiar & $20.0$ & $19.0$ \\
Difference & $5.6$ & $25.4$* \\
(95\% Confidence Interval) & ($-1.1$ to $12.4$) & ($6.6$ to $44.1$)\\
p-value & 0.101  & 0.009
\end{NiceTabular}
\end{table}

\end{document}

您需要多次编译。

上述代码的输出

相关内容