TikZ:带有两条文本行的梯形角

TikZ:带有两条文本行的梯形角

我如何获得相同角度梯形节点一行和两行文字?当我写两行文字时,总是会产生不同的角度,如下图所示。

在此处输入图片描述

梅威瑟:

\documentclass[tikz, margin=3mm]{standalone}
\usetikzlibrary{arrows.meta,shapes}

\begin{document}
   \begin{tikzpicture}[node distance = 1.5cm]
% Styles
    \tikzstyle{start} = [rectangle, rounded corners, text width=3cm, minimum height=1cm, draw=black, text centered]
    \tikzstyle{process} = [rectangle, text width=3cm, minimum height=1cm, draw=black, text centered]
    \tikzstyle{input} = [trapezium, trapezium left angle=70, trapezium right angle=110, text width=2.8cm, minimum height=1cm, text centered, trapezium stretches=true, draw=black]
    \tikzstyle{arrow} = [thick,->,>=latex]
% Nodes
    \node (start) [start] {Start};
    \node (P1) [process,below of=start] {Step 1};
    \node (I1) [input,left of=P1, xshift=-3.0cm] {Input one: two lines long};
    \node (P2) [process,below of=P1] {Step 2};
    \node (I2) [input,left of=P2, xshift=-3.0cm] {Input two};
    \node (P3) [process,below of=P2] {Step 3};
    \node (I3) [input,left of=P3, xshift=-3.0cm] {Input three: two lines long};
    \node (stop) [start,below of=P3] {Stop};
% Arrows
    \draw [arrow] (start) -- (P1);
    \draw [arrow] (I1) -- (P1);
    \draw [arrow] (P1) -- (P2);
    \draw [arrow] (I2) -- (P2);
    \draw [arrow] (P2) -- (P3);
    \draw [arrow] (I3) -- (P3);
    \draw [arrow] (P3) -- (stop);
\end{tikzpicture}
\end{document}

答案1

当您增加梯形的高度时,这会修改形状,因为它会强制高度,而它已经由另一个参数确定,因此,如果您想增加高度,您可以使用属性inner sep,可以是xsepysep..,在代码中的注释中我指出哪些参数会导致修改。

结果:

在此处输入图片描述

梅威瑟:

\documentclass[tikz, margin=3mm]{standalone}
\usetikzlibrary{arrows.meta,shapes.geometric,calc}

\begin{document}
   \begin{tikzpicture}[node distance = 1.5cm]
   % Styles (Its good practice to write like this, you could activate or deactivate options, add comments and avoid put information that goes off the screen like thislike...
    \tikzstyle{start} = [
        rectangle,
        rounded corners,
        text width=3cm,
        minimum height=1cm,
        draw=black,
%       dashed,
        text centered
    ]
    \tikzstyle{process} = [
        rectangle,
        text width=3cm,
        minimum height=1cm,
        draw=black,
        text centered
    ]
    \tikzstyle{input} = [ % It's a matter of tuning...
        trapezium,
        trapezium left angle=70,
        trapezium right angle=110,
        text width=3cm,
%       inner sep=2pt, % Separation between textbox and shape box horizontal and vertical
%       inner xsep=5pt, % Idem but only horizontal.
        inner ysep=5pt, % Idem but only vertical
        minimum width=4.4cm, % it must be the length of the largest trapezoid.
%       minimum height=1cm, % It causes the variation of trapezium angles.. use inner sep instead...
%       trapezium stretches=true, % It also generate variation of trapezium angles...
        text centered,
        draw=black
    ]
    \tikzstyle{arrow} = [
        thick,
        ->,
        >=latex
    ]
% Nodes
    \node (start) [start] {Start};
    \node (P1) [process,below of=start] {Step 1};
    \node (I1) [input,left of=P1, xshift=-3.0cm] {Input one: two lines long};
    \node (P2) [process,below of=P1] {Step 2};
    \node (I2) [input,left of=P2, xshift=-3.0cm] {Input two:};
    \node (P3) [process,below of=P2] {Step 3};
    \node (I3) [input,left of=P3, xshift=-3.0cm] {Input three: three lines long to get another };
    \node (stop) [start,below of=P3] {Stop};
% Arrows
    \draw [arrow] (start) -- (P1);
    \draw [arrow] (I1) -- (P1);
    \draw [arrow] (P1) -- (P2);
    \draw [arrow] (I2) -- (P2);
    \draw [arrow] (P2) -- (P3);
    \draw [arrow] (I3) -- (P3);
    \draw [arrow] (P3) -- (stop);

% For inspection:
    \draw[dashed, orange,thick] (-6.85,-2.5) -- ++ (70:2);
    \draw[dashed, orange,thick] (-6.75,-3.5) -- ++ (70:1.2);
    \draw[dashed, orange,thick] (-6.8,-5.5) -- ++ (70:2);
    \draw[dashed, orange,thick] (-6.7,-5.55) -- ++ (90:5);
    \draw[dashed, orange,thick] (-2.3,-5.55) -- ++ (90:5);

\end{tikzpicture}
\end{document}

相关内容