tabular
我以环境制作了以下三张图表LaTeX
。
现在我想Tikz
用动画制作这些图表,MWE 如下:
\documentclass{standalone}
\usepackage[latin1]{inputenc}
\usepackage{tikz}
\usetikzlibrary{shapes,arrows}
\begin{document}
% Define block styles
\tikzstyle{block} =
[
rectangle
, draw
, text width=4.5em
, text centered
, node distance=0.7cm
, minimum height=2em
]
\tikzstyle{block1} =
[
rectangle
, text width=4.5em
, text centered
, node distance=1.5cm
, minimum height=2em
]
\tikzstyle{line} =
[
draw
, -latex'
]
\begin{tikzpicture}[node distance = 2cm, auto]
% Place nodes
\node [block] (A1R1B1) {$B_{1}$};
\node [block, below of=A1R1B1] (A1R1B2) {$B_{2}$};
\node [block, below of=A1R1B2] (A1R1B3) {\vdots};
\node [block, below of=A1R1B3] (A1R1Bb) {$B_{b}$};
\node [block, right of=A1R1B1] (A1R2B1) {$B_{1}$};
\node [block, right of=A1R1B2] (A1R2B2) {$B_{2}$};
\node [block, right of=A1R1B3] (A1R2B3) {\vdots};
\node [block, right of=A1R1Bb] (A1R2Bb) {$B_{b}$};
\node [block1, right of=A1R1B1] (A1R3B1) {\ldots};
\node [block1, right of=A1R1B2] (A1R3B2) {\ldots};
\node [block1, right of=A1R1B3] (A1R3B3) {\ldots};
\node [block1, right of=A1R1Bb] (A1R3Bb) {\ldots};
\node [block, right of=A1R3B1] (A1RrB1) {$B_{1}$};
\node [block, right of=A1R3B2] (A1RrB2) {$B_{2}$};
\node [block, right of=A1R3B3] (A1RrB3) {\vdots};
\node [block, right of=A1R3Bb] (A1RrBb) {$B_{b}$};
\end{tikzpicture}
\end{document}
任何有助于获得所需结果的帮助都将不胜感激。谢谢
答案1
TikZ有一个tabular
类似的宏。\matrix
通过一些设置,您可以轻松实现类似于您所使用的示例tabular
。
代码
\documentclass[tikz,convert=false]{standalone}
\usetikzlibrary{positioning,matrix}
\begin{document}
\begin{tikzpicture}[
every block/.style={shape=rectangle, text width=2.5em, align=center, font=\strut, text depth=+.1667em},
block/.style={every block, draw},
block1/.style={every block, draw=none},
]
\matrix[
inner sep=+0pt,outer sep=+0pt,
matrix of math nodes,
nodes={block,outer ysep=+0pt,inner ysep=.3333em,outer xsep=.5\pgflinewidth},
row 1/.style={nodes=block1},
row 4/.style={nodes=block1},
column 3/.style={nodes=block1},
row sep=-\pgflinewidth,
column sep=-\pgflinewidth
] (m) {
A_1 & A_2 & \cdots & A_a \\
B_1 & B_2 & \cdots & B_1 \\
B_2 & B_1 & \cdots & B_2 \\
\vdots & \vdots & \ddots & \vdots \\
B_b & B_b & \cdots & B_b \\
};
\draw (m-2-2.north east) -- (m-2-4.north west);
\draw (m.north west) -- (m.north east);
\node[above=+0pt of m] {\itshape Block 1};
\end{tikzpicture}
\end{document}