我有一张看起来像这样的桌子。
我使用以下方法生成它:
\begin{table*}
\centering
\caption{ The parameters obtained from the fit for the real-space correlation function \xir{} on the sample with $zcosmo$ and the recovered deprojected correlation function $\xi_{dep}(r)$ for the mock photometric samples}
\label{tab:table2}
\begin{tabular}{*{5}{c}}
\hline
\multicolumn{1}{|p{2cm}|}{\centering Redshift uncertainty \\ $\left(\frac{\Delta z}{1+zcosmo}\right)$}
& \multicolumn{1}{|p{2cm}|}{\centering $r_{0}$ \\ $(h^{-1}Mpc)$}
& \multicolumn{1}{|p{2cm}|}{\centering $\gamma$} &
Mass & Fit range \\
\hline
$zcosmo$ & 30.07$\pm$0.66 & 1.8(\textit{fixed}) & $M_{200}>log_{10}(13.7)$ \\ [1ex]
& 40.16$\pm$4.36 & 1.50$\pm$0.09 & $M_{200}>log_{10}(13.7)$ & 5-50 Mpc \\ [1ex]
0.001 & 32.81$\pm$0.80 & 1.8(\textit{fixed}) & $M_{200}>log_{10}(13.7)$ \\ [1ex]
& 36.98$\pm$5.93 & 1.67$\pm$0.15 & $M_{200}>log_{10}(13.7)$ & 5-50 Mpc \\ [1ex]
\end{tabular}
\end{table*}
如你看到的,最后一列的值(5-50 Mpc)与第二行对齐。我希望它位于两行中间。
答案1
您可以使用\multirow
宏(来自multirow
包)。
我还会使用该包的规则绘制宏booktabs
,但我会丢失所有垂直条。
\documentclass{article}
\usepackage[margin=1in]{geometry}
\usepackage{amsmath,multirow,booktabs,caption}
\newcommand\zcosmo{\textit{zcosmo}}
\begin{document}
\begin{table*}
\centering
\caption{The parameters obtained from the fit for the real-space
correlation function $\xi(r)$ on the sample with $\zcosmo$ and the
recovered deprojected correlation function $\xi_{\textit{dep}}(r)$ for
the mock photometric samples}
\label{tab:table2}
\begin{tabular}{*{5}{c}}
\toprule
\multicolumn{1}{p{2cm}}{\centering Redshift uncertainty \\ $\bigl(\frac{\Delta z}{1+\zcosmo}\bigr)$}
& \multicolumn{1}{p{2cm}}{\centering $r_{0}$ \\ $(h^{-1}Mpc)$}
& \multicolumn{1}{p{2cm}}{\centering $\gamma$} &
Mass & Fit range \\
\midrule
$\zcosmo$ & 30.07$\pm$0.66 & 1.8\ (\textit{fixed}) & $M_{200}>\log_{10}(13.7)$
& \multirow{2}{*}{5--50 Mpc}\\ [1ex]
& 40.16$\pm$4.36 & 1.50$\pm$0.09 & $M_{200}>\log_{10}(13.7)$ & \\ [1ex]
0.001 & 32.81$\pm$0.80 & 1.8\ (\textit{fixed}) & $M_{200}>\log_{10}(13.7)$
& \multirow{2}{*}{5--50 Mpc}\\ [1ex]
& 36.98$\pm$5.93 & 1.67$\pm$0.15 & $M_{200}>\log_{10}(13.7)$ & \\
\end{tabular}
\end{table*}
\end{document}
答案2
“5--50 Mpc” 可以借助包进行移动
multirow
,参见回答米科的。单位可以用包来设置
siunitx
。特别是,它们通常不以斜体设置。秒差距的单位“pc”没有预定义,但很容易添加定义:\DeclareSIUnit{\parsec}{pc}
包
siunitx
还支持表格列按小数点对齐。例如,第 2 列和第 3 列的格式如下。不支持使用文本“(fixed)”代替不确定性,因此我将其从右侧通过 放置\rlap{(\textit{fixed})}
。像这样的数学函数
log
通常是直立设置的。示例使用宏\log
。多行标题设置为内部
tabular
标题。这样可以避免显式设置宽度和较窄的列。正如Mico的例子,去掉了垂直线条,而
booktabs
使用了更专业的包装水平线条。这四条数据看起来是两组,因此我通过 将它们分开
\addlinespace
。
完整示例:
\documentclass{article}
\usepackage{amsmath}
\usepackage{booktabs}
\usepackage{caption}
\usepackage{multirow}
\usepackage{siunitx}
\DeclareSIUnit{\parsec}{pc}
\sisetup{
range-units=single,
range-phrase=--,
}
\newcommand*{\xir}{\ensuremath{\xi(r)}}
\begin{document}
\begin{table*}
\centering
\caption{ The parameters obtained from the fit for the real-space
correlation function \xir{} on the sample with $\mathit{zcosmo}$ and the recovered
deprojected correlation function $\xi_{\text{dep}}(r)$ for the mock
photometric samples}
\label{tab:table2}
\def\fixed{\llap{(\textit{fixed})}}
\begin{tabular}{
c
S[table-format=2.2(2), separate-uncertainty]
S[table-format=1.2(2), separate-uncertainty]
cc
}
\toprule
\begin{tabular}[t]{@{}c@{}}
Redshift\\
uncertainty\\
$\left(\frac{\Delta z}{1+zcosmo}\right)$
\end{tabular}
& {\begin{tabular}[t]{@{}c@{}}
$r_{0}$ \\
(\si{\per\hour\mega\parsec})
\end{tabular}}
& \multicolumn{1}{p{2cm}}{\centering $\gamma$} &
Mass & Fit range \\
\midrule
$\mathit{zcosmo}$ & 30.07+-0.66 & 1.8\fixed & $M_{200}>\log_{10}(13.7)$ &
\multirow{2}{*}{\SIrange{5}{50}{\mega\parsec}}\\
& 40.16+-4.36 & 1.50+-0.09 & $M_{200}>\log_{10}(13.7)$ \\
\addlinespace
0.001 & 32.81+-0.80 & 1.8\fixed & $M_{200}>\log_{10}(13.7)$ &
\multirow{2}{*}{\SIrange{5}{50}{\mega\parsec}} \\
& 36.98+-5.93 & 1.67+-0.15 & $M_{200}>\log_{10}(13.7)$ \\
\bottomrule
\end{tabular}
\end{table*}
\end{document}