tikz 中的旋转形状?这些形状应如何放置在链上?

tikz 中的旋转形状?这些形状应如何放置在链上?

我对 tikz 中的旋转形状感到困惑:我想将非矩形形状连接在一起。该怎么做?

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{chains}
\usetikzlibrary{circuits.ee.IEC}
\usetikzlibrary{shapes}
\begin{document}
\newcommand\TAPE[3]{
  \begin{scope}[
                start chain=#1 going below,
                node distance=1,
                every node/.style={
                    on chain=#1,
                    shape=tape,
            minimum width=#2,
                    minimum height=#3,
                    ultra thin,
                    draw=red!75!black,
                    fill=red!5!white,
                    text=black,
                    font=\tiny,
                    align=left,
          tape bend top=none,
          tape bend height=4mm,
            }]
  \node[rotate=0]   (T1) {#2,#3};
  \node[rotate=180] (B1) {};
  \node[rotate=0]   (T2) {};
  \node[rotate=180] (B2) {};
  \node[rotate=0]   (T3) {};
  \node[rotate=180] (B3) {};
  \node[rotate=0]   (T4) {};
  \node[rotate=180] (B4) {};
  \node[rotate=0]   (T5) {};
  \node[rotate=180] (B5) {};
  \node[rotate=0]   (T6) {};
  \node[rotate=180] (B6) {};
  \end{scope}
}
\begin{tikzpicture}

\TAPE{a}{1cm}{2cm} % Can we get this to work for any set of parameters?
\end{tikzpicture}
\end{document}

我希望紧密链接适用于任何宽度和列

在此处输入图片描述

答案1

node distance等于minimum height( #3);由于胶带弯曲,没有旋转的节点仍然需要移动;移动的长度恰好是 的值tape bend height

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{chains}
\usetikzlibrary{circuits.ee.IEC}
\usetikzlibrary{shapes}

\newlength\tapebend
\setlength{\tapebend}{4mm}

\begin{document}
\newcommand\TAPE[3]{
  \begin{scope}[
                start chain=#1 going below,
                node distance=#3,
                outer sep=0pt,
                every node/.style={
                    on chain=#1,
                    shape=tape,
                    text width=#2,
                    minimum height=#3,
                    ultra thin,
                    draw=red!75!black,
                    fill=red!5!white,
                    text=black,
                    font=\tiny,
                    align=left,
          tape bend top=none,
          tape bend height=\tapebend,
            }]
  \node[rotate=0]   (T1) {};
  \node[rotate=180] (B1) {};
  \node[rotate=0,yshift=4mm]   (T2) {};
  \node[rotate=180] (B2) {};
  \node[rotate=0,yshift=4mm]   (T3) {};
  \node[rotate=180] (B3) {};
  \node[rotate=0,yshift=4mm]   (T4) {};
  \node[rotate=180] (B4) {};
  \node[rotate=0,yshift=4mm]   (T5) {};
  \node[rotate=180] (B5) {};
  \node[rotate=0,yshift=4mm]   (T6) {};
  \node[rotate=180] (B6) {};
  \end{scope}
}

\begin{tikzpicture}
\TAPE{a}{1cm}{1.5cm}
\begin{scope}[xshift=4cm]
\TAPE{b}{2cm}{1cm}
\end{scope}
\begin{scope}[xshift=8cm]
\TAPE{c}{5mm}{8mm}
\end{scope}
\end{tikzpicture}

\end{document}

在此处输入图片描述

相关内容