tikz 椭圆的问题

tikz 椭圆的问题
\documentclass[10pt]{article}
\usepackage{tikz}
\usepackage{graphicx}
\usepackage{pgf,pgfplots}
\usepackage[romanian]{babel}
\usepackage[paperwidth=15.5cm, paperheight=23.5cm, margin=2cm]{geometry}
\usepackage{amsthm,amssymb}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{rmathbr}
\usepackage{float}
\usetikzlibrary{math,arrows,positioning,shapes,fit,calc}
\pgfplotsset{compat=1.15}
\begin{document}
\begin{figure}[H]
\centering
\begin{tikzpicture}
\foreach[count=\i] \lseti/\lsetmi in {{A}/{$x$},{B}/{$f(x)$}, {C}/{$g(f(x))$}} {
    \begin{scope}[local bounding box=\lseti, x=3cm, y=2cm]
    \foreach[count=\j] \lj in \lsetmi {
        \node[minimum width=1em, minimum height=4em] (n-\j-\lseti) at (\i,-\j) {\lj};
    }
    \end{scope}
    \node[ellipse, draw, fit=(\lseti), label={above:$\lseti$}] {};
}
    \draw[->] (n-1-A) -- (n-1-B);
    \draw[->] (n-1-B) -- (n-1-C);
    \draw (4.5,-1.5) node[anchor=north] {$f$};
    \draw (7.4,-1.55) node[anchor=north] {$g$};
\end{tikzpicture}
\end{figure}
\end{document}

上面的代码生成了两个函数的组合图。问题是第二个椭圆和第三个椭圆太胖了。我该如何让它们看起来苗条又好看?请帮忙。先谢谢了!

答案1

如果我理解正确的话:

% arara: pdflatex
\documentclass[tikz,margin=3]{standalone}
\usetikzlibrary{math,arrows,positioning,shapes,fit,calc}
\begin{document}
\begin{tikzpicture}
  \foreach[count=\i] \lseti/\lsetmi in {{A}/{$x$},{B}/{$f(x)$}, {C}/{$g(f(x))$}} {
    \begin{scope}[local bounding box=\lseti, x=3cm, y=2cm]
    \foreach[count=\j] \lj in \lsetmi {
      \node[minimum width=1em,minimum height=4em] (n-\j-\lseti) at (\i,-\j) {\lj};
    }
    \end{scope}
    %\node[ellipse, draw, fit=(\lseti), label={above:$\lseti$}] {};
    \draw (\lseti.center) ellipse (8mm and 4em);
    \path (\lseti.center) ++ (0,4em) node[above] {$\lseti$};
  }
  \draw[->] (n-1-A) -- (n-1-B);
  \draw[->] (n-1-B) -- (n-1-C);
  \draw (4.5,-1.5) node[anchor=north] {$f$};
  \draw (7.4,-1.55) node[anchor=north] {$g$};
\end{tikzpicture}
\end{document}

在此处输入图片描述

但让它看起来好的?我会这样做。

% arara: pdflatex
\documentclass[tikz,margin=3]{standalone}
\usetikzlibrary{positioning}
\usetikzlibrary{shapes.geometric}
\begin{document}
\begin{tikzpicture}[my function/.style={ellipse,draw,minimum height=1cm,label=above:#1},>=stealth]
  \node[my function=$A$] (a) {$x$};
  \node[my function=$B$,right=1cm of a] (b) {$f(x)$};
  \node[my function=$C$,right=1cm of b] (c) {$g(f(x))$};
  \draw[->] (a) -- (b) node[midway,above] {$f$};
  \draw[->] (b) -- (c) node[midway,above] {$g$};
\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容