我想增加水平线 \hline 的长度,但不确定如何做。
这是我现在的表格:
但我希望右侧的所有 3 条水平线都更长,如下所示:
这是我当前表格的代码:
\documentclass{article}
\usepackage{newtxtext} % Times font for text
\usepackage{newtxmath} % Times font for math
\usepackage{array}
\begin{document}
\begin{tabular} {lllll}
\hline
\hline
Phase \hspace{0.17cm} & Treatment Effect \hspace{0.17cm} & Crowding Out \hspace{0.17cm} & Grant Ratio \hspace{0.17cm} & Grant Ratio Diff \\
\hline
I-II & 9.71\% & 1.36\% & 10.41\% & 0.7 \\
III & 4.47\% & -1.67\% & 1.74\% & 4.47 \\
\hline
\end{tabular}
\end{document}
答案1
尝试这个:
@{\hspace{3cm}}
在最后一列后添加额外的 3 厘米空间。这有效地将水平线 ( \hline
) 向右延伸。
您可以将 3 厘米调整为所需的长度。
\documentclass{article}
\usepackage{newtxtext} % Times font for text
\usepackage{newtxmath} % Times font for math
\usepackage{array}
\begin{document}
\begin{tabular} {lllll@{\hspace{3cm}}} % Add extra horizontal space after the last column
\hline
\hline
Phase \hspace{0.17cm} & Treatment Effect \hspace{0.17cm} & Crowding Out \hspace{0.17cm} & Grant Ratio \hspace{0.17cm} & Grant Ratio Diff \\
\hline
I-II & 9.71\% & 1.36\% & 10.41\% & 0.7 \\
III & 4.47\% & -1.67\% & 1.74\% & 4.47 \\
\hline
\end{tabular}
\end{document}
答案2
我不确定其目的是什么。
\documentclass{article}
\usepackage{newtxtext} % Times font for text
\usepackage{newtxmath} % Times font for math
\usepackage{array}
\usepackage{tabularx}
\begin{document}
\noindent
\begin{tabularx}{\textwidth}{
l
*{4}{>{$}c<{$}}
X
}
\hline\noalign{\vspace{2pt}}
\cline{1-5}
Phase&
\multicolumn{1}{c}{Treatment Effect} &
\multicolumn{1}{c}{Crowding Out} &
\multicolumn{1}{c}{Grant Ratio} &
\multicolumn{1}{c}{Grant Ratio Diff} &
\hspace*{\fill}\\
\hline
I-II & 9.71\% & 1.36\% & 10.41\% & 0.7 &\\
III & 4.47\% & -1.67\% & 1.74\% & 4.47 &\\
\hline
\end{tabularx}
\end{document}
以下是我的排版方式。
\documentclass{article}
\usepackage{newtxtext} % Times font for text
\usepackage{newtxmath} % Times font for math
\usepackage{booktabs,siunitx}
\begin{document}
\noindent
\begin{tabular*}{\textwidth}{
@{\extracolsep{\fill}}
l
S[table-format=1.2\%]
S[table-format=-1.2\%]
S[table-format=2.2\%]
S[table-format=1.2]
@{}
}
\toprule
Phase&
{Treatment Effect} &
{Crowding Out} &
{Grant Ratio} &
{Grant Ratio Diff} \\
\midrule
I-II & 9.71\% & 1.36\% & 10.41\% & 0.7 \\
III & 4.47\% & -1.67\% & 1.74\% & 4.47 \\
\bottomrule
\end{tabular*}
\end{document}