这是我目前拥有的代码:
\begin{table}[!ht]
\centering
\caption{The observation $(s_t)$ the DRL agent receives in the beginning of time t}
\begin{tabular}{c|ccccc|ccccccccc}
\hline
& GS & JN J& MSFT & PG & XOM & M & Volume & Log Return & VIX & Adj. Close & 30-d SMA & 60-d SMA & $\Delta $30-d SMA & $\Delta$ 60-d SMA \\ %\hline
& & & Covariance Matrix (252-days) & & & & & & & & & & & \\ \hline
GS & \Sigma_{1,1} & \Sigma_{1,2} & \Sigma_{1,3} & \Sigma_{1,4} & \Sigma_{1,5} & x& x_{1,7} & x_{1,8} &x &x_{1,10} &x_{1,11} &x_{1,12} &x_{1,13} & x_{1,14} \\ %\hline
JNJ & \Sigma_{2,1} & \Sigma_{2,2} & \Sigma_{2,3} & \Sigma_{2,4} & \Sigma_{2,5} & x& x_{2,7} & x_{2,8} &x &x_{2,10} &x_{2,11} &x_{2,12} &x_{2,13} & x_{2,14} \\ %\hline
MSFT & \Sigma_{3,1} & \Sigma_{3,2} & \Sigma_{3,3} & \Sigma_{3,4} & \Sigma_{3,5} & x& x_{3,7} & x_{3,8} &x &x_{3,10} &x_{3,11} &x_{3,12} &x_{3,13} & x_{3,14} \\ %\hline
PG & \Sigma_{4,1} & \Sigma_{4,2} & \Sigma_{4,3} & \Sigma_{4,4} & \Sigma_{4,5} & x& x_{4,7} & x_{4,8} &x &x_{4,10} &x_{4,11} &x_{4,12} &x_{4,13} & x_{4,14} \\ %\hline
XOM & \Sigma_{5,1} & \Sigma_{5,2} & \Sigma_{5,3} & \Sigma_{5,4} & \Sigma_{5,5} & x& x_{5,7} & x_{5,8} &x &x_{5,10} &x_{5,11} &x_{5,12} &x_{5,13} & x_{5,14}\\ \hline
\end{tabular}
\end{table}\\
答案1
这是我的尝试,你可以根据需要进行调整,使用表格数组包裹。
您没有指定文档类别或页面尺寸。我设置了 1 英寸边距,并将表格环境中的字体大小设置为以\scriptsize
使其适合。您可能需要根据页面尺寸使用不同的字体大小和/或旋转表格。
\documentclass{article}
\usepackage{amsmath}
\usepackage{tabularray}
\usepackage{newtxtext,newtxmath}% optional; changes font to more like image
\usepackage[margin=1in]{geometry}
\newcommand{\x}{\mathrm{x}}
\begin{document}
\begin{table}[!ht]
\centering\scriptsize
\begin{tblr}{
colspec = {Q[l]Q[c,$]Q[c,$]Q[c,$]Q[c,$]Q[c,$]Q[c,$]Q[c,$]Q[c,$]Q[c,$]Q[c,$]Q[c,$]Q[c,$]Q[c,$]Q[c,$]},
% mostly centered (c) columns in math mode by default ($)
hline{1,3,8} = {0.7pt,solid},% thicker horizontal lines above rows 1,3 and 8
vline{2,7} = {0.5pt,dashed}% dashed vertical lines before columns 2 and 7
}
& \text{GS} & \text{JNJ} & \text{MSFT} & \text{PG} & \text{XOM} & \text{M} & \text{Volume} & \text{Log} & \text{VIX} & \text{Adj.} & \text{30-d} & \text{60-d} & \Delta \text{ 30-d} & \Delta \text{ 60-d} \\
& \SetCell[c=5]{c,mode=text}{\fontsize{6}{6}\selectfont Covariance Matrix (252-days)} & & & & & & & \text{Return} & & \text{Close} & \text{SMA} & \text{SMA}& \text{SMA}& \text{SMA}\\
GS & \Sigma_{1,1} & \Sigma_{1,2} & \Sigma_{1,3} & \Sigma_{1,4} & \Sigma_{1,5} & \x& \x_{1,7} & \x_{1,8} &\x &\x_{1,10} &\x_{1,11} &\x_{1,12} &\x_{1,13} & \x_{1,14} \\
JNJ & \Sigma_{2,1} & \Sigma_{2,2} & \Sigma_{2,3} & \Sigma_{2,4} & \Sigma_{2,5} & \x& \x_{2,7} & \x_{2,8} &\x &\x_{2,10} &\x_{2,11} &\x_{2,12} &\x_{2,13} & \x_{2,14} \\
MSFT & \Sigma_{3,1} & \Sigma_{3,2} & \Sigma_{3,3} & \Sigma_{3,4} & \Sigma_{3,5} & \x& \x_{3,7} & \x_{3,8} &\x &\x_{3,10} &\x_{3,11} &\x_{3,12} &\x_{3,13} & \x_{3,14} \\
PG & \Sigma_{4,1} & \Sigma_{4,2} & \Sigma_{4,3} & \Sigma_{4,4} & \Sigma_{4,5} & \x& \x_{4,7} & \x_{4,8} &\x &\x_{4,10} &\x_{4,11} &\x_{4,12} &\x_{4,13} & \x_{4,14} \\
XOM & \Sigma_{5,1} & \Sigma_{5,2} & \Sigma_{5,3} & \Sigma_{5,4} & \Sigma_{5,5} & \x& \x_{5,7} & \x_{5,8} &\x &\x_{5,10} &\x_{5,11} &\x_{5,12} &\x_{5,13} & \x_{5,14}\\
\end{tblr}
\caption{The observation $(s_t)$ the DRL agent receives in the beginning of time $t$}
\end{table}
\end{document}
我不知道“x”是什么意思,但我不确定我\x
在数学模式中插入的使它们直立的定义是否真的是你想要的。
答案2
这是一个采用tabularx
横向格式环境的解决方案。请注意,我将字符串“协方差矩阵(252 天)”放在了第一条水平线的上方,而不是下方。
\documentclass{article}
\usepackage{tabularx,amsmath,ragged2e,rotating}
\newcolumntype{C}{>{$}c<{$}} % centered and automatic math mode
\newcommand\mC[1]{\multicolumn{1}{>{\Centering\hspace{0pt}}X}{#1}}
\newcommand\mD[1]{\multicolumn{1}{>{\Centering\hspace{0pt}}X@{}}{#1}}
\renewcommand\tabularxcolumn[1]{m{#1}}
\begin{document}
\begin{sidewaystable} % switch to landscape mode & start a table env.
\setlength\extrarowheight{2pt}
\setlength\tabcolsep{4pt} % default: 0pt
\caption{The observation $(s_t)$ the DRL agent receives at the beginning of time $t$}
\medskip
\begin{tabularx}{\linewidth}{@{} l | *{5}{C} | *{9}{C} @{}}
\multicolumn{1}{c}{} &
\multicolumn{5}{c}{Covariance Matrix (252-days)} \\
\hline
& \text{GS} & \text{JN J} & \text{MSFT} & \text{PG} & \text{XOM}
& \mC{M} & \mC{Volume} & \mC{Log Return} & \mC{VIX} & \mC{Adj. Close}
& \mC{30-d SMA} & \mC{60-d SMA}
& \mC{$\Delta$~30-d SMA} & \mD{$\Delta$~60-d SMA} \\
\hline
GS & \Sigma_{1,1} & \Sigma_{1,2} & \Sigma_{1,3} & \Sigma_{1,4} & \Sigma_{1,5} & x & x_{1,7} & x_{1,8} & x & x_{1,10} & x_{1,11} & x_{1,12} & x_{1,13} & x_{1,14} \\
JNJ & \Sigma_{2,1} & \Sigma_{2,2} & \Sigma_{2,3} & \Sigma_{2,4} & \Sigma_{2,5} & x & x_{2,7} & x_{2,8} & x & x_{2,10} & x_{2,11} & x_{2,12} & x_{2,13} & x_{2,14} \\
MSFT & \Sigma_{3,1} & \Sigma_{3,2} & \Sigma_{3,3} & \Sigma_{3,4} & \Sigma_{3,5} & x & x_{3,7} & x_{3,8} & x & x_{3,10} & x_{3,11} & x_{3,12} & x_{3,13} & x_{3,14} \\
PG & \Sigma_{4,1} & \Sigma_{4,2} & \Sigma_{4,3} & \Sigma_{4,4} & \Sigma_{4,5} & x & x_{4,7} & x_{4,8} & x & x_{4,10} & x_{4,11} & x_{4,12} & x_{4,13} & x_{4,14} \\
XOM & \Sigma_{5,1} & \Sigma_{5,2} & \Sigma_{5,3} & \Sigma_{5,4} & \Sigma_{5,5} & x & x_{5,7} & x_{5,8} & x & x_{5,10} & x_{5,11} & x_{5,12} &x_{5,13} & x_{5,14}\\ \hline
\end{tabularx}
\end{sidewaystable}
\end{document}