我有一个用 TikZ 和 align 环境编写的类别理论图形证明(感谢 Henri 的回答这个问题)。每行上的图表都有一个重复的特征,即标有“A”的垂直线。我希望这些线水平对齐。
\documentclass{article}
\usepackage{amsmath}
\usepackage{tikz}
\usetikzlibrary{knots}
\usetikzlibrary{positioning}
\usepackage{mathtools}
\begin{document}
\tikzset{dot/.style={circle,fill,inner sep=1pt},diagram/.style={knot=black,thick}}
\newcommand{\tikzb}[1]{\tikz[baseline=(B.base)]{#1}}
\newcommand{\qdim}[1]{\left<#1\right>}
\newcommand{\Aid}{\draw[diagram] (0,-1.5) -- node[right] (B) {A} (0,1.5);}
\newcommand{\braket}[2]{\left< #1 \vphantom{#2} \right|\left. \vphantom{#1} #2 \right>}
\pgfkeys{/encircle/.cd,label/.initial=$\Omega_{\mathcal{C}}$,angle/.initial=20}
\newcommand{\encircle}[2][]{%
\pgfkeys{/encircle/.cd,#1}
\draw[diagram] (1,0) arc (0:\pgfkeysvalueof{/encircle/angle}:1 and 0.4) node[above] {\pgfkeysvalueof{/encircle/label}} arc (\pgfkeysvalueof{/encircle/angle}:180:1 and 0.4);
#2
\draw[diagram] (-1,0) arc (-180:0:1 and 0.4);
}
\begin{align}
& & \tikzb{\draw[diagram] (0,-1.5) -- node[right] (B) {X} (0,1.5);}
\tikzb{\encircle{\Aid}}\\
& = \sum_{Y \in \Lambda_\mathcal{C}} \qdim{Y}
& \tikzb{\draw[diagram] (0,-1.5) -- node[right] (B) {X} (0,1.5);}
\tikzb{\encircle[label=Y]{\Aid}}
& \qquad \text{By the definition of $\Omega_{\mathcal{C}}$} \\
& = \sum_{\mathclap{\substack{Y \in \Lambda_\mathcal{C} \\ Z \in \Lambda_\mathcal{C} \\ \iota_i \in \mathcal{C}(Z, X \otimes Y) \\ \braket{\iota_i}{\iota_j} = \delta_{i,j}}}} \qdim{Y}\qdim{Z}
& \tikzb{
\draw[diagram] (-1,-1.5) to[out=90, in=245] node[left] {X} (-0.7,-0.3) coordinate[dot,label={right:$\iota_i^*$}] (A) to node[left] (B) {Z} (-0.7,0.3) coordinate[dot,label={right:$\iota_i$}] (C) to[out=115,in=270] (-1,1.5);
\draw[diagram] (1,0) to[out=90,in=65] (C);
\Aid
\draw[diagram] (A) to[out=295,in=270] (1,0) node[right] {Y};
}
& \qquad \text{Insertion of a further $\Omega_{\mathcal{C}}$}
\end{align}
\end{document}
您不一定需要knots
tikz 库来编译此代码。我尝试在 tikz 代码中添加 &,但无济于事。
答案1
也许这更像是一种解决方法,但我会将 Tikz 部分视为图像。然后我会将所有内容放入表格中,以使所有内容都整齐地排列在列中。
然而,按图像特征进行对齐很不方便,但可靠的手动方法是将空节点添加为绘图中最左侧的项目,相对于要对齐的特征进行定位。然后可以在表格列中将其左对齐,甚至可以在对齐中工作。
通过垂直定位对齐节点,您也可以根据需要很好地匹配基线。
编辑:示例已准备好——但请注意,我使用手动定位作为左停止点的空节点,只是因为我发现调整原始节点更容易
\documentclass{article}
\usepackage{amsmath}
\usepackage{tikz}
\usetikzlibrary{knots}
\usetikzlibrary{positioning}
\usepackage{mathtools}
\begin{document}
\tikzset{dot/.style={circle,fill,inner sep=1pt},diagram/.style={knot=black,thick}}
\newcommand{\tikzb}[1]{\tikz[baseline=(B.base)]{#1}}
\newcommand{\qdim}[1]{\left<#1\right>}
\newcommand{\Aid}{\draw[diagram] (0,-1.5) -- node[right] (B) {A} (0,1.5);}
\newcommand{\braket}[2]{\left< #1 \vphantom{#2} \right|\left. \vphantom{#1} #2 \right>}
\pgfkeys{/encircle/.cd,label/.initial=$\Omega_{\mathcal{C}}$,angle/.initial=20}
\newcommand{\encircle}[2][]{%
\pgfkeys{/encircle/.cd,#1}
\draw[diagram] (1,0) arc (0:\pgfkeysvalueof{/encircle/angle}:1 and 0.4) node[above] {\pgfkeysvalueof{/encircle/label}} arc (\pgfkeysvalueof{/encircle/angle}:180:1 and 0.4);
#2
\draw[diagram] (-1,0) arc (-180:0:1 and 0.4);
}
\begin{tabular}{lll}
& \tikzb{\draw[diagram] (0,-1.5) -- node[right] (B) {X} (0,1.5);}
\tikzb{\encircle{\Aid}}\\
$\displaystyle=\sum_{Y \in \Lambda_\mathcal{C}} \qdim{Y}$
& \tikzb{\draw[diagram] (0,-1.5) -- node[right] (B) {X} (0,1.5);}
\tikzb{\encircle[label=Y]{\Aid}}
& By the definition of $\Omega_{\mathcal{C}}$ \\
$\displaystyle=\sum_{\mathclap{\substack{Y \in \Lambda_\mathcal{C} \\ Z \in \Lambda_\mathcal{C} \\ \iota_i \in \mathcal{C}(Z, X \otimes Y) \\ \braket{\iota_i}{\iota_j} = \delta_{i,j}}}} \qdim{Y}\qdim{Z}$
& \tikzb{
\draw[diagram] (-1,-1.5) to[out=90, in=245] node[left] {X} (-0.7,-0.3) coordinate[dot,label={right:$\iota_i^*$}] (A) to node[left] (B) {Z} (-0.7,0.3) coordinate[dot,label={right:$\iota_i$}] (C) to[out=115,in=270] (-1,1.5);
\draw[diagram] (1,0) to[out=90,in=65] (C);
\Aid
\draw[diagram] (A) to[out=295,in=270] (1,0) node[right] {Y};
\node[draw=none,fill=none] at (-1.6,0) {};%this node is a left stop.
}
& Insertion of a further $\Omega_{\mathcal{C}}$
\end{tabular}
\end{document}
答案2
我只是在两张图片后面加了一些字距调整。当然,这需要手动干预。
\usepackage{mathtools}
\begin{document}
\tikzset{dot/.style={circle,fill,inner sep=1pt},diagram/.style={knot=black,thick}}
\newcommand{\tikzb}[1]{\tikz[baseline=(B.base)]{#1}}
\newcommand{\qdim}[1]{\left<#1\right>}
\newcommand{\Aid}{\draw[diagram] (0,-1.5) -- node[right] (B) {A} (0,1.5);}
\newcommand{\braket}[2]{\left< #1 \vphantom{#2} \right|\left. \vphantom{#1} #2 \right>}
\pgfkeys{/encircle/.cd,label/.initial=$\Omega_{\mathcal{C}}$,angle/.initial=20}
\newcommand{\encircle}[2][]{%
\pgfkeys{/encircle/.cd,#1}
\draw[diagram] (1,0) arc (0:\pgfkeysvalueof{/encircle/angle}:1 and 0.4) node[above] {\pgfkeysvalueof{/encircle/label}} arc (\pgfkeysvalueof{/encircle/angle}:180:1 and 0.4);
#2
\draw[diagram] (-1,0) arc (-180:0:1 and 0.4);
}
\begin{align}
& & \tikzb{\draw[diagram] (0,-1.5) -- node[right] (B) {X} (0,1.5);}
\tikzb{\encircle{\Aid}}\mkern12mu\\
& = \sum_{Y \in \Lambda_\mathcal{C}} \qdim{Y}
& \tikzb{\draw[diagram] (0,-1.5) -- node[right] (B) {X} (0,1.5);}
\tikzb{\encircle[label=Y]{\Aid}}\mkern16.5mu
& \qquad \text{By the definition of $\Omega_{\mathcal{C}}$} \\
& = \sum_{\mathclap{\substack{Y \in \Lambda_\mathcal{C} \\ Z \in \Lambda_\mathcal{C} \\ \iota_i \in \mathcal{C}(Z, X \otimes Y) \\ \braket{\iota_i}{\iota_j} = \delta_{i,j}}}} \qdim{Y}\qdim{Z}
& \tikzb{
\draw[diagram] (-1,-1.5) to[out=90, in=245] node[left] {X} (-0.7,-0.3) coordinate[dot,label={right:$\iota_i^*$}] (A) to node[left] (B) {Z} (-0.7,0.3) coordinate[dot,label={right:$\iota_i$}] (C) to[out=115,in=270] (-1,1.5);
\draw[diagram] (1,0) to[out=90,in=65] (C);
\Aid
\draw[diagram] (A) to[out=295,in=270] (1,0) node[right] {Y};
}
& \qquad \text{Insertion of a further $\Omega_{\mathcal{C}}$}
\end{align}
\end{document}
答案3
为了完整起见,我将根据 Chris H 的建议添加自己的解决方案。它在每个图像的相同坐标处添加一个空节点。坐标系对齐以将 A 置于原点,因此如果此节点是图像最右边的元素,则它就是图像要对齐的边框。这样,只需手动调整一个坐标即可将所有图像对齐到同一点。这对我来说尤其重要,因为实际校样覆盖了整个页面,所以我不想摆弄每一张图片。
\documentclass{article}
\usepackage{amsmath}
\usepackage{tikz}
\usetikzlibrary{knots}
\usetikzlibrary{positioning}
\usepackage{mathtools}
\begin{document}
\tikzset{dot/.style={circle,fill,inner sep=1pt},diagram/.style={knot=black,thick}}
\newcommand{\tikzb}[1]{\tikz[baseline=(B.base)]{#1}}
\newcommand{\qdim}[1]{\left<#1\right>}
\newcommand{\braket}[2]{\left< #1 \vphantom{#2} \right|\left. \vphantom{#1} #2 \right>}
\pgfkeys{/encircle/.cd,label/.initial=$\Omega_{\mathcal{C}}$,angle/.initial=20}
\newcommand{\encircle}[2][]{%
\pgfkeys{/encircle/.cd,#1}
\draw[diagram] (1,0) arc (0:\pgfkeysvalueof{/encircle/angle}:1 and 0.4) node[above] {\pgfkeysvalueof{/encircle/label}} arc (\pgfkeysvalueof{/encircle/angle}:180:1 and 0.4);
#2
\draw[diagram] (-1,0) arc (-180:0:1 and 0.4);
}
\newcommand{\tikzoffset}{\node at (1.63,0) {};}
\newcommand{\Aid}{\draw[diagram] (0,-1.5) -- node[right] (B) {A} (0,1.5); \tikzoffset}
\begin{align}
& & \tikzb{
\draw[diagram] (-1.2,-1.5) -- node[left] (B) {X} (-1.2,1.5);
\encircle{\Aid}
}\\
& = \sum_{\mathclap{Y \in \Lambda_\mathcal{C}}} \qdim{Y}
& \tikzb{
\draw[diagram] (-1.2,-1.5) -- node[left] (B) {X} (-1.2,1.5);
\encircle[label=Y]{\Aid}
}
& \qquad \text{By the definition of $\Omega_{\mathcal{C}}$} \\
& = \sum_{\mathclap{\substack{Y, Z \in \Lambda_\mathcal{C} \\ \iota_i \in \mathcal{C}(Z, X \otimes Y^*) \\ \braket{\iota_i}{\iota_j} = \delta_{i,j}}}} \qdim{Y}\qdim{Z}
& \tikzb{
\draw[diagram] (-1.2,-1.5) to[out=90, in=245] node[left] {X} (-0.7,-0.3) coordinate[dot,label={right:$\iota_i^*$}] (A) to node[left] (B) {Z} (-0.7,0.3) coordinate[dot,label={right:$\iota_i$}] (C) to[out=115,in=270] node[left] {X} (-1.2,1.5);
\draw[diagram] (1,0) to[out=90,in=65] (C);
\Aid
\draw[diagram] (A) to[out=295,in=270] (1,0) node[right] {Y};
}
& \qquad \text{Insertion of a further $\Omega_{\mathcal{C}}$}
\end{align}
\end{document}
同时我也改进/纠正了一些其他细节。