在 xymatrix 中圈出一个集合对象

在 xymatrix 中圈出一个集合对象

我有以下产生双复数的代码:

\begin{displaymath}
\xymatrix{
0 \ar[r] & \Omega^0_X \ar[d] \ar[r] & \Omega_X^1 \ar[r] \ar[d] & \ldots \ar[r] & \Omega_X^n \ar[d] \ar[r] & 0 \\ 
0 \ar[r] & C^0(\Omega^0_X) \ar[d] \ar[r] & C^0(\Omega_X^1) \ar[r] \ar[d] & \ldots \ar[r] & C^0(\Omega_X^n) \ar[d] \ar[r] & 0 \\
0 \ar[r] & C^1(\Omega^0_X) \ar[d] \ar[r] & C^1(\Omega_X^1) \ar[r] \ar[d] & \ldots \ar[r] & C^1(\Omega_X^n) \ar[d] \ar[r] & 0 \\
&   \vdots                       & \vdots                        & \ldots        & \vdots                        & \\
}\end{displaymath}

产生

在此处输入图片描述

我想从左下角到右上角画出每条对角线。我已决定(目前正在)按照 XYpic 手册操作,但通常情况下,可能为时已晚。

所以我的问题是,是否有可能按照描述的那样在 xymatrix/xypic 或 Tikz 中(尽管我对 Tikz 了解甚少)圈出元素(尽管我猜它更像是一个椭圆)?请参见下面的图片,了解一个绘制不佳的版本:

在此处输入图片描述

我在 XYpic 参考手册中找到了椭圆命令,但我对周围的代码不够熟悉,无法使用它。此外,我不确定是否可以将基本 XYpic 代码放入 xymatrix。作为部分答案,对任何一点的澄清都将非常有帮助。

答案1

这是一种切换到tikz-cd对于交换图并使用tikzmark库放置一些稍后用于绘制“矩形”的标记(特别注意,该图的语法是相同的):

\documentclass{article}
\usepackage{amsmath}
\usepackage{tikz-cd} 
\usetikzlibrary{tikzmark}

\begin{document}

\begin{tikzcd}[column sep=1cm,row sep=1cm]
0 \ar[r] & \tikzmark{startc}\Omega^0_X \ar[d] \ar[r] & \tikzmark{startb}\Omega_X^1 \ar[r] \ar[d] & \tikzmark{starta}\ldots \ar[r] & \Omega_X^n \ar[d] \ar[r] & 0 \\ 
\tikzmark{endc}0 \ar[r] & C^0(\Omega^0_X) \ar[d] \ar[r] & C^0(\Omega_X^1) \ar[r] \ar[d] & \ldots \ar[r] & C^0(\Omega_X^n) \ar[d] \ar[r] & 0 \\
\tikzmark{endb}0 \ar[r] & \tikzmark{enda}C^1(\Omega^0_X) \ar[d] \ar[r] & C^1(\Omega_X^1) \ar[r] \ar[d] & \ldots \ar[r] & C^1(\Omega_X^n) \ar[d] \ar[r] & 0 \\
&   \vdots                       & \vdots                        & \ldots        & \vdots                        & \\
\end{tikzcd}

\begin{tikzpicture}[remember picture,overlay]
\draw[rounded corners=20pt]
  ([xshift=-5pt,yshift=15pt]{pic cs:starta}) -- 
  ([xshift=50pt,yshift=15pt]pic cs:starta) --
  ([xshift=30pt,yshift=-15pt]pic cs:enda) --
  ([xshift=-30pt,yshift=-15pt]pic cs:enda) --
  cycle
  ;
\draw[rounded corners=20pt]
  ([xshift=-10pt,yshift=15pt]{pic cs:startb}) -- 
  ([xshift=42pt,yshift=15pt]pic cs:startb) --
  ([xshift=0pt,yshift=-15pt]pic cs:endb) --
  ([xshift=-48pt,yshift=-15pt]pic cs:endb) --
  cycle
  ;
