如何使用 tikzpicture 环境绘制一个被二等分的倾斜矩形

如何使用 tikzpicture 环境绘制一个被二等分的倾斜矩形

我想使用tikzpicture环境绘制以下除以二的矩形:

我想要的是

然而,我目前所取得的成就是:

我目前所做的

梅威瑟:

\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{shapes.multipart}
\usetikzlibrary{decorations.text}

\begin{document}

% Bend curves from https://tex.stackexchange.com/a/22316/152550
\begin{tikzpicture}[delay rect/.style={rectangle split, rectangle split parts=2,draw,
minimum width=1.5cm,minimum height=1cm, 
text width=2cm,align=center,inner ysep=2cm,draw,inner ysep=3mm,inner
xsep=3mm}]  % From https://tex.stackexchange.com/a/452609/152550
    \node (start) at (0,0) {Start};
    \node (end) at (6,0) {End};
    \node[rotate=60,delay rect] (delay) at (3,0) {A1\nodepart{two}text here};
    \def\myshift#1{\scriptsize\raisebox{1ex}}
    \draw [->,postaction={decorate,decoration={text along path,text align=center,text={|\myshift|hello}}}] (start) to [bend left=10] (delay);
    \draw [->,postaction={decorate,decoration={text along path,text align=center,text={|\myshift|bye}}}] (delay) to [bend left=10] (end);
\end{tikzpicture}

\end{document}

谢谢!

答案1

在您的样式定义中,delay rec您需要添加选项rectangle split horizontal

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes.multipart}
\usetikzlibrary{decorations.text}

\begin{document}
% Bend curves from https://tex.stackexchange.com/a/22316/152550
    \begin{tikzpicture}[
delay rect/.style = {rectangle split,  % all double and not used options in style are removed
                     rectangle split horizontal,   % <---
                     rectangle split parts=2, draw,
                     minimum height=1cm,
                     align=center,
                     inner ysep=3mm,inner xsep=3mm}
                        ]  % From https://tex.stackexchange.com/a/452609/152550
    \node (start) at (0,0) {Start};
    \node (end) at (6,0) {End};
    \node[delay rect,rotate=60] (delay) at (3,0) {A1\nodepart{two}text here};
    \def\myshift#1{\scriptsize\raisebox{1ex}}
    \draw [->,postaction={decorate,decoration={text along path,text align=center,text={|\myshift|hello}}}] (start) to [bend left=10] (delay);
    \draw [->,postaction={decorate,decoration={text along path,text align=center,text={|\myshift|bye}}}] (delay) to [bend left=10] (end);
\end{tikzpicture}
\end{document}

在此处输入图片描述

编辑:

关于您以下评论中的子问题:

1)减小矩形的字体大小(\scriptsize)?

in node style definition just define font size with `font=\scriptsize`

2)再稍微减少矩形的高度?

in height of a rectangles are defined by `minimum height = <desired height>`. you have selected 1cmm, if this is to much, reduce for example to 7mm

3)稍微减少矩形每个部分的宽度,这样文本和边缘之间就没有太多的空间

space between node border lines and nodes content (text) is controlled by `inner sep` (equal for all direction) or `inner ysep` in vertical direction) and `inner xsep` for horizontal. default value is `3pt`. if this is to much to you, than to node's style option add for example `inner sep=2pt`.

相关内容