3

I want to draw rectangular box around some text, and use arrows to point from one of them to the other. But, one text is a bit longer, so I also want to split it into to lines. I have the following:

\documentclass{beamer}

\usepackage{tikz}
\usetikzlibrary{positioning,shapes}

\begin{document}

\begin{frame}{Test}
\begin{columns}
    \begin{column}{0.50\textwidth}
        One side

        \begin{tikzpicture}[rectangle,draw=cyan,thick]

            \node (pq1) {Hard problems};
            \node [dashed,below=of pq1] (pq2) {Construct new problems};
            \node [below=of pq2] (pq3) {Framework fail};
            \node [dashed,below=of pq3] (pq4) {Analyze against \\new adversaries};

            \path[->,thick,cyan] (pq1) edge  (pq2)
                                 (pq3) edge  (pq4);
        \end{tikzpicture}
    \end{column}

    \begin{column}{0.50\textwidth}
        Other Part
    \end{column}
\end{columns}
\end{frame}

\end{document}

The point is that only the arrows are drawn, but rectangles are not drawn around the text. I want two of them to be with solid lines, the other two with dashed lines. Also how can I split the text into to lines in TikZ node?

3

Like this:

enter image description here

For node you need define option align and in your case I suggest also text width=.... I assume, that the shapes of all nodes are the same, so I define a common style for all:

\documentclass{beamer}
\usepackage{tikz}
\usetikzlibrary{positioning}

\begin{document} 
\begin{frame}{Test}
\begin{columns}
    \begin{column}{0.50\textwidth}
        One side
\begin{center}
        \begin{tikzpicture}[
every node/.style = {shape=rectangle,% is not necessary, default node's shape is rectangle
                     draw=cyan, semithick,
                     text width=0.8\linewidth,
                     align=center}
                            ]
\node (pq1) [draw] {Hard problems};
\node (pq2) [dashed,below=of pq1] {Construct new problems};
\node (pq3) [below=of pq2] {Framework fail};
\node (pq4) [dashed,below=of pq3] {Analyze against \\new adversaries};
%
\path[->,thick,cyan] (pq1) edge  (pq2)
                     (pq3) edge  (pq4);
        \end{tikzpicture}
\end{center}
    \end{column}
    \begin{column}{0.50\textwidth}
        Other Part
    \end{column}
\end{columns}
\end{frame}
\end{document}

If you like to have diferent nodes shape width, accomodate to contained text, than delete option text width=... in definition for every node.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.