我想要绘制如下的共边图:
但可能更复杂。为此,我使用了tqft
。但是传入和传出的边界组件应该等距且对齐。我真正想要的是以下内容:
假设有传入边界分量1,2,...,n
和传出边界分量1',2', ...,n'
(等距且对齐),这些分量的位置是预先固定的;绘制连接边界分量的共边线{1,4}, {2,3,4',5'}, {1',3',6'}
等。任何提示都将不胜感激。
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{tqft}
\begin{document}
\begin{tikzpicture}
\pic[
tqft,
incoming boundary components=2,
outgoing boundary components=2,
draw,
at={(1,0)},
name=a,
every outgoing lower boundary component/.style={draw},
offset=1,
cobordism height=3cm,
];
\pic[tqft,
incoming boundary components=2,
outgoing boundary components=0,
draw,
name=b,
];
\pic[tqft,
incoming boundary components=2,
outgoing boundary components=0,
draw,
at={(4.5,0)},
name=c,
];
\pic[tqft,
incoming boundary components=0,
outgoing boundary components=3,
draw,
name=d,
every outgoing lower boundary component/.style={draw},
at={(0,-1)},
];
\pic[tqft,
incoming boundary components=0,
outgoing boundary components=1,
draw,
name=e,
every outgoing lower boundary component/.style={draw},
at={(6.5,-1)},
];
\end{tikzpicture}
\end{document}
答案1
这看起来是 tqft 库的一个非常有用的功能。我已经尝试实现它了,我想知道在将它推送到 CTAN 之前它是否“在野外”有效。您可以从以下位置获取该软件包github,下载文件tqft.dtx
并运行tex tqft.dtx
以生成包文件。将它们放在 TeX 可以找到的地方,然后尝试以下代码。
\documentclass{standalone}
%\url{https://tex.stackexchange.com/q/312405/86}
\usepackage{tikz}
\usetikzlibrary{tqft}
\begin{document}
\begin{tikzpicture}[
tqft,
every outgoing boundary component/.style={fill=blue!50},
outgoing boundary component 3/.style={fill=none,draw=red},
every incoming boundary component/.style={fill=green!50},
every lower boundary component/.style={draw,ultra thick, dashed},
every upper boundary component/.style={draw,purple},
cobordism/.style={fill=red!50},
cobordism edge/.style={draw},
genus=3,
hole 2/.style={ultra thick, blue},
view from=incoming,
anchor=between incoming 1 and 2
]
\pic[name=a,tqft,
incoming boundary components=5,
skip incoming boundary components={2,4},
outgoing boundary components=7,
skip outgoing boundary components={2,3,5},
offset=-.5];
\begin{scope}[every pin edge/.style={<-}]
\foreach \anchor/\ang in {
hole 1/-90,
hole 2/90,
hole 3/-90,
incoming boundary 3/90,
outgoing boundary 4/-90,
between last incoming and last outgoing/0,
between first incoming and first outgoing/180,
between incoming 1 and 3/90,
between outgoing 1 and 4/-90,
between outgoing 4 and 6/-90
} {
\node[pin=\ang:\anchor,at=(a-\anchor),inner sep=0pt] {};
}
\draw[<-] (0,0) -- ++(0,3);
\end{scope}
\end{tikzpicture}
\end{document}
上面演示了两个新的键:
skip incoming boundary components={2,4}
skip outgoing boundary components={2,3,5}
对于这两组边界组件,组件数量(由incoming boundary components=5
和设定outgoing boundary components=7
)决定了可用的边界槽总数。然后,新键会指定要忽略哪些槽。因此,在上述共边系统中,实际上只有 3 个传入边界组件,因为第 2 个和第 4 个被忽略了。请注意,锚点是根据间隙定义的,因此边界组件被标记为1
、3
和5
。
上述代码生成了下图。
欢迎评论、提出错误和功能请求 - 可以在这里或在 github 上。
为了完整起见,这里是我对您的原始图片的渲染,其中所有边界组件均已对齐。
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric,tqft}
\usepackage{tqft}
\tikzset{
tqft/use nodes=false,
}
\begin{document}
\begin{tikzpicture}[
tqft,
every outgoing boundary component/.style={fill=blue!50},
outgoing boundary component 3/.style={fill=none,draw=red},
every incoming boundary component/.style={fill=green!50},
every lower boundary component/.style={draw,ultra thick, dashed},
every upper boundary component/.style={draw,purple},
cobordism/.style={fill=red!50},
cobordism edge/.style={draw},
view from=incoming,
cobordism height=4cm,
]
\begin{scope}[every node/.style={rotate=90}]
\pic[name=a,
tqft,
incoming boundary components=3,
skip incoming boundary components=2,
outgoing boundary components=0
];
\pic[name=b,
tqft,
incoming boundary components=3,
skip incoming boundary components=2,
outgoing boundary components=3,
skip outgoing boundary components=2,
offset=1,
anchor=incoming boundary 1,
at=(a-incoming boundary 2)
];
\pic[name=c,
tqft,
incoming boundary components=2,
outgoing boundary components=0,
anchor={(0,0)},
at=(b-incoming boundary 3)
];
\pic[name=d,
tqft,
incoming boundary components=0,
outgoing boundary components=4,
skip outgoing boundary components=3,
at=(a-incoming boundary 1)
];
\pic[name=e,
tqft,
incoming boundary components=0,
outgoing boundary components=1,
at=(c-incoming boundary 2)
];
\end{scope}
\end{tikzpicture}
\end{document}