重新创建此 TikZ 图像

重新创建此 TikZ 图像

我需要在 TikZ 中重新创建以下图像。 Tikz 绘图

我能够使用以下 TikZ 代码绘制框,但无法正确放置下括号和符号。

\begin{figure}[H]
\begin{tikzpicture}
\draw (0,0) -- (1.6,0) -- (1.6,1.3) -- (0,1.3) -- (0,0);
\draw (1.7,0) -- (3.3,0) -- (3.3,1.3) -- (1.7,1.3) -- (1.7,0);
\draw (3.4,0) -- (5,0) -- (5,1.3) -- (3.4,1.3) -- (3.4,0);
\draw (5.1,0) -- (6.7,0) -- (6.7,1.3) -- (5.1,1.3) -- (5.1,0);

\draw (0.5,0.21) -- (1.5,0.21);
\draw (0.5,0.42) -- (1.5,0.42);
\draw (0.5,0.63) -- (1.5,0.63);
\draw (0.5,0.84) -- (1.5,0.84);
\draw (0.5,1.06) -- (1.5,1.06);

\draw (1.8,0.21) -- (3.2,0.21);
\draw (1.8,0.42) -- (3.2,0.42);
\draw (1.8,0.63) -- (3.2,0.63);
\draw (1.8,0.84) -- (3.2,0.84);
\draw (1.8,1.06) -- (3.2,1.06);

\draw (3.5,0.21) -- (4.9,0.21);
\draw (3.5,0.42) -- (4.9,0.42);
\draw (3.5,0.63) -- (4.9,0.63);
\draw (3.5,0.84) -- (4.9,0.84);
\draw (3.5,1.06) -- (4.9,1.06);

\draw (5.2,0.21) -- (6.6,0.21);
\draw (5.2,0.42) -- (6.6,0.42);
\draw (5.2,0.63) -- (6.6,0.63);
\draw (5.2,0.84) -- (6.6,0.84);
\draw (5.2,1.06) -- (6.6,1.06);
\end{tikzpicture}

答案1

现在太晚了,没法再多解释,但我还是想补充一个完全不同的关于如何绘制的建议。这个建议有点草率,可能可以写得更好。

在此处输入图片描述

