![用线分隔矩阵元素](https://linux22.com/image/393891/%E7%94%A8%E7%BA%BF%E5%88%86%E9%9A%94%E7%9F%A9%E9%98%B5%E5%85%83%E7%B4%A0.png)
使用以下代码
\documentclass{beamer}
\beamertemplatenavigationsymbolsempty
\usepackage{verbatim}
\usepackage{tikz}
\usepackage{pgfplots}
\usetikzlibrary{arrows, arrows.meta}
\usetikzlibrary{matrix}
\begin{document}
\begin{frame}[t,fragile]
\frametitle{}
\begin{tikzpicture}
\matrix (x) [matrix of nodes,row sep=1em,column sep=1em] {%
15.1 & 23.7 & 19.7 & 15.4 & 18.3 & 23.0\\
17.4 & 18.6 & 12.9 & 20.3 & 13.7 & 21.4\\
10.3 & 26.1 & 15.7 & 14.0 & 17.8 & 33.8\\
23.2 & 12.9 & 29.8 & 18.3 & 14.2 & 20.8\\
13.5 & 17.1 & 20.7 & 27.1 & 18.9 & 16.6\\};
\draw<2->[ultra thick, blue, latex'-] (x-2-1) -- (x-4-5);
% Node names: (<name of matrix>-<row>-<column>)
\end{tikzpicture}
\end{frame}
\end{document}
从答案这个问题
矩阵元素是否可以用线分隔,以便看起来像单元格之间有边框的表格
答案1
matrix
它本身并不是真正设计用来绘制表格的,但是calc
可以绘制任何类型的线条。
\documentclass{beamer}
\beamertemplatenavigationsymbolsempty
\usepackage{verbatim}
\usepackage{tikz}
\usetikzlibrary{arrows, arrows.meta}
\usetikzlibrary{matrix,calc}
\begin{document}
\begin{frame}[t,fragile]
\frametitle{}
\begin{tikzpicture}
\matrix (x) [matrix of nodes,row sep=1em,column sep=1em] {%
15.1 & 23.7 & 19.7 & 15.4 & 18.3 & 23.0\\
17.4 & 18.6 & 12.9 & 20.3 & 13.7 & 21.4\\
10.3 & 26.1 & 15.7 & 14.0 & 17.8 & 33.8\\
23.2 & 12.9 & 29.8 & 18.3 & 14.2 & 20.8\\
13.5 & 17.1 & 20.7 & 27.1 & 18.9 & 16.6\\};
\draw<2->[ultra thick, blue, latex'-] (x-2-1) -- (x-4-5);
% Node names: (<name of matrix>-<row>-<column>)
\foreach \i in {1,...,6}
\draw ($(x-1-\i.north west)+(-.5em,.5em)$) -- ($(x-5-\i.south west)+(-.5em,-.5em)$);
\foreach \i in {1,...,5}
\draw ($(x-\i-1.south west)+(-.5em,-.5em)$) -- ($(x-\i-6.south east)+(.5em,-.5em)$);
\draw ($(x-1-1.north west)+(-.5em,.5em)$) -| ($(x-5-6.south east)+(.5em,-.5em)$);
\end{tikzpicture}
\end{frame}
\end{document}
答案2
只是为了好玩一些风格。
\documentclass{beamer}
\beamertemplatenavigationsymbolsempty
\usepackage{verbatim}
\usepackage{tikz}
\usetikzlibrary{arrows,calc}
\usetikzlibrary{matrix}
\begin{document}
\begin{frame}[t,fragile]
\frametitle{}
\begin{tikzpicture}[vline/.style={insert path={
($(x-1-#1.east)!0.5!(x-1-\the\numexpr1+#1.west)$) coordinate (aux)
(x.north-|aux) -- (x.south-|aux)}},
hline/.style={insert path={
($(x-#1-1.south)!0.5!(x-\the\numexpr1+#1\relax-1.north)$) coordinate (aux)
(x.west|-aux) -- (x.east|-aux)}}]
\matrix (x) [matrix of nodes,row sep=1em,column sep=1em] {%
15.1 & 23.7 & 19.7 & 15.4 & 18.3 & 23.0\\
17.4 & 18.6 & 12.9 & 20.3 & 13.7 & 21.4\\
10.3 & 26.1 & 15.7 & 14.0 & 17.8 & 33.8\\
23.2 & 12.9 & 29.8 & 18.3 & 14.2 & 20.8\\
13.5 & 17.1 & 20.7 & 27.1 & 18.9 & 16.6\\};
\draw[vline/.list={1,...,5},hline/.list={1,...,4}] (x.north west) rectangle
(x.south east);
\draw<2->[ultra thick, blue, latex'-] (x-2-1) -- (x-4-5);
% Node names: (<name of matrix>-<row>-<column>)
\end{tikzpicture}
\end{frame}
\end{document}