在 tikz-cd 中改变列和行的宽度

在 tikz-cd 中改变列和行的宽度

我使用 tikz-cd 创建了下图

\begin{tikzcd}
S_E \arrow[dddd, bend right, two heads] \arrow[ddrrr, bend left, two heads, tail] & & & \\ 
&   E \arrow[dd, dash,swap, "G"] \arrow[dr, dash, "\langle\sigma\rangle"]   &   & \\ 
&   &   L \arrow[dl, dash] &    S_L\arrow[d, phantom, "{\cap}"]^\prime \\ 
&   K   & & S_L \\
S_K &   &   &  
\end{tikzcd}

在此处输入图片描述

我希望图表的第一列和最后一行比其他列和行更窄,这样,例如,S_E 直接出现在 E 的左上方,仅有一个很小的间隙,但保持“内部”图表的尺寸不变。

有没有一种使用 tikz-cd 的简单方法可以做到这一点?

答案1

正如我刚刚从符号 1,您可以手动修改每列或每行的分隔符。只需执行以下操作:

% arara: pdflatex

\documentclass{article}
\usepackage{tikz-cd}

\begin{document}
\begin{tikzcd}
    S_E \arrow[dddd, bend right, two heads] \arrow[ddrrr, bend left, two heads, tail] &[-25pt] & &[-25pt] \\[-15pt] 
     & E \arrow[dd, dash,swap, "G"] \arrow[dr, dash, "\langle\sigma\rangle"] & & \\ 
     & &   L \arrow[dl, dash] & S_L\arrow[d, phantom, "{\cap}"]^\prime \\ 
     & K   & & S_L \\[-15pt]
    S_K & & &  
\end{tikzcd}
\end{document}

在此处输入图片描述

答案2

您可以直接使用 TikZ 的所有功能和灵活性,但风格如下tikz-cd

\documentclass{article}
\usepackage{tikz-cd}
\usetikzlibrary{positioning,calc}
\usepackage{amsmath}

\begin{document}

With \texttt{tikz-cd}:
\[
\begin{tikzcd}
S_E
  \arrow[dddd, bend right, two heads] 
  \arrow[ddrrr, bend left, two heads, tail] & & & \\ 
 &  E \arrow[dd, dash,swap, "G"] \arrow[dr, dash, "\langle\sigma\rangle"]   &   & \\ 
&   &   L \arrow[dl, dash] &    S_L\arrow[d, phantom, "{\cap}"]^\prime \\ 
&   K   & & S_L \\
S_K &   &   &
\end{tikzcd}
\]
With \texttt{tikz} using the \texttt{tikz-cd} style:
\[
\begin{tikzpicture}[commutative diagrams/every diagram]
\matrix[
  matrix of math nodes,
  name=mat, 
  commutative diagrams/every cell
] 
{
E \\
& L \\
K \\
};
\path[commutative diagrams/.cd, every arrow, every label]
  (mat-1-1) edge[commutative diagrams/dash,swap,"$G$"] (mat-3-1)
  (mat-3-1) edge[commutative diagrams/dash] (mat-2-2)
  (mat-2-2) edge[commutative diagrams/dash,swap,"$\langle\sigma\rangle$"] (mat-1-1);
\node[above left= 5pt and 5pt of mat-1-1] 
  (se)
  {$S_E$};  
\node[below left= 5pt and 5pt of mat-3-1] 
  (sk)
  {$S_K$};  
\node[right= 5pt and 5pt of mat-2-2] 
  (spl)
  {$S'_L$};
\node
  (sl)
  at (spl|-mat-3-1)
  {$S_L$};
\path[commutative diagrams/.cd, every arrow, every label]
  (se) edge[bend right,commutative diagrams/two heads] (sk);    
\path[commutative diagrams/.cd, every arrow, every label]
  (se) edge[bend left,commutative diagrams/two heads,commutative diagrams/tail] (spl);
\node
  at ( $ (spl)!0.5!(sl) $ )
  {$\cap$};
\end{tikzpicture}
\]

\end{document}

在此处输入图片描述

相关内容