Tikz:在图形右侧插入文本/数学(逐项列出)

Tikz:在图形右侧插入文本/数学(逐项列出)

我想在以下 tikz 图片的右侧插入一些文字和数学运算:有人能帮帮我吗?

\documentclass{beamer}
\usepackage{tikz}
\usetikzlibrary{shapes,arrows,chains,calc}

\begin{document}
\tikzstyle{block} = [rectangle, draw, text width=6em, text centered, rounded corners, minimum height=4em]
\tikzstyle{line} = [draw, -latex']


\begin{tikzpicture}[node distance=1cm, auto]
\node (init) {};
\node [block] (A) {A};
\node [block, right=1.5cm of A] (B) {B};
\node [block, above=2cm of {$(A)!0.5!(B)$}] (C) {C};

\path [line] (A) -- node [text width=2.5cm,midway,above,align=center ] {$x^2-2x+5$} (B);
      \path [line] (C) -- node [text width=1.5cm,midway,left,align=center ] {$\int_1^2x^2 \text{dx}$} (A);
 \path [line] (C) -- node [text width=1.5cm,midway,right,align=center ] {$\lambda(t,s)$} (B);
\end{tikzpicture}

\end{document}

答案1

您可以使用columnsbeamer 环境。请参阅文档的第 12.7 章beamuserguide.pdf,版本 3.36。(现在您明白为什么我想要所有这些出色的 LaTeX 手册的可链接 HTML 版本...)

\documentclass{beamer}
\usepackage{tikz}
\usetikzlibrary{shapes,arrows,chains,calc}

\tikzset{
  block/.style={
    rectangle,
    draw,
    text width=6em,
    text centered,
    rounded corners,
    minimum height=4em
  },
  line/.style={draw, -latex'},
}

\begin{document}

\begin{columns}[T]
    \begin{column}{.62\linewidth}
        \begin{tikzpicture}[node distance=1cm, auto]
            \node (init) {};
            \node [block] (A) {A};
            \node [block, right=1.5cm of A] (B) {B};
            \node [block, above=2cm of {$(A)!0.5!(B)$}] (C) {C};

            \path [line] (A) -- node [text width=2.5cm,midway,above,align=center ] {$x^2-2x+5$} (B);
            \path [line] (C) -- node [text width=1.5cm,midway,left,align=center ] {$\int_1^2x^2 \text{dx}$} (A);
            \path [line] (C) -- node [text width=1.5cm,midway,right,align=center ] {$\lambda(t,s)$} (B);
        \end{tikzpicture}
    \end{column}%
    \hfill%
    \begin{column}{.3\linewidth}
        Text and 
        \[ y = f(x) \]
        formulas\dots
    \end{column}
\end{columns}

\end{document}

在此处输入图片描述

...你可能需要在这里或那里添加空格来让它看起来更好。但你明白了。

附录 \tikzstyle\tikzset已过时。已提供更好的定义。

答案2

只是 Rmano 答案的一个小变化(关于图片)。如果您喜欢垂直居中列,则省略 中的选项 [T] \column。我的经验表明,对于等式和文本,列宽永远不会足够大,因此我建议两列的宽度相等。

\documentclass{beamer}
\usepackage{tikz}
\usetikzlibrary{arrows,calc,positioning,quotes}

\tikzset{
  block/.style={
    rectangle,
    draw,
    minimum width=5em,
    rounded corners,
    minimum height=6ex
  },
  line/.style={draw, -latex'},
}

\begin{document}
\begin{frame}{Relations between A, B and C \dots}
\begin{columns}[T]
    \begin{column}{.48\linewidth}
\begin{tikzpicture}[node distance=1cm and 2.5cm]
    \node [block] (A) {A};
    \node [block, right=of A] (B) {B};
    \node [block, above=2cm of {$(A)!0.5!(B)$}] (C) {C};

\draw[line] (A) edge["$x^2-2x+5$"] (B) 
            (C) edge["$\int_1^2x^2 \mathsf{d}x$" '] (A)
            (C) edge["{$\lambda(t,s)$}"] (B);
\end{tikzpicture}
    \end{column}
    \hfill
    \begin{column}{.48\linewidth}
\begin{itemize}
\item   $a^2 + b^2 = c^2$
\item   considering
\[ c = \sqrt{a^2 + b^2} \]
    more text \dots more text \dots more text \dots
\item   \dots
\item   \dots
\item   \dots
\end{itemize}

    \end{column}
\end{columns}
\end{frame}
\end{document}

该 MWE 给出:

在此处输入图片描述

相关内容