\draw[rounded corners=20pt]
  ([xshift=-6pt,yshift=15pt]{pic cs:startc}) -- 
  ([xshift=42pt,yshift=15pt]pic cs:startc) --
  ([xshift=-6pt,yshift=-15pt]pic cs:endc) --
  ([xshift=-46pt,yshift=-15pt]pic cs:endc) --
  cycle
  ;
\end{tikzpicture}

\end{document}

在此处输入图片描述

根据您的需要调整使用的xshift和的值。yshift

另一种具有更好形状的可能性:

\documentclass{article}
\usepackage{amsmath}
\usepackage{tikz-cd} 
\usetikzlibrary{tikzmark}

\tikzset{
Enclose/.style={
  draw,
  opacity=0.2,
  line width=#1,
  line cap=round,
  color=gray
  }
}

\begin{document}


\begin{tikzpicture}[remember picture,overlay]
\draw[Enclose=30pt] ([xshift=10pt]pic cs:starta) -- ([xshift=15pt]pic cs:enda);
\draw[Enclose=30pt] ([xshift=5pt]pic cs:startb) -- ([xshift=-10pt]pic cs:endb);
\draw[Enclose=30pt] ([xshift=10pt]pic cs:startc) -- ([xshift=-10pt]pic cs:endc);
\end{tikzpicture}

\begin{tikzcd}[column sep=1cm,row sep=1cm]
0 \ar[r] & \tikzmark{startc}\Omega^0_X \ar[d] \ar[r] & \tikzmark{startb}\Omega_X^1 \ar[r] \ar[d] & \tikzmark{starta}\ldots \ar[r] & \Omega_X^n \ar[d] \ar[r] & 0 \\ 
\tikzmark{endc}0 \ar[r] & C^0(\Omega^0_X) \ar[d] \ar[r] & C^0(\Omega_X^1) \ar[r] \ar[d] & \ldots \ar[r] & C^0(\Omega_X^n) \ar[d] \ar[r] & 0 \\
\tikzmark{endb}0 \ar[r] & \tikzmark{enda}C^1(\Omega^0_X) \ar[d] \ar[r] & C^1(\Omega_X^1) \ar[r] \ar[d] & \ldots \ar[r] & C^1(\Omega_X^n) \ar[d] \ar[r] & 0 \\
&   \vdots                       & \vdots                        & \ldots        & \vdots                        & \\
\end{tikzcd}

\end{document}

在此处输入图片描述

代码需要运行三次才能稳定。

答案2

这可能是您想要的吗?circled定义了一个名为的新命令,它接受一个参数,通过tikz,您需要做的就是circled{object}

更新:tikzmark根据 OP 的新解释,通过 tikz 使用技能。

在此处输入图片描述

代码:已更新

\documentclass[12pt]{article}
\usepackage[margin=1cm,paper size={20cm,15cm}]{geometry}
\usepackage{tabularx,array}
\usepackage{amsmath,tikz}
\usepackage[all]{xy}
\usetikzlibrary{calc,positioning}
\thispagestyle{empty}

