背景文字如何定位?

背景文字如何定位?

我有两个问题。如何放大背景并更改文本的位置?以及,为什么最后一个梯形比其他图形大?

这是我的 WE:

\documentclass[12pt,a4paper]{extarticle} %,twoside Usado en latex-ssau-gost-style-master
\usepackage[utf8]{inputenc}
%%%%%%%TIKZ%%%%%%%
\usepackage{tikz}    
% FLOWCHARTS
\usepackage{subfigure}

\usetikzlibrary{shapes,arrows,backgrounds,fit}

\tikzstyle{deci} = [diamond, draw, fill=blue!20, text width=4.5em, text badly centered, node distance=3cm, inner sep=0pt]
\tikzstyle{proc} = [rectangle, draw, fill=blue!20,text width=7em, text centered, rounded corners, minimum height=4em]
\tikzstyle{line} = [draw, -latex']
\tikzstyle{io} = [draw, ellipse,fill=red!20, node distance=3cm, minimum height=2em]    
\tikzstyle{data} = [trapezium, draw, trapezium left angle = 70, trapezium right angle = 110, ,text width=7em, text centered, minimum height=4em, fill=blue!20]
\pgfdeclarelayer{background}
\pgfdeclarelayer{foreground}
\pgfsetlayers{background,main,foreground}
%%%%%%%%%%%%%%%%%%

\begin{document}

\begin{figure}
    \centering
    \begin{tikzpicture}[node distance = 2.5cm, auto]
        % Place nodes
        \node (init) [io] {Begining};
        \node (ispea) [data,below of = init] {Airfoil coordinates, $\bar{c}, g_1(\bar{x}), g_2(\bar{x})$};
        \node (spea)   [proc, below of=ispea] {Multiobjective optimization};
        \node (vlm)    [proc, below of=spea] {VLM};
        \node (imdb)  [data, right of=vlm, node distance=7cm] {Geometrical characteristics};
        \node (static) [proc,below of =vlm] {Static analysis};
        \node (seval)  [proc, below of=static] {$C_k$ calculation};
        \begin{pgfonlayer}{background}
            \node (MAPDL) [fit = (static)(seval),fill=blue!10] {MAPDL};
        \end{pgfonlayer}
        \node (out) [data, below of=seval,node distance=3cm]  {Print results};
        \node (end) [io, below of=out] {End};
        % Draw edges
        \path [line] (init) -- (ispea);
        \path [line] (ispea) -- (spea);
        \path [line] (spea) -- (vlm);
        \path [line] (imdb) -- (vlm);
        \path [line] (vlm) -- (static);
        \path [line] (static) -- (seval);
        \path [line] (seval) -- (out);
        \path [line] (out) -- (end);
    \end{tikzpicture}
    \caption{Scheme automatization process wing's design}
    \label{fig:wing_design_process}
\end{figure}

\end{document}

这就是我得到的: 在此处输入图片描述

这就是我所寻找的: 在此处输入图片描述

答案1

请注意,\tikzstyle现在已弃用。\tikzset建议改用。您的代码只需稍作更改即可满足您的要求:

  • MAPDL节点放在(static) -- (seval)前层的路径上
  • 然后让适合的背景节点(static)(seval)(mapdl)只负责着色
  • 使用trapezium stretches body适合您data风格的选项
\documentclass[12pt,a4paper]{extarticle} %,twoside Usado en latex-ssau-gost-style-master
\usepackage[utf8]{inputenc}
%%%%%%%TIKZ%%%%%%%
\usepackage{tikz}    
% FLOWCHARTS
\usepackage{subfigure}

\usetikzlibrary{shapes,arrows,backgrounds,fit}

\tikzset{
  deci/.style={diamond, draw, fill=blue!20, text width=4.5em, text badly centered, node distance=3cm, inner sep=0pt},
  proc/.style={rectangle, draw, fill=blue!20,text width=7em, text centered, rounded corners, minimum height=4em},
  line/.style={draw, -latex'},
  io/.style={draw, ellipse,fill=red!20, node distance=3cm, minimum height=2em},
  data/.style={trapezium, draw, trapezium left angle = 50, trapezium right angle = 130,
    text width=7em, text centered, minimum height=4em, fill=blue!20,
    trapezium stretches body,
  },
}
\pgfdeclarelayer{background}
\pgfdeclarelayer{foreground}
\pgfsetlayers{background,main,foreground}
%%%%%%%%%%%%%%%%%%

\begin{document}

\begin{figure}
    \centering
    \begin{tikzpicture}[node distance = 2.5cm, auto]
        % Place nodes
        \node (init) [io] {Begining};
        \node (ispea) [data,below of = init] {Airfoil coordinates, $\bar{c}, g_1(\bar{x}), g_2(\bar{x})$};
        \node (spea)   [proc, below of=ispea] {Multiobjective optimization};
        \node (vlm)    [proc, below of=spea] {VLM};
        \node (imdb)  [data, right of=vlm, node distance=7cm] {Geometrical characteristics};
        \node (static) [proc,below of =vlm] {Static analysis};
        \node (seval)  [proc, below of=static] {$C_k$ calculation};
        \node (out) [data, below of=seval,node distance=3cm]  {Print results};
        \node (end) [io, below of=out] {End};
        % Draw edges
        \path [line] (init) -- (ispea);
        \path [line] (ispea) -- (spea);
        \path [line] (spea) -- (vlm);
        \path [line] (imdb) -- (vlm);
        \path [line] (vlm) -- (static);
        \path [line] (static) -- node (mapdl) [right=2cm] {MAPDL} (seval);
        \path [line] (seval) -- (out);
        \path [line] (out) -- (end);
        \begin{pgfonlayer}{background}
          \node (MAPDL) [fit = (static)(seval)(mapdl),fill=blue!10] {};
        \end{pgfonlayer}
    \end{tikzpicture}
    \caption{Scheme automatization process wing's design}
    \label{fig:wing_design_process}
\end{figure}

\end{document}

在此处输入图片描述

相关内容