我有两个问题。我试图绘制的图表肯定有一种简单的方法,但我对在 tex 中绘制图表完全陌生。Xy-pic 包似乎太复杂了,因此我正在尝试 TikZ-package。
我如何将矩阵中的箭头简单地更改为
$\Rightarrows$
,我通过解决了它[double]
,但它看起来并不好看,而且箭头的颜色有些不同。如何在两个节点之间添加两个箭头。简单来说,我想在两个节点 A 和 B 之间写上
$A \Rightarrow B$
和$B \nLightarrow A$
。我还无法解决弯曲问题。
这是我迄今为止的代码。
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{matrix,arrows,decorations.pathmorphing}
\begin{document}
\begin{tikzpicture}
\matrix (m) [matrix of math nodes, row sep=3em, column sep=3em, text
height=1.5ex, text depth=0.25ex]
{ & X & & \\
A & B & C & D \\
E & F & G & H \\
& I & & \\};
\path[->] (m-1-2) edge [double] (m-2-3)
edge [double,bend left=90] (m-4-2);
\path[->] (m-2-1) edge [double] (m-2-2)
edge [double] (m-3-1)
edge [double] (m-1-2);
\path[->] (m-2-2) edge [double] (m-2-3)
edge [double] (m-3-2);
\path[->] (m-2-3) edge [double] (m-2-4)
edge [double] (m-3-3);
\path[->] (m-2-4) edge [double] (m-3-4);
\path[->] (m-3-1) edge [double] (m-3-2)
edge [double] (m-4-2);
\path[->] (m-3-2) edge [double](m-3-3);
\path[->] (m-3-3) edge [double] (m-3-4);
\path[->] (m-4-2) edge [double] (m-3-3);
\end{tikzpicture}
\end{document}
答案1
这是一个使用tikz-cd有助于创建交换图的包:
\documentclass{article}
\usepackage{tikz-cd}
\begin{document}
\begin{tikzcd}
& X\arrow[Rightarrow]{dr}{}\arrow[Rightarrow,to path={..controls +(-2.5,0.7) and +(-2.5,-0.7).. (\tikztotarget)}]{ddd}{} \\
A \arrow[Rightarrow]{ur}{}\arrow{r}{}\arrow{d} & B \arrow{r}{}\arrow{d} & C\arrow{r}{}\arrow{d} & D\arrow{d}\\
E \arrow[Rightarrow]{dr}{} \arrow{r}{} & F \arrow{r}{} & G\arrow{r}[color=red]{} & H\\
& I\arrow[Rightarrow]{ur}{}\\
\end{tikzcd}
\end{document}
如果要为所有箭头赋予 样式\Rightarrow
,则使用以下arrows=Rightarrow
选项就足够了:
\documentclass{article}
\usepackage{tikz-cd}
\begin{document}
\begin{tikzcd}[arrows=Rightarrow]
& X\arrow{dr}{}\arrow[to path={..controls +(-2.5,0.7) and +(-2.5,-0.7).. (\tikztotarget)}]{ddd}{} \\
A \arrow{ur}{}\arrow{r}{}\arrow{d} & B \arrow{r}{}\arrow{d} & C\arrow{r}{}\arrow{d} & D\arrow{d} \\
E \arrow{dr}{} \arrow{r}{} & F \arrow{r}{} & G\arrow{r}[color=red]{} & H \\
& I\arrow{ur}{}
\end{tikzcd}
\end{document}
我最初忘记了问题 2。您可以使用in=
、out=
键来弯曲箭头:
\documentclass{article}
\usepackage{tikz-cd}
\begin{document}
\begin{tikzcd}[arrows=Rightarrow]
& X\arrow{dr}{}\arrow[to path={..controls +(-2.5,0.7) and +(-2.5,-0.7).. (\tikztotarget)}]{ddd}{} \\
A \arrow{ur}{}\arrow[out=30,in=150]{r}{}\arrow{d} & B \arrow[out=210,in=330]{l}{}\arrow{r}{}\arrow{d} & C\arrow{r}{}\arrow{d} & D\arrow{d} \\
E \arrow{dr}{} \arrow{r}{} & F \arrow{r}{} & G\arrow{r}[color=red]{} & H \\
& I\arrow{ur}{}
\end{tikzcd}
\end{document}
答案2
这有点简化,我将绘图命令放入循环中foreach
。很难理解最终产品应该是什么样子。此外,颜色似乎是 PDF 查看器的问题,因为 SumatraPDF 没有出现此问题。所需的箭头名称是implies
,可以在库文档中找到arrows
。为了简化,我不想把它写得太简洁,但这当然是可能的。
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{matrix,arrows,decorations.pathmorphing}
\begin{document}
\begin{tikzpicture}[>=implies]
\matrix (m) [matrix of math nodes, nodes in empty cells, row sep=3em, column sep=3em,
text height=1.5ex, text depth=0.25ex]
{ & X & & \\
A & B & C & D \\
E & F & G & H \\
& I & & \\};
\foreach[remember=\x as \lastx (initially 1)] \x in {2,...,4}{
\draw[double,->] (m-2-\lastx) -- (m-2-\x);
\draw[double,->] (m-3-\lastx) -- (m-3-\x);
}
\foreach \x in {1,...,4}{\draw[double,->] (m-2-\x) -- (m-3-\x);}
\draw[double,->] (m-1-2) -- (m-2-3);
\draw[double,->] (m-2-1) -- (m-1-2);
\draw[double,->] (m-4-2) -- (m-3-3);
\draw[double,->] (m-3-1) -- (m-4-2);
\draw[double,->] (m-1-2) .. controls ([xshift=-1.2cm]m-1-1) and ([xshift=-1.2cm]m-4-1) .. (m-4-2);
\end{tikzpicture}
\end{document}
答案3
将箭头改为 $\Rightarrows$ 的一种方法是使用 tikz-cd,通过在边上添加 [交换图/Rightarrow]。以下代码是回答可以在以下网址找到tikzcd 手册(第 13 页)为五边形图。
代码与您的不同,但它给出了将边缘转换为 tikz-cd 的 Rightarrow 的基本思想。
\documentclass{article}
\usepackage{tikz-cd}
\begin{document}
\newlength{\edgelentgh}
\setlength{\edgelentgh}{3cm}
\[
\begin{tikzcd}[row sep={0cm,between origins},column sep={0cm,between origins}] %setting seperators to zero for easier manipulation
&[.3090169944\edgelentgh]
&[.5\edgelentgh] % above value times golden ratio
F'(U_2)\arrow{ddl}\arrow{ddr}\arrow{drr}
&[.5\edgelentgh]
&[.3090169944\edgelentgh]\\[.5877852523\edgelentgh]
F'(U_1)\arrow{urr}\arrow{rrrr}\arrow{dr}\arrow{drrr}
&&&& F'(U_3) \arrow{dlll}\arrow{dl}
\\[.9510565163\edgelentgh] % above value times golden ratio
&
F(V)\arrow{rr}
&&
F(W)
&
\end{tikzcd}
\]
% This example is given in the tikz-cd manual:
\begin{tikzpicture}[commutative diagrams/every diagram]
\node (P0) at (90:.8506508084\edgelentgh) {$F'(U_2)$};
\node (P1) at (90+72:.8506508084\edgelentgh) {$F'(U_1)$} ;
\node (P2) at (90+2*72:.8506508084\edgelentgh) {$F(V)$};
\node (P3) at (90+3*72:.8506508084\edgelentgh) {$F(W)$};
\node (P4) at (90+4*72:.8506508084\edgelentgh) {$F'(U_3)$};
%
\path[commutative diagrams/.cd, every arrow, every label]
(P0) edge[commutative diagrams/Rightarrow] node (P4)
(P3) edge[commutative diagrams/Rightarrow] node[swap] (P4)
(P1) edge[commutative diagrams/Rightarrow] node (P0)
(P1) edge[commutative diagrams/Rightarrow] node[swap] (P2)
(P2) edge[commutative diagrams/Rightarrow] (P3);
\end{tikzpicture}
\end{document}