我该如何画出连接箭头的线?这是我设法编写的代码,由于我是 Latex 新手,因此可能比较混乱和不整洁
\begin{center}
$ \downarrow \linebreak
\fbox{\parbox{4 cm}{In x(n); \hspace{0.1 cm} A/D\linebreak Out x(n-1);%
\hspace{0.1 cm} D/A\linebreak x(n-1) = x(n);\hspace{00.1 cm} Shift}} \linebreak
\downarrow$
\end{center}
答案1
这是利用强大力量之间的奇妙互动的一种可能性tcolorbox
和listings
包装:
代码:
\documentclass{article}
\usepackage[many]{tcolorbox}
\tcbuselibrary{listings}
\lstset{
basicstyle=\small\ttfamily,
columns=fullflexible
}
\begin{document}
\begin{tcblisting}{enhanced,listing only,hbox,remember as=mycode,colframe=green!60!black,colback=white}
In x(n); A/D
Out x(n-1); D/A
x(n-1) = x(n); Shift
\end{tcblisting}
\begin{tikzpicture}[remember picture,overlay,>=latex]
\draw[->]
(mycode.south) -- ([yshift=-30pt]mycode.south);
\draw
([yshift=-30pt]mycode.south) --
([xshift=30pt,yshift=-30pt]mycode.south east) |-
([yshift=30pt]mycode.north);
\draw[->]
([yshift=30pt]mycode.north) -- (mycode.north);
\end{tikzpicture}
\end{document}