\documentclass[border=5mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{decorations.pathreplacing}
\tikzset{
fulllinebox/.pic={
\node (-frame) at (0,0) [above right,draw,minimum width=1.6cm,minimum height=1.3cm] {};
\foreach \y in {0.167,0.334,...,1}
  \draw (-frame.south west) ++(0.1cm,1.3cm*\y) -- +(1.4cm,0);
},
halflinebox/.pic={
\node (-frame) at (0,0)  [above right,draw,minimum width=1.6cm,minimum height=1.3cm] {};
\foreach \y in {0.167,0.334,...,1}
  \draw (-frame.south west) ++(0.7cm,1.3cm*\y) -- +(0.8cm,0);
}
}
\begin{document}
\begin{tikzpicture}[decoration={brace,mirror,amplitude=5pt}]
\pic (1) {halflinebox};
\pic (2) at ([xshift=0.2cm]1-frame.south east) {fulllinebox};
\pic (3) at ([xshift=0.2cm]2-frame.south east) {fulllinebox};
\pic (4) at ([xshift=0.2cm]3-frame.south east) {fulllinebox};

\draw [decorate] (1-frame.south west) ++(0.1cm,-1pt) -- node[below=5pt]{$S_m$} ++(1.4cm,0);
\draw [decorate] (4-frame.south west) ++(0.1cm,-1pt) -- node[below=5pt]{$S_1$} ++(1.4cm,0);

\path (2-frame.south east) --node[below=9pt] {$\dots$} (3-frame.south west);

\draw [latex-latex,shorten >=0.05cm,shorten <=0.05cm] ([yshift=0.1cm]4-frame.north west) -- node[above]{$l$} ([yshift=0.1cm]4-frame.north east);

\node [right,align=center] at (4-frame.east) {$x_1$\\$\vdots$\\$x_n$};
\end{tikzpicture}
\end{document}

答案2

坐标是一种保存坐标位置以供日后使用的方法。装饰.路径替换图书馆里有一个brace装饰,必须mirror在此处编辑(或者您可以反转指定点的顺序)。计算库允许您使用(抽象)坐标进行计算,例如添加一定量(($(N)+(x,y)$))或指定两点之间某个点的某个分数(($(V)!x!(W)$))。stelth是某种箭头尖,还有许多其他箭头尖,请参阅手册或这里

代码

\documentclass[tikz, border=2mm]{standalone}
\usetikzlibrary{calc, decorations.pathreplacing}

\begin{document}

\begin{tikzpicture}[decoration={brace, mirror}]
\draw (0,0) coordinate (A) -- (1.6,0) coordinate (B) -- (1.6,1.3) -- (0,1.3)  -- cycle;
\draw (1.7,0) -- (3.3,0) coordinate (C) -- (3.3,1.3) -- (1.7,1.3) -- cycle;
\draw (3.4,0) coordinate (D) -- (5,0) -- (5,1.3) -- (3.4,1.3) -- cycle;
\draw (5.1,0) coordinate (E) -- (6.7,0) coordinate (F) -- (6.7,1.3) coordinate (G) -- (5.1,1.3) coordinate (H) -- cycle;

\draw (0.5,0.21) -- (1.5,0.21);
\draw (0.5,0.42) -- (1.5,0.42);
\draw (0.5,0.63) -- (1.5,0.63);
\draw (0.5,0.84) -- (1.5,0.84);
\draw (0.5,1.06) -- (1.5,1.06);

\draw (1.8,0.21) -- (3.2,0.21);
\draw (1.8,0.42) -- (3.2,0.42);
\draw (1.8,0.63) -- (3.2,0.63);
\draw (1.8,0.84) -- (3.2,0.84);
\draw (1.8,1.06) -- (3.2,1.06);

\draw (3.5,0.21) -- (4.9,0.21);
\draw (3.5,0.42) -- (4.9,0.42);
\draw (3.5,0.63) -- (4.9,0.63);
\draw (3.5,0.84) -- (4.9,0.84);
\draw (3.5,1.06) -- (4.9,1.06);

\draw (5.2,0.21) -- (6.6,0.21);
\draw (5.2,0.42) -- (6.6,0.42);
\draw (5.2,0.63) -- (6.6,0.63);
\draw (5.2,0.84) -- (6.6,0.84);
\draw (5.2,1.06) -- (6.6,1.06);

\draw[decorate] ($(A)+(0,-0.1)$) -- ($(B)+(0,-0.1)$);
\node[below] at ($(A)!0.5!(B)+(0,-0.2)$) {$\Delta\epsilon$};

\node[below] at ($(C)!0.5!(D)$) {$\dots$};

\draw[decorate] ($(E)+(0,-0.1)$) -- ($(F)+(0,-0.1)$);
\node[below] at ($(E)!0.5!(F)+(0,-0.2)$) {$\Omega\varphi$};

\node[right] at (G) {$\tau_{\beta}$};
\node[right] at ($(F)!0.55!(G)$) {$\vdots$};
\node[right] at (F) {$\tau_{\nu}$};

\draw[stealth-stealth] ($(G)+(0,0.1)$) -- ($(H)+(0,0.1)$);


\end{tikzpicture}

\end{document}

输出

在此处输入图片描述

答案3

还有一个选择:

\documentclass[tikz, border=2mm]{standalone}
    \usetikzlibrary{calc, chains, decorations.pathreplacing}

\begin{document}
    \begin{tikzpicture}[
node distance = 2mm,
  start chain = going right,
     A/.style = {draw, minimum width=16mm, minimum height=13mm, 
                 inner sep=1mm, node contents={},
                 on chain},
     B/.style = {decorate,
                 decoration={brace, raise=1mm, mirror,
                 pre=moveto, pre length=1mm,  post=moveto,post length=1mm},
                 thick},
   arr/.style = {thick, shorten < = 1mm, shorten > = 1mm}
                        ]
\node (n1)  [A];
    \foreach \i in {2,5,8,11}
    \draw[arr,shorten <=8mm] ($(n1.south west) + (0,\i mm)$) -- + (16mm,0);
\node (n2)  [A];
    \foreach \i in {2,5,8,11}
    \draw[arr]  ($(n2.south west) + (0,\i mm)$) -- + (16mm,0);
\node (n3)  [A];
    \foreach \i in {2,5,8,11}
    \draw[arr]  ($(n3.south west) + (0,\i mm)$) -- + (16mm,0);
\node (n4)  [A];
    \foreach \i in {2,5,8,11}
    \draw[arr]  ($(n4.south west) + (0,\i mm)$) -- + (16mm,0);

\draw[B] (n1.south west) -- node[below=2mm]{$S_m$} (n1.south east);
\draw[B] (n4.south west) -- node[below=2mm]{$S_1$} (n4.south east);

\draw[stealth-stealth,shorten <=1mm, shorten >=1mm] 
    ([yshift=2mm] n4.north west) -- node[above] {$l$} + (16mm,0);

\node[align=left,right=0mm of n4]   {$x_1$\\$\vdots$\\$x_n$};
    \end{tikzpicture}
\end{document}

在此处输入图片描述

在我的示例中,我使用了附加包 chains来设置链中的节点。\foreach使用循环来绘制节点中的线条。为了简化节点中的线条绘制,它们通过选项缩短shorten >=...,因此对于坐标,可以使用左右节点的边界。

相关内容