多行表格

多行表格

我正在尝试重新创建这张表

桌子的图片

    \centering
    \begin{tabular}{|l|p{2cm}|c|c|}
\hline
& 
\multirow{1}{*}{Price at \\t=0}
& \multicolumn{2}{c|}{Futrue ($t.t=1..1$) price} \\
\cline{3-4}
 &  & Event $u$ &Event $d$\\
\hline
Risk Asset & \textcolor{red}{\$A} & \$$uA$ &\$$dA$\\
\hline
Risk free Asset & \textcolor{red}{\$1} & \$$F$ &\$ $F$\\
\hline
    \end{tabular}
\end{table}

答案1

为了使“t=0 时的价格”显示在两行中,无需\multirow。只需将文本拆分为两个表格行,但最后两列的标题部分仍需要这两个行。

由于您也询问了背景颜色,因此我添加了第二个示例nicematrix

在此处输入图片描述

\documentclass{article}

\usepackage{tikz}
\usepackage{nicematrix}
\begin{document}

\begin{table}
\centering
\begin{tabular}{|l|c|c|c|}
\hline
& 
Price at 
& \multicolumn{2}{c|}{Futrue ($t.t=1..1$) price} \\
\cline{3-4}
 & t=0 & Event $u$ &Event $d$\\
\hline
Risk Asset & \textcolor{red}{\$A} & \$$uA$ &\$$dA$\\
\hline
Risk free Asset & \textcolor{red}{\$1} & \$$F$ &\$ $F$\\
\hline
\end{tabular}
\end{table}


\begin{table}
\centering
\begin{NiceTabular}{lccc}[hvlines, rules/color=[gray]{0.35}, cell-space-limits=3pt]
\CodeBefore
\rowcolor{black!5}{1,2}
\columncolor{black!5}{1,2}
\rectanglecolor{black!15}{3-2}{4-2}
\Body
\Block{2-1}{}   &  \Block{2-1}{Price at\\ t=0} & \Block{1-2}{Future ($t.t=1..1$)\\ Price in} \\
                &                              & Event $u$    & Event $d$                    \\
Risk Asset      & \textcolor{red}{\$A}         & \$$uA$       &\$$dA$                        \\
Risk free Asset & \textcolor{red}{\$1}         & \$$F$        &\$ $F$                        \\
\CodeAfter
\tikz \draw [black, thick] (1-|1) rectangle (last-|last) ; 
\end{NiceTabular}
\end{table}

\end{document}

相关内容