\newcommand{\tikzmark}[1]{\tikz[overlay,remember picture] \node[outer sep=0pt, inner sep=0pt] (#1) {};
}

%\newcommand*\circled[1]{\tikz[baseline=(char.base)]{
%    \node[shape=circle,draw,minimum width=2cm,inner sep=2pt] (char) {$#1$};}}

\begin{document}
\begin{displaymath}
\xymatrix{
0 \ar[r] & \tikzmark{d}\Omega^0_X \ar[d] \ar[r] & \Omega_X^1 \ar[r] \ar[d] & \ldots \ar[r] &\tikzmark{b}{\Omega_X^n}  \ar[d] \ar[r] & 0 \\ 
\tikzmark{c}0 \ar[r] & C^0(\Omega^0_X) \ar[d] \ar[r] & C^0(\Omega_X^1) \ar[r] \ar[d] & {\ldots} \ar[r] & C^0(\Omega_X^n) \ar[d] \ar[r] & 0 \\
0 \ar[r] & C^1(\Omega^0_X)\ar[d] \ar[r] & {C^1(\Omega_X^1)} \ar[r] \ar[d] & \ldots \ar[r] & C^1(\Omega_X^n) \ar[d] \ar[r] & 0 \\
&   \tikzmark{a}{\vdots}                      & \vdots                        & \ldots        &   \vdots                        & \\
}
\end{displaymath}

\begin{tikzpicture}[overlay, remember picture]
\draw [rounded corners=10pt]($(a.south west)+(-0.5,-0.5)$) -- ($(a.south west)+(-0.5,0.6)$) -- ($(b.east)+(0.6,0.6)$)-- ($(b.east)+(0.6,-0.5)$)--cycle;
\draw [rounded corners=10pt]($(c.south west)+(-0.5,-0.5)$) -- ($(c.south west)+(-0.5,0.6)$) -- ($(d.east)+(0.6,0.6)$)-- ($(d.east)+(0.6,-0.5)$)--cycle;
\end{tikzpicture}
\end{document}

在此处输入图片描述

代码

\documentclass[12pt]{article}
\usepackage[margin=1cm,paper size={20cm,15cm}]{geometry}
\usepackage{tabularx,array}
\usepackage{amsmath,tikz}
\usepackage[all]{xy}
\thispagestyle{empty}
\newcommand*\circled[1]{\tikz[baseline=(char.base)]{
    \node[shape=circle,draw,minimum width=2cm,inner sep=2pt] (char) {$#1$};}}

\begin{document}
\begin{displaymath}
\xymatrix{
0 \ar[r] & \Omega^0_X \ar[d] \ar[r] & \Omega_X^1 \ar[r] \ar[d] & \ldots \ar[r] & \circled{\Omega_X^n} \ar[d] \ar[r] & 0 \\ 
0 \ar[r] & C^0(\Omega^0_X) \ar[d] \ar[r] & C^0(\Omega_X^1) \ar[r] \ar[d] & \circled{\ldots} \ar[r] & C^0(\Omega_X^n) \ar[d] \ar[r] & 0 \\
0 \ar[r] & C^1(\Omega^0_X)\ar[d] \ar[r] & \circled{C^1(\Omega_X^1)} \ar[r] \ar[d] & \ldots \ar[r] & C^1(\Omega_X^n) \ar[d] \ar[r] & 0 \\
&   \circled{\vdots}                      & \vdots                        & \ldots        &   \vdots                        & \\
}
\end{displaymath}
\end{document}

答案3

仅包含tikz

在此处输入图片描述

\documentclass[tikz,margin=2pt]{standalone}
\usepackage{}
\usetikzlibrary{calc,fit}

\begin{document}

\begin{tikzpicture}[x=2cm,y=-1.5cm,>=stealth]

\foreach \y [count=\Y from 0] in
    {{0,\Omega^0_X,\Omega_X^1,\ldots,\Omega_X^n ,0},
    {0,C^0(\Omega^0_X),C^0(\Omega_X^1),\ldots,C^0(\Omega_X^n),0},
    {0,C^1(\Omega^0_X),C^1(\Omega_X^1),\ldots,C^1(\Omega_X^n),0},
    {,\vdots,\vdots,\ldots,\vdots,}} {%
    \foreach \x [count=\X from 0] in \y 
    {%
    \node[inner sep=5pt] (\X\Y) at (\X,\Y) {$\x$} ;
    }}

\foreach \y in {0,...,3}
\foreach \x [count=\i from 1] in {0,...,4} {%
    \draw[->] (\x\y) -- (\i\y); 
    }

\foreach \x in {0,...,5}
\foreach \y [count=\i from 1] in {0,...,2} {%
    \draw[->] (\x\y) -- (\x\i); 
    }

\node[draw=red, rounded corners=6pt, rotate fit=-50, inner sep =7pt, fit=(10) (01)] {};
\node[draw=red, rounded corners=6pt, rotate fit=-50, inner sep =1pt, fit=(20) (11) (02)] {};
\node[draw=red, rounded corners=6pt, rotate fit=-50, inner sep =1pt, fit=(12) (21) (30)] {};
\end{tikzpicture}

\end{document}

相关内容