绘制两个图形:一个相邻,并添加音乐符号

绘制两个图形:一个相邻,并添加音乐符号

我需要获取屏幕截图上的内容:

在此处输入图片描述

\documentclass{article}
\usepackage{musicography}
\usepackage[demo]{graphicx} 
\usepackage{tikz}
\usetikzlibrary{arrows.meta,
                chains,
                positioning}

\begin{document}
    \begin{tikzpicture}[
    node distance = 4mm and 44mm,
      start chain = A going below,
every node/.style = {inner sep=0pt, outer sep=2mm, rounded corners,
                     text width=0.15\linewidth,
                     on chain=A},
        arr/.style = {color=#1, ultra thick, -{Straight Barb[angle=60:2pt 3]}}
                        ]
\setkeys{Gin}{width=\linewidth}
\node   {\includegraphics{boy.jpg}};    % A-1
\node   {\includegraphics{girl.jpg}};
\node   {\includegraphics{girl.jpg}};   % A-3
%
\node[above right=of A-1.east]
        {\includegraphics{pera.png}};         % A-4
\node   {\includegraphics{grapes.png}};
\node   {\includegraphics{strawberry.png}};
\node   {\includegraphics{tangerine.png}};    % A-7
%
\draw[red, ultra thick,
     {Straight Barb[angle=60:2pt 3]}-{Straight Barb[angle=60:2pt 3]}
     ]  (A-1.west) to [bend right=45] (A-3.west);
\foreach \i in {4,...,7}
    \draw[arr=black] (A-1.east) -- (A-\i);
\draw[arr=blue!50!gray] (A-2.east) -- (A-5);
\foreach \i in {5,6}
    \draw[arr=purple!50!gray] (A-3.east) -- (A-\i);
%
\draw[arr=brown,densely dashed] (A-4) -- (A-3);
\draw[arr=brown,densely dashed] (A-7) -- (A-3);
\end{tikzpicture}
\end{document}

在此处输入图片描述

答案1

我不会chains在这里使用。使用,matrix您可以自动填充节点。否则,您可以将子图放在范围内并移动右侧,并且可以执行以下操作@egreg 建议

\documentclass{article}
\usepackage{musicography}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,matrix,positioning,shapes.geometric}

\begin{document}
    \begin{tikzpicture}[font=\sffamily]
 \begin{scope}[local bounding box=left]
  \matrix[matrix of nodes,cells={nodes={ellipse,draw,
    alias=\tikzmatrixname-\the\pgfmatrixcurrentrow,
  execute at begin node=User \the\pgfmatrixcurrentrow}},row sep=1em] (L1){
  {}\\ 
  {}\\
  {}\\};
  \matrix[right=4em of L1,matrix of nodes,cells={nodes={draw,
    alias=\tikzmatrixname-\the\pgfmatrixcurrentrow,
  execute at begin node=\scalebox{2}{\musEighth} \the\pgfmatrixcurrentrow}},row sep=1em] (L2){
  {}\\ 
  {}\\
  {}\\
  {}\\};
  \draw foreach \X in {1,2,3,4} {(L1-1.east) edge[-latex,thick] (L2-\X.west)}
  foreach \X in {1,4} {(L2-\X.west) edge[-latex,thick,dashed,blue!40] (L1-3.east)}
  (L1-2) edge[ultra thick,-{Triangle[width=5pt]},gray] (L2-2)
  foreach \X in {2,3}{(L1-3) edge[ultra thick,-{Triangle[width=5pt]},gray]
  (L2-\X)}
  (L1-1.west) edge[bend right,latex-latex,thick] (L1-3.west);
 \end{scope}
 \draw[very thin] ([xshift=1em]left.north west) to[bend right]
  ([xshift=1em]left.south west) ([xshift=-0.1em]left.north east) to[bend left]
  ([xshift=-0.1em]left.south east);
 \begin{scope}[local bounding box=right,xshift=16em]
  \matrix[matrix of nodes,cells={nodes={ellipse,draw,
    alias=\tikzmatrixname-\the\pgfmatrixcurrentrow,
  execute at begin node=User \the\pgfmatrixcurrentrow}},row sep=1em] (L3){
  {}\\ 
  {}\\
  {}\\};
  \matrix[right=4em of L3,matrix of nodes,cells={nodes={draw,
    alias=\tikzmatrixname-\the\pgfmatrixcurrentrow,
  execute at begin node=\scalebox{2}{\musEighth} \the\pgfmatrixcurrentrow}},row sep=1em] (L4){
  {}\\ 
  {}\\
  {}\\
  {}\\};
  \draw foreach \X in {1,2,4} {(L3-1.east) edge[-latex,thick] (L4-\X.west)}
  foreach \X in {1} {(L4-\X.west) edge[-latex,thick,dashed,blue!40] (L3-3.east)}
  (L3-3) edge[ultra thick,-{Triangle[width=5pt]},gray] (L4-3)
  foreach \X in {1,3}{(L3-2) edge[ultra thick,-{Triangle[width=5pt]},gray]
  (L4-\X)}
  (L4-1.east) edge[bend left,latex-latex,thick] (L4-3.east);
 \end{scope}
