括号内为 tikz 节点(例如:“{text}”而不仅仅是“text”)

括号内为 tikz 节点(例如:“{text}”而不仅仅是“text”)

我在 Tikz 上绘制了以下图形:

在此处输入图片描述

其 MWE 为:

\begin{tikzpicture}
\node[text width=2.65cm,text centered] (R) at (-3,0) {Radical ideals of $A$};
\node[text width=2.8cm, text centered] (C) at (3,0) {Closed subsets of $\operatorname{Spec} A$};
\draw[->,transform canvas={yshift=0.15cm}] (R) -- (C) node[midway,above]{$V(\cdot)$};
\draw[<-,transform canvas={yshift=-0.15cm}] (R) -- (C) node[midway,below]{$I(\cdot)$};
\end{tikzpicture}

它看起来很棒,但我希望在节点周围加上花括号,就好像它们是集合一样(在数学意义上),并且我希望箭头稍微大一些(就像函数箭头$\to$一样)。

我该如何做呢?

答案1

我在下面的代码中用样式包装了内容,但这不是必需的。

节点文本和括号之间有这么多空气的原因在于text width节点,可以通过各种方式进行修改,例如通过使用\node[align=center] (R) at (-3,0) {Radical\\ideals of $A$};,然后节点的宽度只与最长的线一样宽。

在此处输入图片描述

\documentclass[border=1cm]{standalone}
\usepackage{amsmath}
\usepackage{tikz}
\usetikzlibrary{decorations.pathreplacing, arrows.meta}
\begin{document}
\begin{tikzpicture}[
  Brace/.style={
     thick,
     decoration={ % define decoration
        brace,
        amplitude=5pt % height of curl
        },
     decorate % activate decoration
  },
  FuncArrow/.style={ % style for the lines
    -{To[length=3pt]}, % add arrow tip
    shorten >=8pt, shorten <=8pt % shorten the lines a bit so they don't crash with the braces
    }
]
 
\node[text width=2.65cm,text centered] (R) at (-3,0) {Radical ideals of $A$};
\node[text width=2.8cm, text centered] (C) at (3,0) {Closed subsets of $\operatorname{Spec} A$};

% modified the style here, and swapped the drawing coordinate order of the second one
\draw[FuncArrow,transform canvas={yshift=0.15cm}] (R) -- (C) node[midway,above]{$V(\cdot)$};
\draw[FuncArrow,transform canvas={yshift=-0.15cm}] (C) -- (R) node[midway,below]{$I(\cdot)$};


\foreach \nodename in {R,C} { % draw braces for both nodes
% the order of the coordinates matter, one is drawn from north to south, the other from south to north
% (there is a mirror option for the brace decoration, but that would need two different decorations I think)
\draw [Brace] (\nodename.north east) -- (\nodename.south east);
\draw [Brace] (\nodename.south west) -- (\nodename.north west);
}
\end{tikzpicture}
\end{document}

答案2

添加到你的序言中

\usetikzlibrary{decorations.pathreplacing}

并在代码末尾的 endtikzpicture 之前添加

\draw [decorate,decoration={brace,amplitude=4pt,mirror,raise=4pt},xshift=10pt,line 
    width=2pt]
    (3.5,-0.65) -- (3.5,0.65);
    \draw [decorate,decoration={brace,amplitude=4pt,raise=4pt},xshift=10pt,line 
    width=2pt]
    (-4,-0.65) -- (-4,0.65);

在此处输入图片描述

相关内容