你能帮我画出图片上的内容吗?
这是我目前的代码:
\documentclass{article}
\usepackage{multirow}
\usepackage{color}
\usepackage{layout}
\usepackage{multicol}
\usepackage{subcaption}
\usepackage{caption}
\usepackage[table]{xcolor}% http://ctan.org/pkg/xcolor
\begin{document}
\begin{table}
\parbox{.45\linewidth}{
\centering
\begin{tabular}{|c|c|c|c|c|c|}
\hline
& & & & & \\ \hline
& & & & & \\ \hline
& & & & & \\ \hline
& & & & & \\ \hline
& & & & & \\ \hline
& & & & & \cellcolor{gray!25} \\ \hline
& & & & & \cellcolor{gray!25} \\ \hline
& & & & & \cellcolor{gray!25} \\ \hline
& & & & & \cellcolor{gray!25} \\ \hline
\end{tabular}
}
\hfill
\parbox{.45\linewidth}{
\centering
\begin{tabular}{|c|c|c|c|c|c|}
\hline
& &\cellcolor{gray!25} & & & \cellcolor{gray!25} \\ \hline
&\cellcolor{gray!25} & & & &\cellcolor{gray!25} \\ \hline
& & & & & \\ \hline
& \cellcolor{gray!25} & & & & \\ \hline
& & & & \cellcolor{gray!25} & \\ \hline
& &\cellcolor{gray!25} & & & \\ \hline
\cellcolor{gray!25} & & & & & \\ \hline
& \cellcolor{gray!25} & & & & \\ \hline
& & & \cellcolor{gray!25} & &\cellcolor{gray!25} \\ \hline
\end{tabular}
}
\end{table}
\end{document}
答案1
这假设您想保留表格并仅对其进行注释(而不是使用 Ti 创建这些网格钾Z)然后local cs
(如定义这里) 可以帮助您实现这一目标。
\documentclass{article}
\usepackage{multirow}
\usepackage{color}
\usepackage{layout}
\usepackage{multicol}
\usepackage{subcaption}
\usepackage{caption}
\usepackage[table]{xcolor}% http://ctan.org/pkg/xcolor
\usepackage{tikz}
\usetikzlibrary{calc}
\begin{document}
\begin{table}
\parbox{.45\linewidth}{
\centering
\begin{tikzpicture}[local cs/.style={shift={(#1.south west)},x={(#1.south
east)-(#1.south west)},y={(#1.north west)-(#1.south west)}}]
\node[inner sep=0pt,outer sep=0pt] (tab) {\begin{tabular}{|c|c|c|c|c|c|}
\hline
& & & & & \\ \hline
& & & & & \\ \hline
& & & & & \\ \hline
& & & & & \\ \hline
& & & & & \\ \hline
& & & & & \cellcolor{gray!25} \\ \hline
& & & & & \cellcolor{gray!25} \\ \hline
& & & & & \cellcolor{gray!25} \\ \hline
& & & & & \cellcolor{gray!25} \\ \hline
\end{tabular}};
\begin{scope}[local cs=tab,font=\sffamily,nodes={align=center}]
\draw[thick,latex-latex] ([yshift=-1em]0,0)
-- ([yshift=-1em]1,0) node[pos=5/12,below]{independent\\
variables} node[pos=5/6,anchor=north west]{dependent\\
variables};
\draw[double=black,double distance=0.8pt,white,thick] (5/6,-0.2em)
-- ++(0,-1.6em);
\draw[thick,latex-latex] ([xshift=1em]1,0) -- ([xshift=1em]1,1)
node[pos=2/9,right]{test\\rows}
node[pos=13/18,right]{training\\rows};
\draw[double=black,double distance=0.8pt,white,thick]
([xshift=0.2em]1,4/9) -- ++ (1.6em,0);
\end{scope}
\end{tikzpicture}
}
\hfill
\parbox{.45\linewidth}{
\centering
\begin{tikzpicture}[local cs/.style={shift={(#1.south west)},x={(#1.south
east)-(#1.south west)},y={(#1.north west)-(#1.south west)}}]
\node[inner sep=0pt,outer sep=0pt] (tab) {\begin{tabular}{|c|c|c|c|c|c|}
\hline
& &\cellcolor{gray!25} & & & \cellcolor{gray!25} \\ \hline
&\cellcolor{gray!25} & & & &\cellcolor{gray!25} \\ \hline
& & & & & \\ \hline
& \cellcolor{gray!25} & & & & \\ \hline
& & & & \cellcolor{gray!25} & \\ \hline
& &\cellcolor{gray!25} & & & \\ \hline
\cellcolor{gray!25} & & & & & \\ \hline
& \cellcolor{gray!25} & & & & \\ \hline
& & & \cellcolor{gray!25} & &\cellcolor{gray!25} \\ \hline
\end{tabular}};
\begin{scope}[local cs=tab,font=\sffamily,nodes={align=center}]
\draw[thick,latex-latex] ([yshift=-1em]0,0)
-- ([yshift=-1em]1,0) node[pos=1/2,below]{no demarcation between
independent\\ and dependent variables};
\draw[thick,latex-latex] ([xshift=1em]1,0) -- ([xshift=1em]1,1)
node[pos=1/2,right]{no\\ demarcation\\ between\\ training and\\ test rows};
\end{scope}
\end{tikzpicture}
}
\end{table}
\end{document}