一开始我想问为什么矩阵在投影仪中会混乱,然后@percusse
给出说明让它正确运行。
现在剩下的问题是之前的两个箭头c4
似乎c7
不是水平的,有办法修复它吗?
\documentclass{standalone}
%\documentclass{beamer}
\usepackage{tikz}
\usetikzlibrary{matrix}
\begin{document}
%\begin{frame}[fragile]
\begin{tikzpicture}
\matrix (m) [matrix of math nodes,row sep=3em,column sep=4em,minimum width=2em]
{
c_0 & c_1 & c_2 & c_3 \\
{} & c_4 & c_5 & c_6 \\
{} & c_7 & c_8 & & \\
};
\path[-stealth]
(m-1-1) edge node [above] {$a_0$} (m-1-2)
(m-1-2) edge node [above] {$a_1$} (m-1-3)
(m-1-3) edge node [above] {$a_2$} (m-1-4)
(m-2-1) edge node [above] {$a_3$} (m-2-2)
(m-2-2) edge node [above] {$a_4$} (m-2-3)
(m-2-3) edge node [above] {$a_5$} (m-2-4)
(m-3-1) edge node [above] {$a_6$} (m-3-2)
(m-3-2) edge node [above] {$a_7$} (m-3-3);
\end{tikzpicture}
%\end{frame}
\end{document}
答案1
在第一列中使用幻像节点并删除最后一行中多余的“&”符号:
\documentclass{beamer}
\usepackage{tikz}
\usetikzlibrary{matrix}
\begin{document}
\begin{frame}[fragile]
\begin{tikzpicture}
\matrix (m) [matrix of math nodes,row sep=3em,column sep=4em,
minimum width=2em]
{
c_0 & c_1 & c_2 & c_3 \\
{\phantom{c_0}} & c_4 & c_5 & c_6 \\
{\phantom{c_0}} & c_7 & c_8 & \\
};
\path[-stealth]
(m-1-1) edge node [above] {$a_0$} (m-1-2)
(m-1-2) edge node [above] {$a_1$} (m-1-3)
(m-1-3) edge node [above] {$a_2$} (m-1-4)
(m-2-1) edge node [above] {$a_3$} (m-2-2)
(m-2-2) edge node [above] {$a_4$} (m-2-3)
(m-2-3) edge node [above] {$a_5$} (m-2-4)
(m-3-1) edge node [above] {$a_6$} (m-3-2)
(m-3-2) edge node [above] {$a_7$} (m-3-3);
\end{tikzpicture}
\end{frame}
\end{document}
或用于箭头起始坐标(m-1-1.east |- m-2-2)
和(m-1-1.east |- m-3-2)
:
\path[-stealth]
(m-1-1) edge node [above] {$a_0$} (m-1-2)
(m-1-2) edge node [above] {$a_1$} (m-1-3)
(m-1-3) edge node [above] {$a_2$} (m-1-4)
(m-1-1.east |- m-2-2) edge node [above] {$a_3$} (m-2-2)
(m-2-2) edge node [above] {$a_4$} (m-2-3)
(m-2-3) edge node [above] {$a_5$} (m-2-4)
(m-1-1.east |- m-3-2) edge node [above] {$a_6$} (m-3-2)
(m-3-2) edge node [above] {$a_7$} (m-3-3);