如何制作带有方框文字或数学和箭头的图表?

如何制作带有方框文字或数学和箭头的图表?

我怎样才能制作这样的图表?

答案1

我通过使用 TikZ 实现了这一点,代码如下:

\documentclass[11pt]{article}
\usepackage{amsmath, amsfonts, bm, listings, enumitem, geometry, titlesec,
array, makecell, caption, graphicx, float, algorithm, algpseudocode}

\usepackage{tikz}
\usetikzlibrary{shapes.geometric, arrows.meta}

\tikzstyle{process} = [rectangle, minimum width=2cm, minimum height=1.3cm, 
text centered, draw=black]
\tikzstyle{arrow} = [thick,->,>={Stealth[scale=1.1]}]

\title{}
\author{}
\date{}

\begin{document}
\maketitle

\begin{center}
    \begin{tikzpicture}
        \node (agent) [process, minimum width=2cm, minimum height=2cm,
            label={[anchor=north,inner sep=5pt]north:Agent}]{};
        \node (pi) [process, left of=agent, minimum width=1cm, 
            minimum height=1cm,xshift=1cm, yshift=-0.3cm] {\(\pi\)};
        \node (env) [process, minimum height=1.5cm, below of=pi, yshift=-1cm] 
            {Environment};

        \draw [arrow] (env.163) -- ++(-1.5,0) node[anchor=south, xshift=0.8cm]
            {\(S_{t+1}\)} coordinate(a1);
        \draw [arrow] (a1) -- ++(-0.7,0) |- node[anchor=south, xshift=1.3cm] 
            {\(S_t\)} (pi);
        \draw [arrow] (env.197) -- ++(-1.5,0) node[anchor=south, xshift=0.8cm]
            {\(R_{t+1}\)} coordinate(a2);
        \draw [arrow] (a2) -- ++(-1.3,0) -- ++(0,3.2) 
            -- node[anchor=south, xshift=0.5cm] {\(R_t\)} (agent.154);
        \draw [arrow] (pi) -- ++(2.7,0) node[anchor=south, xshift=-0.8cm] 
            {\(A_t\)} |- (env);
        \draw [dashed,thick] (-2.7,-1.5) -- (-2.7, -3.2);
    \end{tikzpicture}   
\end{center}

\end{document}

相关内容