答案1
@Ignasy 答案的变体,但包含一些(题外话)图像和图像代码改进/更改。代码中差异用 标记<---
:
\documentclass[margin=3mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows.meta, % <--- added
ext.paths.ortho, % <--- added
positioning}
\begin{document}
\begin{tikzpicture}[
arr/.style = {-Latex, rounded corners=4mm},
lbl/.style = {font=\footnotesize, text=red, auto},
N/.style = {draw, semithick, minimum width=2cm, minimum height=1.5cm}
] % <--- added image elements styles
\node[N] (a) {$\displaystyle \int \cos x \,dx$}; % <--- changed
\node[N, right=of a] (b) {$x^2 \sin x$}; % <--- changed
\draw[arr] (a) r-ud [distance=-10mm] node[lbl] {$a$ to $b$} (b); % <--- changed
\draw[arr] (b) r-du [distance=-10mm] node[lbl] {$b$ to $a$} (a); % <--- changed
\end{tikzpicture}
\end{document}
编辑: 现在被认为是@Qrrbrbirlbel,TikZ 扩展包作者,评论。
答案2
\documentclass[10pt,a4paper]{article}
\usepackage{amsmath,tikz}
\usetikzlibrary{positioning}
\begin{document}
\begin{tikzpicture}
\node[minimum width=2cm, minimum height=1.5cm, draw] (a) {$\int \cos x \,dx$};
\node[minimum width=2cm, minimum height=1.5cm, draw, right=2cm of a] (b) {$x^2 \sin x$};
\draw[-latex, rounded corners] (a) --++(90:2cm)-| node[near start, red, above]{$a$ to $b$} (b);
\draw[-latex, rounded corners] (b) --++(-90:2cm) -| node[near start, red, below]{$b$ to $a$} (a);
\end{tikzpicture}
\end{document}
答案3
像这样:
代码:
\documentclass[10pt,a4paper]{article}
\usepackage{amsmath,tikz}
\begin{document}
\begin{tikzpicture}[scale=2]
\draw (0,0) rectangle (.8,.5) node[midway] (a) {$\int \cos x \,dx$};
\draw (2,0) rectangle (2.8,.5) node[midway] (b) {$x^2 \sin x$};
\draw[-latex] (.4,.5) to [out=60,in=120] node[red, above]{$a$ to $b$} (2.4,.5);
\draw[-latex] (2.4,0) to [out=-120,in=-60] node[red, below]{$b$ to $a$} (.4,0);
\end{tikzpicture}
\end{document}