[Tex/LaTex] Blocks with TikZ

beamerblocktikz-nodetikz-pgf

For a beamer presentation I am using TikZ for creating a rounded block with some text in it. The following is the working example:

\documentclass{beamer} %
\usetheme{CambridgeUS}
\usepackage[latin1]{inputenc}
\usefonttheme{professionalfonts}
\usepackage{times,textpos}
\usepackage{tikz}
\usepackage{amsmath}
\usepackage{verbatim}
\usetikzlibrary{arrows,shapes}

\author{Author}
\title{Presentation title}

\begin{document}

\begin{frame}{TIkZ}
 \begin{textblock*}{2.50cm}(0.5cm,0.25cm)

    \begin{tikzpicture}
    \node [fill=green!30, rounded corners=6pt] {{\color{blue}How to write a very very very very long sentence in two lines inside this block using tikz}};
    \end{tikzpicture}

  \end{textblock*}
\end{frame}

\end{document}

In this example I am trying to write a very long sentence inside the block, but it goes the outside the page margins. Is there any way to adjust the block size such that words outside the margin start in a new paragraph inside the block.

Please help.

Best Answer

You could use : text width and minimum widthoption

\documentclass{beamer} %
\usetheme{CambridgeUS}
\usepackage[latin1]{inputenc}
\usefonttheme{professionalfonts}
\usepackage{times,textpos}
\usepackage{tikz}
\usepackage{amsmath}
\usepackage{verbatim}
\usetikzlibrary{arrows,shapes}

\author{Author}
\title{Presentation title}

\begin{document}

\begin{frame}{TIkZ}
 \begin{textblock*}{2.50cm}(0.5cm,0.25cm)

    \begin{tikzpicture}
      \node [fill=green!30, rounded corners=6pt,
      font=\color{blue}, minimum width=10cm, text width=10cm] {How to write a very very very very long sentence in two lines inside this block using tikz};
    \end{tikzpicture}

  \end{textblock*}
\end{frame}

\end{document}

enter image description here