我是 tikz 新手,需要一些帮助来更改我曾得到过帮助的图表。在旧图表中,映射如下所示:
p \
\x_____y
/
pbar/
即,两个元素 p、pbar 通过第一个映射 x 映射到同一个元素,而第二个映射则将它们传递给 y。我想创建一个新的映射,它们看起来像这样:
p _____ x\
\y
/
pbar_____xbar/
即,第一个映射 x 和 xbar 将两个元素 p、pbar 映射到不同的元素,但第二个映射将它们都映射到 y。我想创建一个新的映射,它们看起来像这样:
旧图的代码是:
\documentclass[a4paper,11pt,twoside]{report}
\usepackage{mathrsfs}
\usepackage{tikz}
\usetikzlibrary{arrows,positioning,calc,arrows.meta,shapes,fit}
\usetikzlibrary{arrows,automata}
\begin{document}
\begin{tikzpicture}[loose/.style={inner sep=.7em}, oval/.style={ellipse,draw}]
\newcommand{\p}{\mathbf{p}}
\newcommand{\x}{\mathbf{x}}
\node(p){$\p$};
\node[below=1 of p](pb){$\bar \p$};
\node[right=4 of $(p)!0.5!(pb)$](x1){$\x(\cdot;\p,I)$};
\node[right =4 of x1](y){$y(\cdot;\p,I)$}; \def\ovalwidth{0.8}%Just used for the left one, adjust to make roughly match the others which are already wide
\def\ovalheight{0.4}%excess height, all will get the same height.
\coordinate(ovaltop) at ($(p.north)+(0,\ovalheight)$);
\coordinate(ovalbot) at ($(pb.south)-(0,\ovalheight)$); \node[oval,inner sep=2pt,fit={(ovaltop)($(pb)+(\ovalwidth,0)$)($(pb)-(\ovalwidth,0)$)(ovalbot)},label=$\Omega$]{};
\node[oval,inner
sep=2pt,fit={(x1)(x1|-ovaltop)(x1|-ovalbot)},label=$\mathscr{F}_\Pi(I)\subset\mathscr{F}_\Pi$]{};
\node[oval,inner
sep=2pt,fit={(y)(y|-ovaltop)(y|-ovalbot)},label=$\mathscr{G}_\Pi(I)\subset\mathscr{G}_\Sigma$]{};
\draw[-Latex] (p) -- node [above,loose]{$X_{\Pi I}(\p)$} (x1);
\draw[-Latex] (pb) -- node [below,loose]{$X_{\Pi I}(\bar\p)$} (x1); \draw[-Latex] (x1) -- node [above,loose]{$Y_\Sigma(\x(\cdot;\p,I))$} (y);
\end{tikzpicture}
\end{document}
它包含许多额外元素,例如椭圆和箭头标签。请保留椭圆的原样(即最左边的椭圆包含 ps,中间的椭圆包含 xs,最右边的椭圆包含 y),我有足够的信心自己标记新箭头。
如果不太麻烦的话,你能否比平常多解释一下你的代码——我希望很快就能在没有帮助的情况下完成这些。
答案1
我尝试遵循您的指示并尽可能多地保留/复制您的代码/策略。
\documentclass[a4paper,11pt,twoside]{report}
\usepackage{mathrsfs}
\usepackage{tikz}
\usetikzlibrary{positioning,calc,arrows.meta,shapes,fit}
\begin{document}
\begin{tikzpicture}[loose/.style={inner sep=.7em}, oval/.style={ellipse,draw}]
\newcommand{\p}{\mathbf{p}}
\newcommand{\x}{\mathbf{x}}
\node(p){$\p$};
\node[below=1 of p](pb){$\bar \p$};
\node[right=3 of p](x0){$\x$};
\node[right=3 of pb](x0b){$\bar\x$};
\node[right=3 of $(x0)!0.5!(x0b)$](x1){$\x(\cdot;\p,I)$};
\node[right=3 of x1](y){$y(\cdot;\p,I)$};
\def\ovalwidth{0.8}%Just used for the left one, adjust to make roughly match the others which are already wide
\def\ovalheight{0.4}%excess height, all will get the same height.
\coordinate(ovaltop) at ($(p.north)+(0,\ovalheight)$);
\coordinate(ovalbot) at ($(pb.south)-(0,\ovalheight)$);
\node[oval,inner sep=2pt,fit={(ovaltop)($(pb)+(\ovalwidth,0)$)($(pb)-(\ovalwidth,0)$)(ovalbot)},label=$\Omega$]{};
\node[oval,inner
sep=2pt,fit={(x0)(x0|-ovaltop)(x0|-ovalbot)($(x0)+(\ovalwidth,0)$)($(x0)-(\ovalwidth,0)$)},label={}]{};
\node[oval,inner
sep=2pt,fit={(x1)(x1|-ovaltop)(x1|-ovalbot)},label=$\mathscr{F}_\Pi(I)\subset\mathscr{F}_\Pi$]{};
\node[oval,inner
sep=2pt,fit={(y)(y|-ovaltop)(y|-ovalbot)},label=$\mathscr{G}_\Pi(I)\subset\mathscr{G}_\Sigma$]{};
\draw[-Latex] (p) -- node [above,loose]{$X_{\Pi I}(\p)$} (x0);
\draw[-Latex] (pb) -- node [below,loose]{$X_{\Pi I}(\bar\p)$} (x0b);
\draw[-Latex] (x0) -- (x1);
\draw[-Latex] (x0b) -- (x1);
\draw[-Latex] (x1) -- node [above,loose]{$Y_\Sigma(\x(\cdot;\p,I))$} (y);
\end{tikzpicture}
\end{document}
至于您修改后的问题:
\documentclass[a4paper,11pt,twoside]{report}
\usepackage{mathrsfs}
\usepackage{tikz}
\usetikzlibrary{positioning,calc,arrows.meta,shapes,fit}
\begin{document}
\begin{tikzpicture}[loose/.style={inner sep=.7em}, oval/.style={ellipse,draw}]
\newcommand{\p}{\mathbf{p}}
\newcommand{\x}{\mathbf{x}}
\node(p){$\p$};
\node[below=1 of p](pb){$\bar \p$};
\node[right=4 of p](x0){$\x$};
\node[right=4 of pb](x0b){$\bar\x$};
\node[right=4.5 of $(x0)!0.5!(x0b)$](y){$y(\cdot;\p,I)$};
\def\ovalwidth{0.8}%Just used for the left one, adjust to make roughly match the others which are already wide
\def\ovalheight{0.4}%excess height, all will get the same height.
\coordinate(ovaltop) at ($(p.north)+(0,\ovalheight)$);
\coordinate(ovalbot) at ($(pb.south)-(0,\ovalheight)$);
\node[oval,inner sep=2pt,fit={(ovaltop)($(pb)+(\ovalwidth,0)$)($(pb)-(\ovalwidth,0)$)(ovalbot)},label=$\Omega$]{};
\node[oval,inner
sep=2pt,fit={(x0)(x0|-ovaltop)(x0|-ovalbot)($(x0)+(\ovalwidth,0)$)($(x0)-(\ovalwidth,0)$)},label={}]{};
\node[oval,inner
sep=2pt,fit={(y)(y|-ovaltop)(y|-ovalbot)},label=$\mathscr{G}_\Pi(I)\subset\mathscr{G}_\Sigma$]{};
\draw[-Latex] (p) -- node [above,loose]{$X_{\Pi I}(\p)$} (x0);
\draw[-Latex] (pb) -- node [below,loose]{$X_{\Pi I}(\bar\p)$} (x0b);
\draw[-Latex] (x0) -- node [above,sloped]{$Y_\Sigma(\x(\cdot;\p,I))$} (y);
\draw[-Latex] (x0b) -- node [below,sloped]{$Y_\Sigma(\x(\cdot;\p,I))$} (y);
\end{tikzpicture}
\end{document}