![表格邊框有問題 - 有些不完整](https://rvso.com/image/286969/%E8%A1%A8%E6%A0%BC%E9%82%8A%E6%A1%86%E6%9C%89%E5%95%8F%E9%A1%8C%20-%20%E6%9C%89%E4%BA%9B%E4%B8%8D%E5%AE%8C%E6%95%B4.png)
我的表格邊框再次出現問題。我想製作這樣的東西:
或者像這樣:
但我不斷得到這個:
這些是我的命令:
\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}
有關信息,這裡是使用of創建表格的方法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}
你需要幾個編譯。