我必须写相当长的链式复合体,例如
0\rightarrow A \rightarrow B \rightarrow C \rightarrow
ETC。
其中包含许多术语,我希望靠近页面侧面的箭头向后弯曲并指向新行,如您在第 31 页所见的那样这些笔记(推论 3.4.2)。我该怎么做?
答案1
最终版本在这里:
\documentclass{amsart}
\usepackage{tikz-cd}
\begin{document}
\begin{tikzcd}
0 \rar &H^0(U \cup V) \rar & H^0(U) \oplus H^0(V) \rar
\ar[draw=none]{d}[name=X, anchor=center]{}
& H^0(U \cap V) \ar[rounded corners,
to path={ -- ([xshift=2ex]\tikztostart.east)
|- (X.center) \tikztonodes
-| ([xshift=-2ex]\tikztotarget.west)
-- (\tikztotarget)}]{dll}[at end]{\partial} \\
{} & H^1(U \cap V) \rar & H^1(U) \oplus H^1(V) \rar
\ar[draw=none]{d}[name=Y, anchor=center]{}
& H^1(U \cap V) \ar[rounded corners,
to path={ -- ([xshift=2ex]\tikztostart.east)
|- (Y.center) \tikztonodes
-| ([xshift=-2ex]\tikztotarget.west)
-- (\tikztotarget)}]{dll}[at end]{\partial} \\
{} & \cdots \rar & H^i(U) \oplus H^i(V) \rar
\ar[draw=none]{d}[name=I, anchor=center]{}
& \cdots \ar[rounded corners,
to path={ -- ([xshift=2ex]\tikztostart.east)
|- (I.center) \tikztonodes
-| ([xshift=-2ex]\tikztotarget.west)
-- (\tikztotarget)}]{dll}[at end]{\partial} \\
{} & H^n(U \cup V) \rar & H^n(U) \oplus H^n(V) \rar & H^n(U \cap V) \rar & 0
\end{tikzcd}
\end{document}
改进
这项改进引入了一种双参数样式,将列中节点的宽度column width={<col>}{<content>}
设置为。 这不是最好的解决方案,因为用户需要输入列本身的最宽。人们肯定可以想到一种解决方案,使用文件保存最宽宽度,或者检查同一列中所有节点的锚点以检查哪些节点最大。text width
<col>
<content>
<content>
.aux
to path
.west
.east
现在to path
不需要手动放置辅助节点(以前是X
、Y
和),而是使用和I
之间的中间点。代码只是在这个中间点定义。代码是的无 版本。\tikztostart
\tikztotarget
@find halway
@aux
calc
($(\tikztostart)!.5!(\tikztotarget)$)
代码
\documentclass[tikz]{standalone}
\usepackage{tikz-cd}
\makeatletter
\tikzset{
commutative diagrams/column width/.style 2 args={
/tikz/commutative diagrams/matrix of math nodes maybe/.append style={
column #1/.append style={
every node/.append style={
align=center,
text width=\widthof{\iftikzcd@mathmode$\fi#2\iftikzcd@mathmode$\fi}}}}},
@find halfway/.code 2 args={%
\begingroup
\pgftransformshift{\pgfpointlineattime{.5}{\pgfpointanchor{#1}{center}}{\pgfpointanchor{#2}{center}}}%
\pgfnode{coordinate}{center}{}{@aux}{}%
\endgroup},
line break/.style={
every node/.append style={at end},
rounded corners, to path={
[@find halfway/.expanded={\tikztostart}{\tikztotarget}]
-- ([xshift=2ex]\tikztostart.east)
|- (@aux) \tikztonodes
-| ([xshift=-2ex]\tikztotarget.west)
-- (\tikztotarget)}}}
\makeatother
\begin{document}
\begin{tikzcd}[
column width={2}{H^n(U \cup V)},
column width={3}{H^n(U) \oplus H^n(V)},
column width={4}{H^n(U \cap V)}
]
0 \rar & H^0(U \cup V) \rar
& H^0(U) \oplus H^0(V) \rar
& H^0(U \cap V) \ar[line break]{dll}{\partial} \\
& H^1(U \cap V) \rar
& H^1(U) \oplus H^1(V) \rar
& H^1(U \cap V) \ar[line break]{dll}{\partial} & \cdots \rar
& H^i(U) \oplus H^i(V) \rar
& \cdots \ar[line break]{dll}{\partial} \\
& H^n(U \cup V) \rar
& H^n(U) \oplus H^n(V) \rar
& H^n(U \cap V) \rar
& 0
\end{tikzcd}
\end{document}