\end{tikzpicture}
\end{document}

在此处输入图片描述

或者不用牙套。

\documentclass{article}
\usepackage{musicography}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,matrix,positioning,shapes.geometric}

\begin{document}
    \begin{tikzpicture}[font=\sffamily]
 \begin{scope}[local bounding box=left]
  \matrix[matrix of nodes,cells={nodes={ellipse,draw,
    alias=\tikzmatrixname-\the\pgfmatrixcurrentrow,
  execute at begin node=User \the\pgfmatrixcurrentrow}},row sep=1em] (L1){
  {}\\ 
  {}\\
  {}\\};
  \matrix[right=4em of L1,matrix of nodes,cells={nodes={draw,
    alias=\tikzmatrixname-\the\pgfmatrixcurrentrow,
  execute at begin node=\scalebox{2}{\musEighth} \the\pgfmatrixcurrentrow}},row sep=1em] (L2){
  {}\\ 
  {}\\
  {}\\
  {}\\};
  \draw foreach \X in {1,2,3,4} {(L1-1.east) edge[-latex,thick] (L2-\X.west)}
  foreach \X in {1,4} {(L2-\X.west) edge[-latex,thick,dashed,blue!40] (L1-3.east)}
  (L1-2) edge[ultra thick,-{Triangle[width=5pt]},gray] (L2-2)
  foreach \X in {2,3}{(L1-3) edge[ultra thick,-{Triangle[width=5pt]},gray]
  (L2-\X)}
  (L1-1.west) edge[bend right,latex-latex,thick] (L1-3.west);
 \end{scope}
 \begin{scope}[local bounding box=right,xshift=16em]
  \matrix[matrix of nodes,cells={nodes={ellipse,draw,
    alias=\tikzmatrixname-\the\pgfmatrixcurrentrow,
  execute at begin node=User \the\pgfmatrixcurrentrow}},row sep=1em] (L3){
  {}\\ 
  {}\\
  {}\\};
  \matrix[right=4em of L3,matrix of nodes,cells={nodes={draw,
    alias=\tikzmatrixname-\the\pgfmatrixcurrentrow,
  execute at begin node=\scalebox{2}{\musEighth} \the\pgfmatrixcurrentrow}},row sep=1em] (L4){
  {}\\ 
  {}\\
  {}\\
  {}\\};
  \draw foreach \X in {1,2,4} {(L3-1.east) edge[-latex,thick] (L4-\X.west)}
  foreach \X in {1} {(L4-\X.west) edge[-latex,thick,dashed,blue!40] (L3-3.east)}
  (L3-3) edge[ultra thick,-{Triangle[width=5pt]},gray] (L4-3)
  foreach \X in {1,3}{(L3-2) edge[ultra thick,-{Triangle[width=5pt]},gray]
  (L4-\X)}
  (L4-1.east) edge[bend left,latex-latex,thick] (L4-3.east);
 \end{scope}
\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容