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s1LDQsIiIsMSx7ImNvbG91ciI6WzAsNjAsNjBdLCJzdHlsZSI6eyJoZWFkIjp7Im5hbWUiOiJub25lIn19fV0sWzgsMywiIiwxLHsiY29sb3VyIjpbMCw2MCw2MF0sInN0eWxlIjp7ImhlYWQiOnsibmFtZSI6Im5vbmUifX19XSxbMCw5LCIiLDEseyJjb2xvdXIiOlswLDYwLDYwXSwic3R5bGUiOnsiaGVhZCI6eyJuYW1lIjoibm9uZSJ9fX1dLFs5LDQsIiIsMSx7ImNvbG91ciI6WzAsNjAsNjBdLCJzdHlsZSI6eyJoZWFkIjp7Im5hbWUiOiJub25lIn19fV0sWzksNywiIiwxLHsiY29sb3VyIjpbMCw2MCw2MF0sInN0eWxlIjp7ImhlYWQiOnsibmFtZSI6Im5vbmUifX19XV0=
\[\begin{tikzcd}[cramped,sep=tiny]
&&&&&&& {v_2} \\
\\
\\
{v_1} &&&&&&& {v_7} &&&&&&& {v_3} \\
&&& {v_6} &&&&&&&& {v_8} \\
\\
\\
\\
&&&&& {v_{10}} &&&& {v_9} \\
\\
\\
&&&& {v_5} &&&&&& {v_4}
\arrow[color={rgb,255:red,214;green,92;blue,92}, no head, from=1-8, to=4-1]
\arrow[color={rgb,255:red,214;green,92;blue,92}, no head, from=1-8, to=4-8]
\arrow[color={rgb,255:red,214;green,92;blue,92}, no head, from=4-1, to=5-4]
\arrow[color={rgb,255:red,214;green,92;blue,92}, no head, from=9-6, to=12-5]
\arrow[color={rgb,255:red,214;green,92;blue,92}, no head, from=4-1, to=12-5]
\arrow[color={rgb,255:red,214;green,92;blue,92}, no head, from=9-10, to=12-11]
\arrow[color={rgb,255:red,214;green,92;blue,92}, no head, from=12-5, to=12-11]
\arrow[color={rgb,255:red,214;green,92;blue,92}, no head, from=9-6, to=4-8]
\arrow[color={rgb,255:red,214;green,92;blue,92}, no head, from=4-8, to=9-10]
\arrow[color={rgb,255:red,214;green,92;blue,92}, no head, from=5-4, to=5-12]
\arrow[color={rgb,255:red,214;green,92;blue,92}, no head, from=9-6, to=5-12]
\arrow[color={rgb,255:red,214;green,92;blue,92}, no head, from=9-10, to=5-4]
\arrow[color={rgb,255:red,214;green,92;blue,92}, no head, from=1-8, to=4-15]
\arrow[color={rgb,255:red,214;green,92;blue,92}, no head, from=4-15, to=5-12]
\arrow[color={rgb,255:red,214;green,92;blue,92}, no head, from=4-15, to=12-11]
\end{tikzcd}\]
答案1
quiver 软件/网站并不是真正开始使用 TikZ-CD 的最佳选择,它相当冗长。图书馆手册相当简短并且有例子。
这是相同的图表,\ar
其中单元格内部的行符合目标规范,没有不必要的空行和空列。
看起来不太好。TikZ-CD 不是此图表的最佳工具。
我认为以圆形方式放置节点要好得多,这是我在其他两个图中通过graphs
库。
第一个图仅使用了graphs.standard
库的子图,但是在这里不容易为各个节点指定颜色(需要一个小错误修正),但您可以按照相同的手册操作,只需像往常一样添加类似内容[blue]
即可[draw=red]
。
代码
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{cd, graphs.standard}
\definecolor{Red}{RGB}{214,92,92}
\begin{document}
\[
\begin{tikzcd}[column sep=.25em, row sep=1em, arrows={dash, Red}]
& & & & v_2 \ar[d] \ar[dllll] \ar[drrrr] \\
v_1 \ar[dr] \ar[dddrr]
& & & & v_7 \ar[ddl]\ar[ddr]
& & & & v_3 \ar[dl] \ar[dddll] \\
& |[blue]| v_6 \ar[rrrrrr] \ar[rrrrd]
& & & & & & v_8 \ar[dllll] \\
& & & v_{10}
& & v_9 \\
& & |[draw=red]| v_5 \ar[ru]\ar[rrrr]
& & & & v_4 \ar[lu]
\end{tikzcd}
\]
\[
\tikz\graph[
edges=Red, simple, radius=1.5cm,
clockwise=5, phase=90+360/5,
typeset=$v_{\tikzgraphnodename}$]{
subgraph K_n[V={6, ..., 10}] --
subgraph C_n[n=5]; % n = 5 is the same as V = {1, ..., 5}
subgraph C_n[V={6, ..., 10}, -!-]% remove the cycle, needs simple
};
\]
\[
\tikz\graph[
edges=Red, simple, radius=1.5cm,
clockwise=5, phase=90+360/5,
typeset=$v_{\tikzgraphnodename}$]{
{[clique] 6[blue], 7, 8, 9, 10} --
{[cycle] 1, 2, 3, 4, 5[draw=red]},
subgraph C_n[V={6, ..., 10}, -!-]% remove the cycle, needs simple
};
\]
\end{document}