0

I'm trying to recreate this table

picture of table

    \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}
2
  • 2
    There is not really a need for a \multirow here. A simple \begin{table} \centering \begin{tabular}{|l|c|c|c|} \hline & Price at & \multicolumn{2}{c|}{Futrue ($t.t=1..1$) price} \\ \cline{3-4} & at 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} should suffice.
    – leandriis
    Jul 27 at 6:34
  • TY! What about the row and column colors Jul 27 at 6:53
2

In order to get "Price at t=0" to be displayed in two lines there is no need for \multirow. Just split the text into the two table rows which you nevertheless need for the header part of the last two columns.

Since you asked about the background colors, as well, I added a second example using nicematrix:

enter image description here

\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}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.