使图形(列表)像 tikz 节点/箭头过渡一样

使图形(列表)像 tikz 节点/箭头过渡一样

我的 MWE 如下:

\documentclass[a4paper,11pt,twoside]{report}
\usepackage[left=2.5cm,right=2cm,top=2cm,bottom=2cm]{geometry}
\usepackage[T1]{fontenc}
\usepackage{graphicx}

\usepackage{setspace}
\usepackage{bchart}
\usepackage{float}
\usepackage{listings}
\usepackage{color}
\usepackage{textcomp}
\lstset{
%frame=tb,
  language=C++,
  aboveskip=3mm,
  belowskip=3mm,
  showstringspaces=false,
  columns=flexible,
  %basicstyle={\small\ttfamily},
  basicstyle=\ttfamily\footnotesize\bfseries,
  numbers=none,
  numberstyle=\tiny\color{gray},
  %keywordstyle=\color{blue},
  commentstyle=\color{dkgreen},
  %stringstyle=\color{mauve},
  breaklines=true,
  breakatwhitespace=true,
  tabsize=3
}

\begin{document}

\begin{figure}[H]
\centering
\begin{minipage}{.45\linewidth}
\begin{lstlisting}
array stat_1[144] : w32 -> w8 = symbolic
(query [(Eq falseq
            (Eq 0
                N0:(ReadLSB w64 56 stat_1)))
        (Eq false
            (Eq 0 N1:(URem w64 8 N0)))]
       (Eq false
           (Eq 0 N2:(Read w8 56 stat_1))))
\end{lstlisting}
\end{minipage}
\end{figure}


\begin{figure}[H]
\centering
\begin{minipage}{.45\linewidth}
\begin{lstlisting}
array stat_1[144] : w32 -> w8 = symbolic
(query [(Eq falseq
            (Eq 0
                N0:(ReadLSB w64 56 stat_1)))
        (Eq false
            (Eq 0 N1:(URem w64 8 N0)))
        (Eq false
            (Eq 0 (URem w64 N0 N1)))]
       (Eq false
           (Eq 0 N2:(Read w8 56 stat_1))))

\end{lstlisting}
\end{minipage}
\end{figure}


\end{document}

我想制作一些东西,让第一个图形变成第二个图形,例如图 1 ---> 图 2(有点像 tikz 节点/箭头状态机样式,但我希望能够在里面插入图形/列表)我该如何实现这样的效果?希望我说清楚了,谢谢!

答案1

您可以简单地使用tikz并将lstlisting作为节点内容。(删除figure环境,但保留minipage。)

\documentclass[a4paper,11pt,twoside]{report}
\usepackage[left=2.5cm,right=2cm,top=2cm,bottom=2cm]{geometry}
\usepackage[T1]{fontenc}
\usepackage{graphicx}

\usepackage{setspace}
\usepackage{bchart}
\usepackage{float}
\usepackage{listings}
\usepackage{color}
\usepackage{textcomp}
\lstset{
%frame=tb,
  language=C++,
  aboveskip=3mm,
  belowskip=3mm,
  showstringspaces=false,
  columns=flexible,
  %basicstyle={\small\ttfamily},
  basicstyle=\ttfamily\footnotesize\bfseries,
  numbers=none,
  numberstyle=\tiny\color{gray},
  %keywordstyle=\color{blue},
  commentstyle=\color{dkgreen},
  %stringstyle=\color{mauve},
  breaklines=true,
  breakatwhitespace=true,
  tabsize=3
}

\usepackage{tikz}
\usetikzlibrary{positioning}

\begin{document}

\centering
\begin{tikzpicture}
  \node(listing1)[draw]{%
\begin{minipage}{.45\linewidth}
\begin{lstlisting}
array stat_1[144] : w32 -> w8 = symbolic
(query [(Eq falseq
            (Eq 0
                N0:(ReadLSB w64 56 stat_1)))
        (Eq false
            (Eq 0 N1:(URem w64 8 N0)))]
       (Eq false
           (Eq 0 N2:(Read w8 56 stat_1))))
\end{lstlisting}
\end{minipage}
}
node(listing2)[draw,right=of listing1]{%
\begin{minipage}{.45\linewidth}
\begin{lstlisting}
array stat_1[144] : w32 -> w8 = symbolic
(query [(Eq falseq
            (Eq 0
                N0:(ReadLSB w64 56 stat_1)))
        (Eq false
            (Eq 0 N1:(URem w64 8 N0)))
        (Eq false
            (Eq 0 (URem w64 N0 N1)))]
       (Eq false
           (Eq 0 N2:(Read w8 56 stat_1))))
\end{lstlisting}
\end{minipage}
};
\draw[->] (listing1)--(listing2);
\end{tikzpicture}

\end{document}

相关内容