我的图表对齐有问题,我不知道如何使前两个有向图与“=”对齐,并与左括号(“{”)对齐。我的代码如下
\documentclass[12pt]{report}
\usepackage{tikz}
\usetikzlibrary{calc}
\begin{document}
\begin{center}
\begin{tikzpicture}[thick]
\node (p0) at ( -2.3,0.25) {};
\node (p1) at ( 0, 0) {};
\node (p2) at ( 0.8,-0.2) {$i$};
\node (p3) at ( 2,0) {};
\node (p4) at ( 0,0.6) {};
\node (p5) at ( 1.8,0.8) {$j$};
\node (p6) at ( 2,0.6) {};
\node (p7) at ( 2.2,0.3) {$\cdot$};
\node (p8) at ( 2.4,0) {};
\node (p9) at ( 3.5,-0.2) {$k$};
\node (p10) at ( 4.4,0) {};
\node (p11) at ( 2.4,0.6) {};
\node (p12) at ( 2.8,0.8) {$l$};
\node (p13) at ( 4.4,0.6) {};
\node (p14) at (4.6,-0.3){=};
\begin{scope}
\draw (p1) -- (p3);
\draw (p4) -- (p6);
\draw [ shorten <=-0.08cm, shorten >=-0.15cm, -latex](p2) -- (p5);
\draw (p8) -- (p10);
\draw (p11) -- (p13);
\draw [ shorten <=-0.08cm, shorten >=-0.15cm, -latex](p9) -- (p12);
\end{scope}
\end{tikzpicture}$
\left\{
\begin{array}{c l}
{
\begin{tikzpicture}[thick]
\node (p1) at ( 0, -1) {};
\node (p3) at ( 3,-1) {};
\node (p4) at ( 0,0) {};
\node (p6) at ( 3,0) {};
\node (p7) at ( 0,1) {};
\node (p9) at ( 3,1) {};
\node (p2) at ( 1, -1.2) {$i$};
\node (p5) at ( 2,0) {};
\node (p10)at (2.05,-0.2){};
\node (p8) at ( 1.5,1.2) {$l$};
\node (p11)at (3.3, 0){=};
\node (p12)at (3.6, -0.5){};
\node (p13)at (4.6, -0.7){$i$};
\node (p14)at (6.6, -0.5){};
\node (p15)at (3.6, 0.5){};
\node (p16)at (5.1, 0.7){$l$};
\node (p17)at (6.6, 0.5){};
\node (p18)at (7.5, 0){si j=k};
\begin{scope}
\draw (p1) -- (p3);
\draw (p4) -- (p6);
\draw (p7) -- (p9);
\draw [ shorten <=-0.08cm, shorten >=-0.15cm, -latex](p2) -- (p5);
\draw [ shorten <=0.02cm, shorten >=-0.10cm, -latex](p10) -- (p8);
\draw (p12) -- (p14);
\draw (p15) -- (p17);
\draw [shorten <=-0.08cm, shorten >=-0.1cm, -latex](p13) -- (p16);
\end{scope}
\end{tikzpicture}
} \\
\\
0,$ \hspace{16mm} en otro caso$\\
\\
\end{array}
\right.
$
\end{center}
\end{document}
总之,我想要的是以下内容:(我编辑了上面的图片来绘制所需的图表)
答案1
简短的回答是,如果你添加baseline=(current bounding box.center)
到你的tikzpicture
环境中,那么它们将垂直居中在它们的中点附近,这样你的方程式就应该正确对齐。
事实上,对于您的示例,这并不完全有效,因为您以一种不寻常的方式排版。首先,显示的方程式应放在环境内equation
或内部\[...\]
(而不是放在使用 排版的居中方程式内)$...$
。其次,像这样具有多个分支的方程式最好使用cases
来自数学包。进行这些更改将得到上图,代码如下所示:
\documentclass[12pt]{report}
\usepackage{amsmath}
\usepackage{tikz}
\usetikzlibrary{calc}
\begin{document}
\[
\begin{tikzpicture}[thick,baseline=(current bounding box.center)]
\node (p0) at ( -2.3,0.25) {};
\node (p1) at ( 0, 0) {};
\node (p2) at ( 0.8,-0.2) {$i$};
\node (p3) at ( 2,0) {};
\node (p4) at ( 0,0.6) {};
\node (p5) at ( 1.8,0.8) {$j$};
\node (p6) at ( 2,0.6) {};
\node (p7) at ( 2.2,0.3) {$\cdot$};
\node (p8) at ( 2.4,0) {};
\node (p9) at ( 3.5,-0.2) {$k$};
\node (p10) at ( 4.4,0) {};
\node (p11) at ( 2.4,0.6) {};
\node (p12) at ( 2.8,0.8) {$l$};
\node (p13) at ( 4.4,0.6) {};
\begin{scope}
\draw (p1) -- (p3);
\draw (p4) -- (p6);
\draw [ shorten <=-0.08cm, shorten >=-0.15cm, -latex](p2) -- (p5);
\draw (p8) -- (p10);
\draw (p11) -- (p13);
\draw [ shorten <=-0.08cm, shorten >=-0.15cm, -latex](p9) -- (p12);
\end{scope}
\end{tikzpicture}
=\begin{cases}
\begin{tikzpicture}[thick,baseline=(current bounding box.center)]
\node (p1) at ( 0, -1) {};
\node (p3) at ( 3,-1) {};
\node (p4) at ( 0,0) {};
\node (p6) at ( 3,0) {};
\node (p7) at ( 0,1) {};
\node (p9) at ( 3,1) {};
\node (p2) at ( 1, -1.2) {$i$};
\node (p5) at ( 2,0) {};
\node (p10)at (2.05,-0.2){};
\node (p8) at ( 1.5,1.2) {$l$};
\node (p11)at (3.3, 0){=};
\node (p12)at (3.6, -0.5){};
\node (p13)at (4.6, -0.7){$i$};
\node (p14)at (6.6, -0.5){};
\node (p15)at (3.6, 0.5){};
\node (p16)at (5.1, 0.7){$l$};
\node (p17)at (6.6, 0.5){};
%\node (p18)at (7.5, 0){si j=k};
\begin{scope}
\draw (p1) -- (p3);
\draw (p4) -- (p6);
\draw (p7) -- (p9);
\draw [ shorten <=-0.08cm, shorten >=-0.15cm, -latex](p2) -- (p5);
\draw [ shorten <=0.02cm, shorten >=-0.10cm, -latex](p10) -- (p8);
\draw (p12) -- (p14);
\draw (p15) -- (p17);
\draw [shorten <=-0.08cm, shorten >=-0.1cm, -latex](p13) -- (p16);
\end{scope}
\end{tikzpicture} &\text{si }j=k\\
0,&\text{en otro caso}\\
\end{cases}
\]
\end{document}
最后,你使用的tikz
确实很冗长,可以简化很多。下面是我可能这样做的方法。事实证明,使用当前边界来设置基线不再那么有效,因为标签为 tikz 环境提供了一些“下方”的额外空间,因此我使用坐标 手动设置基线bl
。
\tikzset{baseline=(bl.base), draw/.append style={thick}}
\[ \begin{tikzpicture}
\coordinate(bl) at (1,0.4); % set baseline
\draw(0,0)--+(2,0);
\draw(0,1)--+(2,0);
\draw[-latex](0.6,0)node[below]{$i$}--(1.6,1)node[above]{$j$};
\node at (2.3,0.5){$\cdot$};
\draw(2.6,0)--+(2,0);
\draw(2.6,1)--+(2,0);
\draw[-latex](4.2,0)node[below]{$k$}--(3.6,1)node[above]{$l$};
\end{tikzpicture}
= \begin{cases}\space
\begin{tikzpicture}
\coordinate(bl) at (1,0.9); % set baseline
\draw(0,0)--+(2,0);
\draw(0,1)--+(2,0);
\draw(0,2)--+(2,0);
\draw[-latex](0.6,0)node[below]{$i$}--(1.6,1);
\draw[-latex](1.6,1)--(1,2)node[above]{$l$};
\end{tikzpicture}
=
\begin{tikzpicture}
\coordinate(bl) at (1,0.4); % set baseline
\draw(0,0)--+(2,0);
\draw(0,1)--+(2,0);
\draw[-latex](0.6,0)node[below]{$i$}--(1,1)node[above]{$l$};
\end{tikzpicture},
&\text{si }j=k\\
0,&\text{en otro caso}\\
\end{cases}
\]
线条之间的空间比您原来的要大,因此您可能需要对此进行调整。我还使点k
和j
它们的线条之间的距离相同,以便案例环境中的第一个图表是正确的。这是此代码生成的结果: