% Regression test for \stgroup and \stcallout. % - a group over one stack (the three sheets are one composite object), % - a group over two adjacent shards (the pair is one partitioned parent), % - a side card hanging off the right edge of each band. % No absolute coordinate appears anywhere in this figure. % ../scripts/build.sh group-callout.tex \documentclass[border=10pt]{standalone} \usepackage[cjk]{supertensor} \stsetrole{act}{stTeal} \stsetrole{w}{stOrange} \stsetrole{q}{stTeal} \stsetrole{k}{stViolet} \stsetrole{v}{stCoral} \stdim{T}{7} \stdim{d}{5} \stdim{dh}{3} \begin{document} \begin{tikzpicture} \ststage{S1}{一、分组框:把已经排好的面命名为一个复合对象} \strow{R1}{T} \stface[role=act, bracket=true]{X}{}{T}{d} \stlink{l1}{三路投影} \stgroup[role=q]{QG} \ststack[role=q]{Q}{}{T}{dh}{3} \stgroupend \stgroup[role=k]{KG} \ststack[role=k]{K}{}{T}{dh}{3} \stgroupend \stgroup[role=v]{VG} \ststack[role=v]{V}{}{T}{dh}{3} \stgroupend \strowend \stcaption{X}{$\mathbf X$}{$T\times d$} \stcaption{QG}{$\mathbf q$}{$h\times T\times d_h$} \stcaption{KG}{$\mathbf k$}{$h\times T\times d_h$} \stcaption{VG}{$\mathbf v$}{$h\times T\times d_h$} \stcallout{N1}{4.2cm}{R1}{分组框在说什么}% {外框与里面的面同色,因为它圈的是同一个对象的多头视图,不是一个新张量。 框的内边距计入行的包围盒,所以下面的符号轨仍然从框底起算。} \ststage{S2}{二、分组框圈住两片相邻的分片,标注它们合起来是谁} \strow{R2}{T} \stface[role=act]{H}{}{T}{d} \stglyph{m2}{$\times$} \stgroup[role=w, pad=2.2mm]{WG} \stcol{Wc}{d} \stface[role=w]{Wa}{}{dh}{T} \stface[role=w, gap=0pt]{Wb}{}{2}{T} \stcolend \stgroupend \stlink{l2}{} \stface[role=q, bracket=true]{Z}{}{T}{T} \strowend \stcaption{H}{$\mathbf H$}{$T\times d$} \stcaption{WG}{$\mathbf W$}{$d\times T$} \stcaption{Z}{$\mathbf Z$}{$T\times T$} \stcallout{N2}{4.2cm}{R2}{一行一张卡}% {同一个 band 上挂两张卡会被 lint 拒绝:并排的说明卡是仪表盘,不是图。} \sttopformula{F}{$\displaystyle \mathbf Z=\mathbf H\,\mathbf W,\qquad \mathbf W=\begin{bmatrix}\mathbf W_a\\ \mathbf W_b\end{bmatrix}$} \stbbox{all} \stmeaningbox{mb}{17cm}{all} {$T$ 序列长,$d$ 模型维,$d_h$ 头宽,$h$ 头数} {} {分组框是横向的子流:成员写在块里,所以它只能圈住相邻的对象; 两侧的内边距各占一份宽度,箭头也接在外框上而不是成员上—— 否则连接线会穿过一个并非自己端点的框。 说明卡挂在 band 右侧,并把纵向游标压到自己底边以下,所以卡片过高只会撑开空白, 不会压住下一段。} \end{tikzpicture} \end{document}